Commit 2f70510
committed
fix(telemetry): address review findings — wiring, lifecycle, redaction, knobs
Iter-3 review fixes addressing 17 distinct findings from the multi-agent
review. Telemetry is now functionally correct and operationally safe.
Critical
- F1: TelemetryClient ctor wires getOrCreateContext on FeatureFlagCache.
isTelemetryEnabled was previously short-circuiting to false in production
because no caller registered the host — every customer silently emitted
zero events.
- F2: integration test asserts the documented default (true), not the prior
off-by-default. Test was contradicting production code.
- F3: IClientContext.getAuthProvider now optional; consumers use ?.() so
external implementers don't break on upgrade.
High / privacy
- F4: explicit DATABRICKS_TELEMETRY_DISABLED parser (1/true/yes/on, case
insensitive). Avoids the footgun where DATABRICKS_TELEMETRY_DISABLED=false
also disabled telemetry. Documented in CHANGELOG and TSDoc.
- F12: TelemetryClient.registerContext warns on telemetry-config and
userAgentEntry divergence so multi-tenant misconfig is visible.
- F9: connect()-on-reconnect releases prior refcount; close() clears the
emitter ref so post-close events can't smuggle into a closed aggregator.
- M-1: redactSensitive strips /home/<user>/, /Users/<user>/, and
C:\Users\<user>\ patterns from stack traces.
- M-3: FeatureFlagCache.getAuthHeaders falls through to the context's auth
provider — feature-flag GET is no longer unconditionally unauth.
Operational
- F7: MetricsAggregator.close races the final flush against a configurable
telemetryCloseTimeoutMs (default 2s) so a flapping endpoint can't hang
process.exit(0).
- F8: flushInFlight serializer prevents concurrent fire-and-forget flushes
from starving the user's HTTP socket pool. Drain pattern in close()
awaits any in-flight flush, then issues a fresh one to capture
close-time metrics that would otherwise be stranded.
- F16: maxStatementMetrics cap (default 5000) with oldest-first eviction.
Buffered errors emitted as standalone metrics first so the first-failure
signal survives.
- DBSQLSession.close() emits connection.close even when closeSession
fails so failed-close rates are visible in dashboards.
Maintainability
- F10/F17: single withErrorTelemetry helper covers fetchChunk, cancel,
close, finished, hasMoreRows, getSchema, getMetadata. safeEmit helper
consolidates seven copy-pasted "get emitter, emit, swallow at debug"
blocks across DBSQLOperation, DBSQLClient, DBSQLSession,
CloudFetchResultHandler, RowSetProvider. Also fixes the inconsistency
where DBSQLSession.close() lacked the swallow wrapper that the other
six sites had.
API surface
- F13: ConnectionOptions exposes nine telemetry knobs (was three) with
TSDoc. Adds telemetryFlushIntervalMs, telemetryMaxRetries,
telemetryCircuitBreakerThreshold, telemetryCircuitBreakerTimeout,
telemetryCloseTimeoutMs, telemetryMaxStatementMetrics.
Tests
- ClientContextStub gains telemetryEmitter / telemetryAggregator hooks so
unit tests can assert on emit calls instead of silently no-op'ing.
- 18 new unit tests covering F1 refcount, F12 divergence warn, async-close
idempotency, error-telemetry wrappers (cancel, close, getMetadata,
closed-op finished/getSchema/hasMoreRows), multi-context FIFO, and a
new tests/unit/result/RowSetProvider.test.ts file (RowSetProvider had
no test file at all). 783 unit tests pass; live e2e against
adb-27363120558779.19.azuredatabricks.net validates the full pipeline.
Co-authored-by: Isaac1 parent 410780a commit 2f70510
19 files changed
Lines changed: 745 additions & 167 deletions
File tree
- lib
- contracts
- result
- telemetry
- tests
- e2e/telemetry
- unit
- .stubs
- result
- telemetry
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
9 | 16 | | |
10 | 17 | | |
11 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
429 | 430 | | |
430 | 431 | | |
431 | 432 | | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
432 | 446 | | |
433 | 447 | | |
434 | 448 | | |
| |||
440 | 454 | | |
441 | 455 | | |
442 | 456 | | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
451 | 473 | | |
452 | 474 | | |
453 | 475 | | |
| |||
489 | 511 | | |
490 | 512 | | |
491 | 513 | | |
492 | | - | |
493 | | - | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
494 | 523 | | |
495 | 524 | | |
496 | 525 | | |
| |||
534 | 563 | | |
535 | 564 | | |
536 | 565 | | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
553 | 578 | | |
554 | 579 | | |
555 | 580 | | |
| |||
578 | 603 | | |
579 | 604 | | |
580 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
581 | 609 | | |
582 | 610 | | |
583 | 611 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 185 | + | |
190 | 186 | | |
191 | 187 | | |
192 | 188 | | |
| |||
266 | 262 | | |
267 | 263 | | |
268 | 264 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
| 265 | + | |
275 | 266 | | |
276 | 267 | | |
277 | 268 | | |
| |||
299 | 290 | | |
300 | 291 | | |
301 | 292 | | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
| 293 | + | |
308 | 294 | | |
309 | 295 | | |
310 | 296 | | |
| |||
332 | 318 | | |
333 | 319 | | |
334 | 320 | | |
335 | | - | |
336 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
337 | 325 | | |
338 | 326 | | |
339 | 327 | | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
344 | 333 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
350 | 339 | | |
351 | | - | |
352 | | - | |
353 | | - | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
354 | 344 | | |
355 | 345 | | |
356 | 346 | | |
357 | | - | |
| 347 | + | |
| 348 | + | |
358 | 349 | | |
359 | | - | |
360 | | - | |
361 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
362 | 353 | | |
363 | | - | |
| 354 | + | |
364 | 355 | | |
365 | | - | |
366 | | - | |
367 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
368 | 360 | | |
369 | 361 | | |
370 | 362 | | |
371 | | - | |
| 363 | + | |
372 | 364 | | |
373 | 365 | | |
374 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
375 | 378 | | |
376 | 379 | | |
377 | 380 | | |
| |||
540 | 543 | | |
541 | 544 | | |
542 | 545 | | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
| 546 | + | |
| 547 | + | |
550 | 548 | | |
551 | 549 | | |
552 | 550 | | |
553 | 551 | | |
554 | | - | |
555 | | - | |
556 | | - | |
| 552 | + | |
557 | 553 | | |
558 | 554 | | |
559 | 555 | | |
560 | 556 | | |
561 | 557 | | |
562 | 558 | | |
563 | 559 | | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
570 | 563 | | |
571 | 564 | | |
572 | 565 | | |
| |||
575 | 568 | | |
576 | 569 | | |
577 | 570 | | |
578 | | - | |
579 | 571 | | |
580 | 572 | | |
581 | | - | |
| 573 | + | |
582 | 574 | | |
583 | 575 | | |
584 | 576 | | |
585 | 577 | | |
586 | 578 | | |
587 | 579 | | |
588 | 580 | | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
| 581 | + | |
| 582 | + | |
594 | 583 | | |
595 | 584 | | |
596 | 585 | | |
| |||
601 | 590 | | |
602 | 591 | | |
603 | 592 | | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
| 593 | + | |
| 594 | + | |
609 | 595 | | |
610 | 596 | | |
611 | 597 | | |
612 | 598 | | |
613 | 599 | | |
614 | 600 | | |
615 | 601 | | |
616 | | - | |
617 | | - | |
618 | | - | |
| 602 | + | |
619 | 603 | | |
620 | 604 | | |
0 commit comments