GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — observability: annotate Session+SessionPool events by odeke-em · Pull Request #1207 · googleapis/python-spanner

This repository was archived by the owner on Jun 8, 2026. It is now read-only.

Conversation

@odeke-em

@odeke-em odeke-em commented Sep 19, 2024 •
edited by harshachinta
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This change adds annotations for session and session pool events to aid customers in debugging latency issues with session pool malevolence and also for maintainers to figure out which session pool type is the most appropriate.

Updates #1170

BEGIN_COMMIT_OVERRIDE
feat: add additional opentelemetry span events for session pool
END_COMMIT_OVERRIDE

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@odeke-em
odeke-em requested review from a team September 19, 2024 03:48
@product-auto-label product-auto-label Bot added the size: m Pull request size is medium. label Sep 19, 2024
@blunderbuss-gcf blunderbuss-gcf Bot assigned manu2 Sep 19, 2024
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the googleapis/python-spanner API. label Sep 19, 2024
@odeke-em
odeke-em force-pushed the trace-annotation-SessionPools branch 3 times, most recently from 8d6f2b7 to 4bc937e Compare September 19, 2024 07:37
@odeke-em

odeke-em commented Sep 19, 2024

Copy link
Copy Markdown
Contributor Author

Exhibit

On running examples/grpc_instrumentation_enabled.py we get back these traces
Screenshot 2024-09-18 at 9 39 29 PM
Screenshot 2024-09-18 at 9 39 47 PM
Screenshot 2024-09-18 at 9 40 01 PM
Screenshot 2024-09-18 at 9 40 25 PM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@odeke-em

odeke-em commented Sep 19, 2024

Copy link
Copy Markdown
Contributor Author

cc @harshachinta

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@odeke-em
odeke-em force-pushed the trace-annotation-SessionPools branch from 4bc937e to 0d5bf26 Compare September 19, 2024 07:45
@harshachinta harshachinta added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 19, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 19, 2024
@odeke-em
odeke-em force-pushed the trace-annotation-SessionPools branch from 0d5bf26 to 3617921 Compare September 19, 2024 13:43
@harshachinta harshachinta added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 19, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 19, 2024
@odeke-em
odeke-em force-pushed the trace-annotation-SessionPools branch 2 times, most recently from f71d05c to eb9dd5a Compare September 20, 2024 01:27
@harshachinta harshachinta added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 20, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 20, 2024
@odeke-em
odeke-em force-pushed the trace-annotation-SessionPools branch from b1ea772 to ab23f09 Compare September 20, 2024 22:09
@odeke-em

odeke-em commented Sep 20, 2024

Copy link
Copy Markdown
Contributor Author

Kindly cc-ing you @harshachinta.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@harshachinta harshachinta added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 23, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 23, 2024
harshachinta
harshachinta suggested changes Oct 1, 2024
View reviewed changes
Comment thread google/cloud/spanner_v1/pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/_opentelemetry_tracing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/session.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/session.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/session.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@odeke-em
odeke-em requested a review from harshachinta October 7, 2024 02:36
@odeke-em

odeke-em commented Oct 7, 2024

Copy link
Copy Markdown
Contributor Author

Kindly please take another look @harshachinta, feedback addressed, thank you for the code review!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

harshachinta
harshachinta reviewed Oct 9, 2024
View reviewed changes
Comment thread google/cloud/spanner_v1/_opentelemetry_tracing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

harshachinta
harshachinta reviewed Oct 9, 2024
View reviewed changes
Comment thread google/cloud/spanner_v1/pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

harshachinta
harshachinta reviewed Oct 9, 2024
View reviewed changes
Comment thread google/cloud/spanner_v1/pool.py Outdated
)

if requested_session_count > 0:
current_span.add_event(

@harshachinta harshachinta Oct 9, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current_span is not initialized.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@odeke-em odeke-em Oct 9, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sheesh, sorry I had a bunch of benchmarks running locally and they interrupted my nox -s unit-3.8 tests so didn't see those but all fixed now.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@odeke-em
odeke-em force-pushed the trace-annotation-SessionPools branch from e60b662 to 3a1611e Compare November 27, 2024 04:08
harshachinta
harshachinta reviewed Nov 28, 2024
View reviewed changes
Comment thread google/cloud/spanner_v1/_opentelemetry_tracing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/session.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/spanner_v1/transaction.py Outdated
Comment on lines +286 to +287
if self._transaction_id is None and len(self._mutations) > 0:
self.begin()

@harshachinta harshachinta Nov 28, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self._transaction_id is None and len(self._mutations) > 0:
self.begin()

Why is this added here? This is already getting executed in the beginning of commit() call, so not needed

python-spanner/google/cloud/spanner_v1/transaction.py

Line 237 in 054a186

if self._transaction_id is None and len(self._mutations) > 0:

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/spanner_v1/pool.py Outdated
)
session = self._sessions.get(block=True, timeout=timeout)
except queue.Empty as e:
add_span_event(current_span, "No session available", span_event_attributes)

