feat(csharp): implement telemetry client pipeline with circuit breaker protection#305
Merged
jadewang-db merged 12 commits intomainfrom Mar 10, 2026
Merged
Conversation
This was referenced Mar 5, 2026
Draft
861c265 to
8165d60
Compare
8165d60 to
49ec024
Compare
49ec024 to
ecccfc6
Compare
ecccfc6 to
c16a7f2
Compare
c16a7f2 to
7ee3e3f
Compare
jadewang-db
commented
Mar 6, 2026
jadewang-db
commented
Mar 6, 2026
jadewang-db
commented
Mar 6, 2026
jadewang-db
commented
Mar 6, 2026
jadewang-db
commented
Mar 6, 2026
jadewang-db
commented
Mar 6, 2026
jadewang-db
commented
Mar 6, 2026
jadewang-db
commented
Mar 6, 2026
jadewang-db
commented
Mar 6, 2026
Collaborator
Author
Code Review Summary — PR #305Reviewed the incremental changes (10 files, +2435/-16 lines) implementing the telemetry client pipeline: Critical Issues (2)
High Issues (1)
Medium Issues (4)
Low Issues (2)
Positive Observations
Recommendations (prioritized)
This comment was generated with GitHub MCP. |
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 9, 2026
…ontext, TelemetrySessionContext) (#301) ## 🥞 Stacked PR Use this [link](https://github.com/adbc-drivers/databricks/pull/301/files) to review incremental changes. - [**stack/itr5-pr-telemetry-models**](#301) [[Files changed](https://github.com/adbc-drivers/databricks/pull/301/files)] - [stack/itr5-pr-telemetry-client-impl](#305) [[Files changed](https://github.com/adbc-drivers/databricks/pull/305/files/cfac5affae5a0c405d91a9246189ec7b43908ab0..88f5b5587bea7bd5cfb7e9e3877061f015e85359)] - [stack/itr5-pr-e2e-tests](#308) [[Files changed](https://github.com/adbc-drivers/databricks/pull/308/files/88f5b5587bea7bd5cfb7e9e3877061f015e85359..f33b25cd7eaae3925ddb7ea77daf9bc1ba813ad7)] --------- ## What's Changed Please fill in a description of the changes here. **This contains breaking changes.** <!-- Remove this line if there are no breaking changes. --> Closes #NNN. --------- Co-authored-by: Jade Wang <jade.wang+data@databricks.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
88f5b55 to
7390faf
Compare
…task-2.2-telemetry-client-manager
- Fix final flush no-op by using _closing flag before _disposed - Drain all batches in FlushAsync instead of just one - Fix race condition in TelemetryClientManager with lock-based synchronization - Replace Debug.WriteLine with Activity.Current?.AddEvent() for tracing - Change TelemetrySessionContext setters to internal - Use Interlocked counter for queue size instead of ConcurrentQueue.Count - Use blocking wait in FlushAsync during close - Use test-isolated TelemetryClientManager instances with proper cleanup Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…2-circuit-breaker-telemetry-exporter
… task-4.1-metrics-aggregator
…activity-listener
…metryMetric These are no longer used. TelemetryClient now uses a direct enqueue → flush → export pipeline without the Activity-based aggregation layer. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…\nTask ID: task-5.1-telemetry-client-implementation
Remove ActivityListener and MetricsAggregator dependencies. TelemetryClient now directly enqueues TelemetryFrontendLog objects and flushes them via the circuit breaker-protected exporter. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7390faf to
d4f1460
Compare
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 10, 2026
…r protection (#305) ## 🥞 Stacked PR Use this [link](https://github.com/adbc-drivers/databricks/pull/305/files) to review incremental changes. - [**stack/itr5-pr-telemetry-client-impl**](#305) [[Files changed](https://github.com/adbc-drivers/databricks/pull/305/files)] - [stack/itr5-pr-e2e-tests](#308) [[Files changed](https://github.com/adbc-drivers/databricks/pull/308/files/d4f1460a559b0d1b18cf3f6869330f7a5c05fd19..488eb22c870625c990252f99d507e27987c9d12c)] --------- ## Summary Implements the telemetry client pipeline for the C# ADBC Databricks driver. This includes the full lifecycle from event ingestion through circuit-breaker-protected export to the Databricks telemetry endpoint. ### Key components - **`TelemetryClient`** — Main client coordinating enqueue → flush → export. Uses `SemaphoreSlim` to gate concurrent flushes, `Interlocked` counter for O(1) batch-size checks, and a periodic `Timer` driven by `FlushIntervalMs`. Graceful shutdown flushes all pending events before disposing. - **`TelemetryClientManager`** — Singleton factory managing one client per host with atomic reference counting (`AddRef`/`Release` via `Interlocked`). Prevents rate-limiting by sharing clients across concurrent connections to the same host. - **`TelemetryClientHolder`** — Holds client + thread-safe ref count using `Interlocked.Increment`/`Decrement`. - **`CircuitBreakerTelemetryExporter`** — Wraps the inner exporter with per-host circuit breaker protection (via Polly). Silently drops events when the circuit is open. Never throws — all exceptions including `OperationCanceledException` are swallowed per the telemetry contract. - **`CircuitBreakerManager`** — Singleton managing per-host circuit breakers with cleanup on last client release. - **`ITelemetryClient`** — Interface defining `Enqueue`, `FlushAsync`, `CloseAsync`, and `IAsyncDisposable`. - **`TelemetrySessionContext` / `StatementTelemetryContext`** — Immutable context objects carrying session-level and statement-level telemetry data. ### Design decisions - **Thread safety**: `CloseAsync` uses `Interlocked.Exchange` for atomic dispose check; `TelemetryClientHolder` uses `Interlocked` for ref counting; flush is gated by `SemaphoreSlim(1,1)`. - **No data loss on close**: `CloseAsync` performs a final `FlushAsync` before cancelling the token and disposing resources. - **Telemetry never impacts driver**: All exceptions are swallowed; disabled telemetry skips the entire path via `_enabled` check in `Enqueue`. - **Memory leak prevention**: `CircuitBreakerManager.RemoveCircuitBreaker` is called when the last client for a host is released. ## Test plan - [x] Unit tests for `TelemetryClient` (enqueue, flush, close, dispose, error handling) - [x] Unit tests for `TelemetryClientManager` (singleton, ref counting, thread safety, multi-host) - [x] Unit tests for `CircuitBreakerTelemetryExporter` (circuit states, cancellation swallowed, error tracking) - [x] Unit tests for `TelemetrySessionContext` and `StatementTelemetryContext` - [x] All 245 telemetry tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Jade Wang <jade.wang+data@databricks.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🚀 Integration tests triggered! View workflow run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🥞 Stacked PR
Use this link to review incremental changes.
Summary
Implements the telemetry client pipeline for the C# ADBC Databricks driver. This includes the full lifecycle from event ingestion through circuit-breaker-protected export to the Databricks telemetry endpoint.
Key components
TelemetryClient— Main client coordinating enqueue → flush → export. UsesSemaphoreSlimto gate concurrent flushes,Interlockedcounter for O(1) batch-size checks, and a periodicTimerdriven byFlushIntervalMs. Graceful shutdown flushes all pending events before disposing.TelemetryClientManager— Singleton factory managing one client per host with atomic reference counting (AddRef/ReleaseviaInterlocked). Prevents rate-limiting by sharing clients across concurrent connections to the same host.TelemetryClientHolder— Holds client + thread-safe ref count usingInterlocked.Increment/Decrement.CircuitBreakerTelemetryExporter— Wraps the inner exporter with per-host circuit breaker protection (via Polly). Silently drops events when the circuit is open. Never throws — all exceptions includingOperationCanceledExceptionare swallowed per the telemetry contract.CircuitBreakerManager— Singleton managing per-host circuit breakers with cleanup on last client release.ITelemetryClient— Interface definingEnqueue,FlushAsync,CloseAsync, andIAsyncDisposable.TelemetrySessionContext/StatementTelemetryContext— Immutable context objects carrying session-level and statement-level telemetry data.Design decisions
CloseAsyncusesInterlocked.Exchangefor atomic dispose check;TelemetryClientHolderusesInterlockedfor ref counting; flush is gated bySemaphoreSlim(1,1).CloseAsyncperforms a finalFlushAsyncbefore cancelling the token and disposing resources._enabledcheck inEnqueue.CircuitBreakerManager.RemoveCircuitBreakeris called when the last client for a host is released.Test plan
TelemetryClient(enqueue, flush, close, dispose, error handling)TelemetryClientManager(singleton, ref counting, thread safety, multi-host)CircuitBreakerTelemetryExporter(circuit states, cancellation swallowed, error tracking)TelemetrySessionContextandStatementTelemetryContext🤖 Generated with Claude Code