This repository was archived by the owner on Jun 8, 2026. It is now read-only.
Commit d37fb80
feat: add cloud.region, request_tag and transaction_tag in span attributes (#1449)
This change enhances observability by introducing these new features:
1. **Cloud Region Attribute**: The `cloud.region` attribute is now added
to all OpenTelemetry spans generated by the Spanner client. This
provides better geographical context for traces, aiding in performance
analysis and debugging across different regions.
2. **Transaction Tag**: The `transaction_tag` set on a `Transaction`
object is now correctly propagated and included in the `Commit` request.
This allows for better end-to-end traceability of transactions.
3. **Request Tag**: This introduces support for `request_tag` on
individual Spanner operations like `read`, `execute_sql`, and
`execute_update`. When a `request_tag` is provided in the
`request_options`, it is now added as a `spanner.request_tag` attribute
to the corresponding OpenTelemetry span. This allows for more granular
tracing and debugging of specific requests within a transaction or a
snapshot.
---------
Co-authored-by: surbhigarg92 <surbhigarg.92@gmail.com>1 parent 8b6f154 commit d37fb80Copy full SHA for d37fb80
16 files changed
+1,115-338Lines changed: 1115 additions & 338 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- google/cloud/spanner_v1
- metrics
- tests
- system
- unit
Expand file treeCollapse file tree
Open diff view settings
Collapse file
google/cloud/spanner_v1/_helpers.py
Copy file name to clipboardExpand all lines: google/cloud/spanner_v1/_helpers.py+49-4Lines changed: 49 additions & 4 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
20 | 20 | |
21 | 21 | |
22 | 22 | |
| 23 | + |
23 | 24 | |
24 | 25 | |
25 | 26 | |
| ||
29 | 30 | |
30 | 31 | |
31 | 32 | |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
| 33 | + |
| 34 | + |
| 35 | + |
36 | 36 | |
| 37 | + |
| 38 | + |
37 | 39 | |
38 | 40 | |
39 | 41 | |
40 | 42 | |
41 | 43 | |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
42 | 54 | |
43 | 55 | |
44 | 56 | |
| ||
55 | 67 | |
56 | 68 | |
57 | 69 | |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
58 | 76 | |
59 | 77 | |
60 | 78 | |
| ||
79 | 97 | |
80 | 98 | |
81 | 99 | |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + |
82 | 127 | |
83 | 128 | |
84 | 129 | |
|
Collapse file
google/cloud/spanner_v1/_opentelemetry_tracing.py
Copy file name to clipboardExpand all lines: google/cloud/spanner_v1/_opentelemetry_tracing.py+9Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
21 | 21 | |
22 | 22 | |
23 | 23 | |
| 24 | + |
24 | 25 | |
25 | 26 | |
26 | 27 | |
| ||
75 | 76 | |
76 | 77 | |
77 | 78 | |
| 79 | + |
78 | 80 | |
79 | 81 | |
80 | 82 | |
| ||
88 | 90 | |
89 | 91 | |
90 | 92 | |
| 93 | + |
91 | 94 | |
92 | 95 | |
93 | 96 | |
| ||
97 | 100 | |
98 | 101 | |
99 | 102 | |
| 103 | + |
100 | 104 | |
101 | 105 | |
102 | 106 | |
| ||
107 | 111 | |
108 | 112 | |
109 | 113 | |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
110 | 119 | |
111 | 120 | |
112 | 121 | |
|
Collapse file
google/cloud/spanner_v1/database.py
Copy file name to clipboardExpand all lines: google/cloud/spanner_v1/database.py+6Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1025 | 1025 | |
1026 | 1026 | |
1027 | 1027 | |
| 1028 | + |
| 1029 | + |
| 1030 | + |
| 1031 | + |
| 1032 | + |
1028 | 1033 | |
1029 | 1034 | |
| 1035 | + |
1030 | 1036 | |
1031 | 1037 | |
1032 | 1038 | |
|
Collapse file
google/cloud/spanner_v1/metrics/spanner_metrics_tracer_factory.py
Copy file name to clipboardExpand all lines: google/cloud/spanner_v1/metrics/spanner_metrics_tracer_factory.py+3-38Lines changed: 3 additions & 38 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
| 21 | + |
26 | 22 | |
27 | 23 | |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | 24 | |
36 | 25 | |
37 | 26 | |
| ||
44 | 33 | |
45 | 34 | |
46 | 35 | |
| 36 | + |
47 | 37 | |
48 | 38 | |
49 | 39 | |
| ||
86 | 76 | |
87 | 77 | |
88 | 78 | |
89 | | - |
| 79 | + |
90 | 80 | |
91 | 81 | |
92 | 82 | |
| ||
153 | 143 | |
154 | 144 | |
155 | 145 | |
156 | | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | | - |
169 | | - |
170 | | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | | - |
176 | | - |
177 | | - |
178 | | - |
179 | | - |
180 | | - |
Collapse file
google/cloud/spanner_v1/session.py
Copy file name to clipboardExpand all lines: google/cloud/spanner_v1/session.py+5Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
532 | 532 | |
533 | 533 | |
534 | 534 | |
| 535 | + |
| 536 | + |
| 537 | + |
| 538 | + |
535 | 539 | |
536 | 540 | |
537 | 541 | |
| 542 | + |
538 | 543 | |
539 | 544 | |
540 | 545 | |
|
Collapse file
google/cloud/spanner_v1/snapshot.py
Copy file name to clipboardExpand all lines: google/cloud/spanner_v1/snapshot.py+6-2Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
409 | 409 | |
410 | 410 | |
411 | 411 | |
412 | | - |
| 412 | + |
| 413 | + |
| 414 | + |
| 415 | + |
| 416 | + |
413 | 417 | |
414 | 418 | |
415 | 419 | |
| ||
601 | 605 | |
602 | 606 | |
603 | 607 | |
604 | | - |
| 608 | + |
605 | 609 | |
606 | 610 | |
607 | 611 | |
|
Collapse file
google/cloud/spanner_v1/transaction.py
Copy file name to clipboardExpand all lines: google/cloud/spanner_v1/transaction.py+6-2Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
479 | 479 | |
480 | 480 | |
481 | 481 | |
482 | | - |
| 482 | + |
| 483 | + |
| 484 | + |
| 485 | + |
483 | 486 | |
484 | 487 | |
485 | 488 | |
| ||
629 | 632 | |
630 | 633 | |
631 | 634 | |
632 | | - |
| 635 | + |
| 636 | + |
633 | 637 | |
634 | 638 | |
635 | 639 | |
|
Collapse file
tests/system/test_session_api.py
Copy file name to clipboardExpand all lines: tests/system/test_session_api.py+2Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
30 | 30 | |
31 | 31 | |
32 | 32 | |
| 33 | + |
33 | 34 | |
34 | 35 | |
35 | 36 | |
| ||
356 | 357 | |
357 | 358 | |
358 | 359 | |
| 360 | + |
359 | 361 | |
360 | 362 | |
361 | 363 | |
|
Collapse file
tests/unit/test__helpers.py
Copy file name to clipboardExpand all lines: tests/unit/test__helpers.py+47-1Lines changed: 47 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
16 | 16 | |
17 | 17 | |
18 | 18 | |
19 | | - |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
20 | 24 | |
21 | 25 | |
22 | 26 | |
| ||
89 | 93 | |
90 | 94 | |
91 | 95 | |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | + |
92 | 138 | |
93 | 139 | |
94 | 140 | |
|
0 commit comments