@harshachinta harshachinta Nov 28, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
add_span_event(current_span, "No session available", span_event_attributes)
add_span_event(current_span, "No session available in the pool", span_event_attributes)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/spanner_v1/pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_pool.py Outdated
Comment on lines +261 to +262
"exception",
"exception",

@harshachinta harshachinta Nov 28, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are there 2 exception events?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@odeke-em odeke-em Nov 28, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a quirk with opentelemetry-python; they add "exception" on every exit call whether or not you set your own, I'll file a bug later on but for now I'll just remove our explicit invocation of "span.record_exception" and instead add our comment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/unit/test_pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread tests/unit/test_pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@harshachinta harshachinta added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 28, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 28, 2024
@odeke-em
odeke-em requested a review from harshachinta November 28, 2024 14:08
@odeke-em

odeke-em commented Nov 28, 2024

Copy link
Copy Markdown
Contributor Author

Thank you @harshachinta for the review, I've addressed the feedback. Please take a look again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@odeke-em
odeke-em force-pushed the trace-annotation-SessionPools branch from b6187d8 to e654029 Compare November 28, 2024 14:26
@harshachinta harshachinta added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 28, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 28, 2024
@odeke-em

odeke-em commented Nov 29, 2024

Copy link
Copy Markdown
Contributor Author

@harshachinta kindly help me run the bots.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@harshachinta harshachinta added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 29, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 29, 2024
harshachinta
harshachinta approved these changes Nov 29, 2024
View reviewed changes

@harshachinta harshachinta left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix lint

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/cloud/spanner_v1/_opentelemetry_tracing.py
yield span
except Exception as error:
span.set_status(Status(StatusCode.ERROR, str(error)))
span.record_exception(error)

@harshachinta harshachinta Nov 29, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets not remove this exception. We are not sure if there are any cases where the span will end up not recording an exception.
I would suggest adding this back here and let us discuss more during our demo.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@harshachinta harshachinta Nov 29, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I was wondering that this behavior of exception getting added twice was not seen earlier since this code exists from very long.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@odeke-em odeke-em Nov 29, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because OpenTelemetry was upgraded only recently.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@odeke-em odeke-em Nov 29, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have locked tests to check for the exceptions to ensure that they are in there and from Span.enter. I had to dive back into OpenTelemetry-Python's code as it isn't even documented and in our demos it was very distracting to have mysteriously both errors. I think for the sake of our sanity and project stability let's leave that comment in and if anything happens it is a trivial one to add back @harshachinta

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@harshachinta harshachinta Dec 2, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. But the opentelemetry documentation for Python guides to record exception for instrumentation libraries.
https://opentelemetry.io/docs/languages/python/instrumentation/#record-exceptions-in-spans

Can you share the code pointer on where the opentelemetry records exception by default when exiting?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@odeke-em odeke-em Dec 2, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshachinta https://github.com/open-telemetry/opentelemetry-python/blob/db4ef06f471cb9e94d810ae66964c3e5e0f5e61e/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py#L986-L1008

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@odeke-em odeke-em Dec 2, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harshachinta it was the cause of us seeing 2 exceptions and took a ton of confusion and time for me to debug, they don't seem to document this condition.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@harshachinta harshachinta added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 2, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 2, 2024
harshachinta
harshachinta reviewed Dec 2, 2024
View reviewed changes
Comment thread tests/unit/test_pool.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@odeke-em

odeke-em commented Dec 2, 2024

Copy link
Copy Markdown
Contributor Author

@harshachinta kindly help me re-run the bots; all unit tests pass locally.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sakthivelmanii sakthivelmanii added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 2, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 2, 2024
@odeke-em
odeke-em force-pushed the trace-annotation-SessionPools branch from 498a70a to 060d17c Compare December 3, 2024 10:04
@harshachinta harshachinta added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 3, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 3, 2024
@odeke-em
odeke-em force-pushed the trace-annotation-SessionPools branch from 060d17c to b400718 Compare December 5, 2024 10:31
@sakthivelmanii sakthivelmanii added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 5, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 5, 2024
@odeke-em
observability: annotate Session+SessionPool events
1d7e440
This change adds annotations for session and session pool
events to aid customers in debugging latency issues with
session pool malevolence and also for maintainers to
figure out which session pool type is the most appropriate.

Updates googleapis#1170
@odeke-em
odeke-em force-pushed the trace-annotation-SessionPools branch from b400718 to 1d7e440 Compare December 6, 2024 07:54
@rahul2393 rahul2393 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 6, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 6, 2024
@harshachinta
harshachinta merged commit a6811af into googleapis:main Dec 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@harshachinta harshachinta harshachinta approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@manu2 manu2

Labels

api: spanner Issues related to the googleapis/python-spanner API. size: l Pull request size is large.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@odeke-em @harshachinta @manu2 @rahul2393 @yoshi-kokoro @sakthivelmanii
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.