Commit 124a9c7
committed
feat(spanner): support user-provided OpenTelemetry for built-in client metrics and endpoint attribute for location-aware routing
Adds a MetricsProvider family on SpannerOptions that controls how the
built-in client metrics are collected and exported: DefaultMetricsProvider
(collect and export to Cloud Monitoring, today's behavior and still the
default), NoopMetricsProvider (built-in metrics off), and
CustomOpenTelemetryMetricsProvider (record the built-in metrics on a
caller-provided OpenTelemetry instance instead of exporting them to Cloud
Monitoring, leaving the metrics pipeline - readers, exporters, resource -
fully owned by the caller). A custom provider records under the distinct
spanner/internal/client instrument namespace so a customer pipeline
re-exported to Cloud Monitoring cannot conflict with the reserved
spanner.googleapis.com descriptors. The new static
SpannerOptions.registerBuiltInMetricViews(SdkMeterProviderBuilder) registers
the renaming/bucketing/attribute-filtering views for the custom namespace.
Default behavior is unchanged: the default provider keeps today's Cloud
Monitoring export, the process-wide exporter singleton is never touched by
custom-sink clients, and OMNI still has built-in metrics off by default
(the default provider is coerced to noop) while an explicitly configured
CustomOpenTelemetryMetricsProvider is honored, which is the opt-in for
Spanner Omni where Cloud Monitoring export is unavailable. The
SPANNER_DISABLE_BUILTIN_METRICS environment variable disables the custom
sink as well.
Also records an endpoint attribute on attempt metrics for location-aware
routing: KeyAwareClientCall injects the resolved endpoint into the operation
tracer through the existing CallOptions tracer bridge. The attribute is only
allowed through the attribute filter of the custom-export views; the Cloud
Monitoring views drop it, so the exported Cloud Monitoring schema is
unchanged. Clients that do not enable the location API never produce the
attribute.1 parent 2f36a71 commit 124a9c7
15 files changed
Lines changed: 1403 additions & 49 deletions
File tree
- java-spanner
- google-cloud-spanner/src
- main/java/com/google/cloud/spanner
- spi/v1
- test/java/com/google/cloud/spanner
- spi/v1
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
72 | 111 | | |
73 | 112 | | |
74 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
170 | 209 | | |
171 | 210 | | |
172 | 211 | | |
| |||
Lines changed: 83 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
43 | 53 | | |
44 | 54 | | |
45 | 55 | | |
| |||
168 | 178 | | |
169 | 179 | | |
170 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
171 | 189 | | |
172 | 190 | | |
173 | 191 | | |
| |||
208 | 226 | | |
209 | 227 | | |
210 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
211 | 252 | | |
212 | 253 | | |
| 254 | + | |
213 | 255 | | |
214 | 256 | | |
215 | 257 | | |
216 | 258 | | |
217 | 259 | | |
218 | | - | |
| 260 | + | |
| 261 | + | |
219 | 262 | | |
220 | 263 | | |
| 264 | + | |
221 | 265 | | |
222 | 266 | | |
223 | 267 | | |
224 | 268 | | |
225 | 269 | | |
226 | | - | |
| 270 | + | |
| 271 | + | |
227 | 272 | | |
228 | 273 | | |
| 274 | + | |
229 | 275 | | |
230 | 276 | | |
231 | 277 | | |
232 | 278 | | |
233 | 279 | | |
234 | | - | |
| 280 | + | |
| 281 | + | |
235 | 282 | | |
236 | 283 | | |
| 284 | + | |
237 | 285 | | |
238 | 286 | | |
239 | 287 | | |
240 | 288 | | |
241 | 289 | | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
247 | 305 | | |
248 | 306 | | |
249 | 307 | | |
250 | 308 | | |
| 309 | + | |
251 | 310 | | |
252 | 311 | | |
253 | 312 | | |
254 | 313 | | |
255 | 314 | | |
256 | | - | |
| 315 | + | |
| 316 | + | |
257 | 317 | | |
258 | 318 | | |
259 | | - | |
| 319 | + | |
260 | 320 | | |
261 | 321 | | |
262 | 322 | | |
263 | 323 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | 324 | | |
269 | 325 | | |
270 | | - | |
| 326 | + | |
271 | 327 | | |
272 | | - | |
| 328 | + | |
273 | 329 | | |
274 | 330 | | |
275 | 331 | | |
276 | 332 | | |
277 | | - | |
| 333 | + | |
| 334 | + | |
278 | 335 | | |
279 | 336 | | |
280 | 337 | | |
281 | 338 | | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
| 339 | + | |
| 340 | + | |
287 | 341 | | |
288 | 342 | | |
289 | 343 | | |
290 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
291 | 348 | | |
292 | 349 | | |
293 | 350 | | |
294 | 351 | | |
295 | 352 | | |
296 | 353 | | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
| 354 | + | |
301 | 355 | | |
302 | 356 | | |
303 | 357 | | |
304 | 358 | | |
305 | 359 | | |
306 | | - | |
| 360 | + | |
307 | 361 | | |
308 | 362 | | |
309 | 363 | | |
| |||
318 | 372 | | |
319 | 373 | | |
320 | 374 | | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
| 375 | + | |
326 | 376 | | |
327 | 377 | | |
328 | 378 | | |
| |||
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
191 | 204 | | |
192 | 205 | | |
193 | | - | |
194 | | - | |
195 | | - | |
| 206 | + | |
196 | 207 | | |
197 | 208 | | |
198 | 209 | | |
| |||
0 commit comments