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 — feat(observability): more descriptive and value adding spans by odeke-em · Pull Request #1241 · 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 Nov 18, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

This change adds more descriptive and value adding spans to replace the generic CloudSpanner.ReadWriteTransaction. With this change, we add new spans:

  • CloudSpanner.Database.run_in_transaction
  • CloudSpanner.execute_pdml
  • CloudSpanner.execute_sql
  • CloudSpanner.execute_update

Exhibit

Given this code

def tx_dql_select(tx):
    try:
        tx.execute_update("DELETE FROM Singers WHERE 1=1")
    except:
        pass

    tx.execute_update(
        'INSERT INTO Singers(SingerId, FirstName, LastName) VALUES(1000, "Bryan", "Adams"), (2000, "Slash", "GunsNRoses")'
    )
    tx.update(
        "Singers",
        columns=["SingerId", "FirstName"],
        values=[["1", "Bryan"], ["2", "Slash"]],
    )
    rows = tx.execute_sql("SELECT * FROM Singers")
    for row in rows:
        print(row)

we now have this exhibit

Without gRPC instrumentation

Screenshot 2024-11-18 at 2 08 46 AM

With gRPC instrumentation

Screenshot 2024-11-18 at 2 12 26 AM

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 November 18, 2024 10:09
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. api: spanner Issues related to the googleapis/python-spanner API. labels Nov 18, 2024
@blunderbuss-gcf blunderbuss-gcf Bot assigned rahul2393 Nov 18, 2024
@odeke-em
odeke-em force-pushed the trace-update-more-descriptive-Database.run_in_transaction-spans branch from bc1befe to 502d0e5 Compare November 18, 2024 22:55
harshachinta
harshachinta suggested changes Nov 20, 2024
View reviewed changes
Comment thread google/cloud/spanner_v1/database.py Resolved

Uh oh!

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

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

Uh oh!

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

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

Uh oh!

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

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

Uh oh!

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

Comment thread google/cloud/spanner_v1/database.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/snapshot.py Resolved

Uh oh!

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

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

Uh oh!

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

Comment thread google/cloud/spanner_v1/transaction.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 November 20, 2024 10:34
@odeke-em

odeke-em commented Nov 20, 2024

Copy link
Copy Markdown
Contributor Author

Kindly help me take a look @harshachinta and help me run the bots afresh!

All reactions

Sorry, something went wrong.

Uh oh!

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

odeke-em
odeke-em commented Nov 20, 2024
View reviewed changes
Comment thread google/cloud/spanner_v1/database.py Outdated
Comment on lines +699 to +707
if span:
span.add_event("Starting BeginTransaction")
txn = api.begin_transaction(
session=session.name, options=txn_options, metadata=metadata
)
if span:
span.add_event(
"Completed BeginTransaction", {"transaction.id": txn.id}
)

@odeke-em odeke-em Nov 20, 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 please take a look.

Sorry, something went wrong.

Uh oh!

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

All reactions
odeke-em
odeke-em commented Nov 20, 2024
View reviewed changes
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 commented Nov 20, 2024

Copy link
Copy Markdown
Contributor Author

@harshachinta kindly help me run the bots one more time, I sent up a fix!

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-update-more-descriptive-Database.run_in_transaction-spans branch 2 times, most recently from 8d613ee to f767159 Compare November 20, 2024 12:06
@sakthivelmanii sakthivelmanii added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 20, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 20, 2024
@odeke-em odeke-em mentioned this pull request Nov 20, 2024
observability: annotate Session+SessionPool events #1207
Merged
@product-auto-label product-auto-label Bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Nov 22, 2024
harshachinta
harshachinta reviewed Nov 22, 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/database.py Outdated
Comment on lines +738 to +739
if isinstance(observability_options, dict):
observability_options["db_name"] = self.name

@harshachinta harshachinta Nov 21, 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.

I think we can do a much simpler thing instead of adding db_name manually at every place.
We have configured a @Property for observability_options in database.py

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

Line 1111 in 054a186

def observability_options(self):

