Skip to content

Conversation

@sreekanth-db
Copy link
Contributor

@sreekanth-db sreekanth-db commented Nov 3, 2025

This PR implements phase 2 (telemetry-activity-based-design.md) of the Activity-based telemetry system for the Databricks ADBC C# driver. It builds upon Phase 1 by adding the foundational infrastructure for collecting and exporting telemetry metrics.

Changes

New Files Added

1. TelemetryConfiguration.cs

Configuration settings for Databricks telemetry collection and export.

Key properties:

  • Enabled: Enable/disable telemetry
  • BatchSize: Number of metrics to batch before sending
  • FlushIntervalMs: Interval for periodic flush
  • MaxRetries, RetryDelayMs: Retry configuration
  • CircuitBreakerEnabled, CircuitBreakerThreshold, CircuitBreakerTimeout: Circuit breaker settings

2. TelemetryMetric.cs

Data model representing a single telemetry event derived from Activity data.

Properties:

  • EventType: Type of telemetry event (ConnectionOpen, StatementExecution, Error)
  • Timestamp: When the event occurred
  • Tags: Flexible dictionary for event-specific metadata

3. IDatabricksTelemetryExporter.cs

Interface for exporting telemetry metrics to external services.

Contract:

  • Single async method: ExportAsync(IReadOnlyList<TelemetryMetric> metrics, CancellationToken cancellationToken)
  • Critical requirement: Implementations must never throw exceptions

4. DatabricksTelemetryExporter.cs

HTTP-based exporter implementation that sends metrics to Databricks telemetry service.

Features:

  • Sends metrics to /telemetry-ext endpoint
  • Uses UriBuilder for proper URL construction
  • Non-blocking error handling (never throws exceptions)

Design Decisions

  • Simplified first version: Focuses on core functionality without retry logic, circuit breaker implementation or unauthenticated telemetry support (can be enhanced later)

What's Left in Phase 2

Two components remain for separate review (because of their complex implementation, will raise a separate PR for better review process):

  • MetricsAggregator: Batching logic, event type aggregation
  • DatabricksActivityListener: Activity event subscription, conversion to TelemetryMetric

_hostUrl = !string.IsNullOrEmpty(hostUrl) ? hostUrl : throw new ArgumentException("Host URL cannot be null or empty.", nameof(hostUrl));
}

public async Task ExportAsync(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this plug into existing Telemetry exporter framework? Does defining this single method work out of the box?
Take a look at FileExporter for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The single-method interface is sufficient because batching and aggregation happen in MetricsAggregator before reaching the exporter.

FileExporter (OpenTelemetry-based):
Activity → OpenTelemetry SDK → BaseExporter → Local File

DatabricksTelemetryExporter (Custom aggregation):
Activity → DatabricksActivityListener → MetricsAggregator → IDatabricksTelemetryExporter → Databricks Service

Signed-off-by: Sreekanth Vadigi <[email protected]>
@CurtHagenlocher
Copy link
Contributor

CurtHagenlocher commented Nov 6, 2025

It looks like this overlaps substantially with "phase 1" (#3653) so my comments on this PR will be limited to the four files that are new to it. EDIT: or is that two files? I'm seeing two different things in two different tools :(.

Copy link
Contributor

@CurtHagenlocher CurtHagenlocher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have more questions than requests for specific changes. Presumably phase 1 needs to be checked in before this?

/// Interface for exporting telemetry metrics to Databricks telemetry service.
/// Implementations must never throw exceptions.
/// </summary>
public interface IDatabricksTelemetryExporter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public interface IDatabricksTelemetryExporter
internal interface IDatabricksTelemetryExporter

}
catch (Exception ex)
{
Debug.WriteLine($"Telemetry export failed: {ex.Message}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this eventually hook into tracing instead?

{
await SendMetricsAsync(metrics, cancellationToken);
}
catch (Exception ex)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a retry mechanism for these?

string fullUrl = new UriBuilder(_hostUrl) { Path = TelemetryEndpoint }.ToString();
string json = SerializeMetrics(metrics);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var request = new HttpRequestMessage(HttpMethod.Post, fullUrl) { Content = content };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unauthenticated endpoint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants