Commit 27ed8de
authored
feat(bqjdbc): Complete OpenTelemetry instrumentation and context propagation (#13187)
b/496720140
## Changes
### Context Propagation & Session Tracking
* **Baggage Injection**: Injected the generated Connection UUID into
OpenTelemetry Baggage upon `BigQueryConnection` initialization to enable
reliable log correlation.
* **Log Handler Update**: Updated `OpenTelemetryJulHandler` to rely on
Baggage for retrieving the connection ID, removing the legacy MDC
fallback.
* **Thread Pool Audit**: Wrapped tasks submitted to background executors
in `BigQueryDatabaseMetaData` with `Context.current().wrap()`, ensuring
trace context is not lost during parallel metadata fetching.
### Span Enrichment & Semantic Conventions
* **Attributes**: Enriched JDBC spans with standard attributes:
`db.system = "bigquery"`, `db.connection_id`, and `db.application`
(derived from `partnerToken` or falling back to
`"Google-BigQuery-JDBC-Driver"`).
* **Scope Separation**: Implemented separate tracers for the JDBC driver
(`com.google.cloud.bigquery.jdbc`) and the SDK
(`com.google.cloud.bigquery`) to allow clean filtering in tracing UIs
while maintaining correlation.
### Instrumentation
* **PreparedStatement**: Added missing instrumentation for
`BigQueryPreparedStatement` execution methods (`execute`,
`executeQuery`, `executeLargeUpdate`) to generate spans.
### Refactoring & Cleanups
* **Centralized Tracing**: Created a centralized `withTracing` helper in
`BigQueryJdbcOpenTelemetry.java` to eliminate duplicated tracing logic
in `BigQueryStatement` and `BigQueryDatabaseMetaData`.
* **Constants**: Defined all semantic convention keys as constants in
`BigQueryJdbcOpenTelemetry.java` to eliminate magic strings from method
bodies.
* **Simplifications**: Simplified redundant boolean checks in
`BigQueryConnection.java`.1 parent e5996c4 commit 27ed8de
8 files changed
Lines changed: 249 additions & 73 deletions
File tree
- java-bigquery/google-cloud-bigquery-jdbc/src
- main/java/com/google/cloud/bigquery/jdbc
- test/java/com/google/cloud/bigquery/jdbc
Lines changed: 22 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
| 154 | + | |
152 | 155 | | |
153 | 156 | | |
154 | 157 | | |
| |||
161 | 164 | | |
162 | 165 | | |
163 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
164 | 172 | | |
165 | 173 | | |
166 | 174 | | |
| |||
1059 | 1067 | | |
1060 | 1068 | | |
1061 | 1069 | | |
1062 | | - | |
1063 | | - | |
1064 | | - | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
1065 | 1075 | | |
1066 | 1076 | | |
1067 | 1077 | | |
| |||
1112 | 1122 | | |
1113 | 1123 | | |
1114 | 1124 | | |
1115 | | - | |
| 1125 | + | |
1116 | 1126 | | |
1117 | 1127 | | |
1118 | 1128 | | |
| |||
1221 | 1231 | | |
1222 | 1232 | | |
1223 | 1233 | | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
1224 | 1242 | | |
1225 | 1243 | | |
1226 | 1244 | | |
| |||
Lines changed: 24 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | 48 | | |
51 | 49 | | |
52 | 50 | | |
| |||
864 | 862 | | |
865 | 863 | | |
866 | 864 | | |
867 | | - | |
| 865 | + | |
| 866 | + | |
868 | 867 | | |
869 | 868 | | |
870 | 869 | | |
| |||
888 | 887 | | |
889 | 888 | | |
890 | 889 | | |
891 | | - | |
892 | | - | |
893 | | - | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
894 | 897 | | |
895 | 898 | | |
896 | 899 | | |
| |||
1280 | 1283 | | |
1281 | 1284 | | |
1282 | 1285 | | |
1283 | | - | |
| 1286 | + | |
1284 | 1287 | | |
1285 | 1288 | | |
1286 | 1289 | | |
| |||
1357 | 1360 | | |
1358 | 1361 | | |
1359 | 1362 | | |
1360 | | - | |
| 1363 | + | |
1361 | 1364 | | |
1362 | 1365 | | |
1363 | 1366 | | |
| |||
1407 | 1410 | | |
1408 | 1411 | | |
1409 | 1412 | | |
1410 | | - | |
1411 | | - | |
1412 | | - | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
1413 | 1421 | | |
1414 | 1422 | | |
1415 | 1423 | | |
| |||
4080 | 4088 | | |
4081 | 4089 | | |
4082 | 4090 | | |
4083 | | - | |
| 4091 | + | |
| 4092 | + | |
4084 | 4093 | | |
4085 | 4094 | | |
4086 | 4095 | | |
| |||
4515 | 4524 | | |
4516 | 4525 | | |
4517 | 4526 | | |
4518 | | - | |
| 4527 | + | |
4519 | 4528 | | |
4520 | 4529 | | |
4521 | 4530 | | |
| |||
5443 | 5452 | | |
5444 | 5453 | | |
5445 | 5454 | | |
5446 | | - | |
5447 | | - | |
5448 | | - | |
5449 | | - | |
5450 | | - | |
5451 | | - | |
5452 | | - | |
5453 | | - | |
5454 | | - | |
5455 | | - | |
5456 | | - | |
| 5455 | + | |
| 5456 | + | |
5457 | 5457 | | |
5458 | 5458 | | |
Lines changed: 66 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| 35 | + | |
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
32 | 39 | | |
| 40 | + | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
| |||
39 | 47 | | |
40 | 48 | | |
41 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
42 | 58 | | |
43 | 59 | | |
44 | 60 | | |
| |||
287 | 303 | | |
288 | 304 | | |
289 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
290 | 356 | | |
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
94 | 103 | | |
95 | 104 | | |
96 | 105 | | |
| |||
106 | 115 | | |
107 | 116 | | |
108 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
109 | 127 | | |
110 | 128 | | |
111 | 129 | | |
| |||
127 | 145 | | |
128 | 146 | | |
129 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
130 | 157 | | |
131 | 158 | | |
132 | 159 | | |
| |||
0 commit comments