Can we add a new field, db_name, to observability_options if it already exists? If the customer does not provide any observability_options, we can create a new dictionary with this field. With this we need not do it at multiple places, WDYT?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/cloud/spanner_v1/database.py Outdated
if isinstance(observability_options, dict):
observability_options["db_name"] = self.name
with trace_call(
"CloudSpanner.execute_partitioned_pdml",

@harshachinta harshachinta Nov 22, 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.

The problem i see here is with every retry there will be a new span parent CloudSpanner.execute_partitioned_pdml which does not indicate that a retry is happening.
Instead we should capture the retries with in only one parent span CloudSpanner.execute_partitioned_pdml.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/cloud/spanner_v1/database.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.

@odeke-em
odeke-em force-pushed the trace-update-more-descriptive-Database.run_in_transaction-spans branch 3 times, most recently from beb8bb9 to d297b66 Compare November 28, 2024 07:41
@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
@odeke-em
odeke-em force-pushed the trace-update-more-descriptive-Database.run_in_transaction-spans branch from be40273 to 47ffdfc Compare December 2, 2024 05:24
@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
@odeke-em
odeke-em force-pushed the trace-update-more-descriptive-Database.run_in_transaction-spans branch from cd4a8b1 to 4829a9a Compare December 2, 2024 12:57
@product-auto-label product-auto-label Bot removed the size: l Pull request size is large. label Dec 3, 2024
@product-auto-label product-auto-label Bot added the size: xl Pull request size is extra large. label Dec 3, 2024
@odeke-em
odeke-em force-pushed the trace-update-more-descriptive-Database.run_in_transaction-spans branch from 8d6dad0 to eecca2e Compare December 3, 2024 13:35
@harshachinta harshachinta added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 4, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 4, 2024
@odeke-em
odeke-em force-pushed the trace-update-more-descriptive-Database.run_in_transaction-spans branch 3 times, most recently from 204067a to 847d89b Compare December 6, 2024 11:30
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Dec 6, 2024
@odeke-em
observability: add updated span events + traace more methods
b9c16d0
This change carves out parts of PR googleapis#1241 in smaller pieces to
ease with smaller reviews.
This change adds more span events, updates important spans
to make them more distinct like changing:

"CloudSpanner.ReadWriteTransaction" to more direct and more
pointed spans like:
* CloudSpanner.Transaction.execute_streaming_sql

Also added important spans:
* CloudSpanner.Database.run_in_transaction
* CloudSpanner.Session.run_in_transaction
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Dec 6, 2024
@odeke-em
observability: add updated span events + traace more methods
873cc18
This change carves out parts of PR googleapis#1241 in smaller pieces to
ease with smaller reviews.
This change adds more span events, updates important spans
to make them more distinct like changing:

"CloudSpanner.ReadWriteTransaction" to more direct and more
pointed spans like:
* CloudSpanner.Transaction.execute_streaming_sql

Also added important spans:
* CloudSpanner.Database.run_in_transaction
* CloudSpanner.Session.run_in_transaction
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Dec 6, 2024
@odeke-em
observability: add updated span events + traace more methods
8372807
This change carves out parts of PR googleapis#1241 in smaller pieces to
ease with smaller reviews.
This change adds more span events, updates important spans
to make them more distinct like changing:

"CloudSpanner.ReadWriteTransaction" to more direct and more
pointed spans like:
* CloudSpanner.Transaction.execute_streaming_sql

Also added important spans:
* CloudSpanner.Database.run_in_transaction
* CloudSpanner.Session.run_in_transaction
@odeke-em odeke-em mentioned this pull request Dec 6, 2024
feat: add updated span events + trace more methods #1259
Merged
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Dec 7, 2024
@odeke-em
observability: add updated span events + traace more methods
b0d9a6c
This change carves out parts of PR googleapis#1241 in smaller pieces to
ease with smaller reviews.
This change adds more span events, updates important spans
to make them more distinct like changing:

"CloudSpanner.ReadWriteTransaction" to more direct and more
pointed spans like:
* CloudSpanner.Transaction.execute_streaming_sql

Also added important spans:
* CloudSpanner.Database.run_in_transaction
* CloudSpanner.Session.run_in_transaction
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Dec 7, 2024
@odeke-em
observability: add updated span events + traace more methods
f437955
This change carves out parts of PR googleapis#1241 in smaller pieces to
ease with smaller reviews.
This change adds more span events, updates important spans
to make them more distinct like changing:

"CloudSpanner.ReadWriteTransaction" to more direct and more
pointed spans like:
* CloudSpanner.Transaction.execute_streaming_sql

Also added important spans:
* CloudSpanner.Database.run_in_transaction
* CloudSpanner.Session.run_in_transaction
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Dec 16, 2024
@odeke-em
observability: add updated span events + traace more methods
b238181
This change carves out parts of PR googleapis#1241 in smaller pieces to
ease with smaller reviews.
This change adds more span events, updates important spans
to make them more distinct like changing:

"CloudSpanner.ReadWriteTransaction" to more direct and more
pointed spans like:
* CloudSpanner.Transaction.execute_streaming_sql

Also added important spans:
* CloudSpanner.Database.run_in_transaction
* CloudSpanner.Session.run_in_transaction
harshachinta pushed a commit that referenced this pull request Dec 17, 2024
@odeke-em
feat: add updated span events + trace more methods (#1259)
ad69c48
* observability: add updated span events + traace more methods

This change carves out parts of PR #1241 in smaller pieces to
ease with smaller reviews.
This change adds more span events, updates important spans
to make them more distinct like changing:

"CloudSpanner.ReadWriteTransaction" to more direct and more
pointed spans like:
* CloudSpanner.Transaction.execute_streaming_sql

Also added important spans:
* CloudSpanner.Database.run_in_transaction
* CloudSpanner.Session.run_in_transaction

* all: update review comments + show type for BeginTransaction + remove prints

* Remove requested span event "Using Transaction"

* Move attempts into try block

* Transform Session.run_in_transaction retry exceptions into events

* More comprehensive test for events and attributes for pool.get

* Add test guards against Python3.7 for which OpenTelemetry is unavailable + address test feedback

* Remove span event per mutation in favour of future TODO

Referencing issue #1269, this update removes adding
a span event per mutation, in favour of a future TODO.

* Sort system-test.test_transaction_abort_then_retry_spans spans by create time

* Delint tests
@odeke-em
feat(observability): more descriptive and value adding spans
f28ed47
This change adds more descriptive and value adding spans to
replace the generic CloudSpanner.ReadWriteTransaction.
With this change, we add new spans:
* CloudSpanner.Database.run_in_transaction
* CloudSpanner.execute_pdml
* CloudSpanner.execute_sql
* CloudSpanner.execute_update
@odeke-em
odeke-em force-pushed the trace-update-more-descriptive-Database.run_in_transaction-spans branch from 847d89b to f28ed47 Compare December 17, 2024 10:38
@product-auto-label product-auto-label Bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Dec 17, 2024
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Dec 17, 2024
@odeke-em
observability: PDML + some batch write spans
6777f97
This change adds spans for Partitioned DML and making
updates for Batch.

Carved out from PR googleapis#1241.
@odeke-em odeke-em mentioned this pull request Dec 17, 2024
observability: PDML + some batch write spans #1274
Merged
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Dec 27, 2024
@odeke-em
observability: PDML + some batch write spans
b20eee8
This change adds spans for Partitioned DML and making
updates for Batch.

Carved out from PR googleapis#1241.
aakashanandg pushed a commit to aakashanandg/python-spanner that referenced this pull request Jan 2, 2025
@odeke-em @aakashanandg
feat: add updated span events + trace more methods (googleapis#1259)
b63b49e
* observability: add updated span events + traace more methods

This change carves out parts of PR googleapis#1241 in smaller pieces to
ease with smaller reviews.
This change adds more span events, updates important spans
to make them more distinct like changing:

"CloudSpanner.ReadWriteTransaction" to more direct and more
pointed spans like:
* CloudSpanner.Transaction.execute_streaming_sql

Also added important spans:
* CloudSpanner.Database.run_in_transaction
* CloudSpanner.Session.run_in_transaction

* all: update review comments + show type for BeginTransaction + remove prints

* Remove requested span event "Using Transaction"

* Move attempts into try block

* Transform Session.run_in_transaction retry exceptions into events

* More comprehensive test for events and attributes for pool.get

* Add test guards against Python3.7 for which OpenTelemetry is unavailable + address test feedback

* Remove span event per mutation in favour of future TODO

Referencing issue #1269, this update removes adding
a span event per mutation, in favour of a future TODO.

* Sort system-test.test_transaction_abort_then_retry_spans spans by create time

* Delint tests
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Jan 9, 2025
@odeke-em
observability: PDML + some batch write spans
31f6e4c
This change adds spans for Partitioned DML and making
updates for Batch.

Carved out from PR googleapis#1241.
odeke-em added a commit to odeke-em/python-spanner that referenced this pull request Jan 10, 2025
@odeke-em
observability: PDML + some batch write spans
048e4cc
This change adds spans for Partitioned DML and making
updates for Batch.

Carved out from PR googleapis#1241.
harshachinta pushed a commit that referenced this pull request Jan 10, 2025
@odeke-em
observability: PDML + some batch write spans (#1274)
592047f
* observability: PDML + some batch write spans

This change adds spans for Partitioned DML and making
updates for Batch.

Carved out from PR #1241.

* Add more system tests

* Account for lack of OpenTelemetry on Python-3.7

* Update tests

* Fix more test assertions

* Updates from code review

* Update tests with code review suggestions

* Remove return per code review nit
@odeke-em

odeke-em commented Jun 5, 2025

Copy link
Copy Markdown
Contributor Author

Was split up but can be revived if needed.

All reactions

Sorry, something went wrong.

Uh oh!

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

@odeke-em odeke-em closed this Jun 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

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

Uh oh!

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

Assignees

@rahul2393 rahul2393

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.

5 participants

@odeke-em @harshachinta @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.