-
Notifications
You must be signed in to change notification settings - Fork 7
feat(csharp): implement telemetry tag definitions (phase 1) #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sreekanth-db
wants to merge
1
commit into
main
Choose a base branch
from
stack/telemetry-phase-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ go.work.sum | |
| .env | ||
|
|
||
| # Editor/IDE | ||
| # .idea/ | ||
| .idea/ | ||
| # .vscode/ | ||
|
|
||
| # Byte-compiled / optimized / DLL files | ||
|
|
||
85 changes: 85 additions & 0 deletions
85
csharp/src/Telemetry/TagDefinitions/ConnectionOpenEvent.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| using System.Collections.Generic; | ||
|
|
||
| namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions | ||
| { | ||
| /// <summary> | ||
| /// Tag definitions for Connection.Open events. | ||
| /// </summary> | ||
| internal static class ConnectionOpenEvent | ||
| { | ||
| public const string EventName = "Connection.Open"; | ||
|
|
||
| // Identity | ||
| [TelemetryTag("workspace.id", ExportScope = TagExportScope.ExportAll, Required = true, Description = "Workspace ID")] | ||
| public const string WorkspaceId = "workspace.id"; | ||
|
|
||
| [TelemetryTag("session.id", ExportScope = TagExportScope.ExportAll, Required = true, Description = "Session ID")] | ||
| public const string SessionId = "session.id"; | ||
|
|
||
| // Driver Configuration | ||
| [TelemetryTag("driver.version", ExportScope = TagExportScope.ExportAll, Description = "Driver version")] | ||
| public const string DriverVersion = "driver.version"; | ||
|
|
||
| [TelemetryTag("driver.os", ExportScope = TagExportScope.ExportAll, Description = "Operating system")] | ||
| public const string DriverOS = "driver.os"; | ||
|
|
||
| [TelemetryTag("driver.runtime", ExportScope = TagExportScope.ExportAll, Description = ".NET runtime")] | ||
| public const string DriverRuntime = "driver.runtime"; | ||
|
|
||
| // Feature Flags | ||
| [TelemetryTag("feature.cloudfetch", ExportScope = TagExportScope.ExportAll, Description = "CloudFetch enabled")] | ||
| public const string FeatureCloudFetch = "feature.cloudfetch"; | ||
|
|
||
| [TelemetryTag("feature.lz4", ExportScope = TagExportScope.ExportAll, Description = "LZ4 compression enabled")] | ||
| public const string FeatureLz4 = "feature.lz4"; | ||
|
|
||
| [TelemetryTag("feature.direct_results", ExportScope = TagExportScope.ExportAll, Description = "Direct results enabled")] | ||
| public const string FeatureDirectResults = "feature.direct_results"; | ||
|
|
||
| [TelemetryTag("feature.multiple_catalog", ExportScope = TagExportScope.ExportAll, Description = "Multiple catalog enabled")] | ||
| public const string FeatureMultipleCatalog = "feature.multiple_catalog"; | ||
|
|
||
| [TelemetryTag("feature.trace_propagation", ExportScope = TagExportScope.ExportAll, Description = "Trace propagation enabled")] | ||
| public const string FeatureTracePropagation = "feature.trace_propagation"; | ||
|
|
||
| [TelemetryTag("server.address", ExportScope = TagExportScope.ExportLocal, Description = "Server address")] | ||
| public const string ServerAddress = "server.address"; | ||
|
|
||
| /// <summary> | ||
| /// Returns tags allowed for Databricks export (privacy filter). | ||
| /// </summary> | ||
| public static IReadOnlyCollection<string> GetDatabricksExportTags() | ||
| { | ||
| return new HashSet<string> | ||
| { | ||
| WorkspaceId, | ||
| SessionId, | ||
| DriverVersion, | ||
| DriverOS, | ||
| DriverRuntime, | ||
| FeatureCloudFetch, | ||
| FeatureLz4, | ||
| FeatureDirectResults, | ||
| FeatureMultipleCatalog, | ||
| FeatureTracePropagation | ||
| }; | ||
| } | ||
| } | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| using System.Collections.Generic; | ||
|
|
||
| namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions | ||
| { | ||
| /// <summary> | ||
| /// Tag definitions for Error events. | ||
| /// </summary> | ||
| internal static class ErrorEvent | ||
| { | ||
| public const string EventName = "Error"; | ||
|
|
||
| // Error Classification | ||
| [TelemetryTag("error.type", ExportScope = TagExportScope.ExportAll, Required = true, Description = "Error type")] | ||
| public const string ErrorType = "error.type"; | ||
|
|
||
| [TelemetryTag("http.status_code", ExportScope = TagExportScope.ExportAll, Description = "HTTP status code")] | ||
| public const string HttpStatusCode = "http.status_code"; | ||
|
|
||
| [TelemetryTag("db.sql_state", ExportScope = TagExportScope.ExportAll, Description = "SQL state")] | ||
| public const string DbSqlState = "db.sql_state"; | ||
|
|
||
| [TelemetryTag("error.operation", ExportScope = TagExportScope.ExportAll, Description = "Failed operation")] | ||
| public const string ErrorOperation = "error.operation"; | ||
|
|
||
| [TelemetryTag("error.retried", ExportScope = TagExportScope.ExportAll, Description = "Was retried")] | ||
| public const string ErrorRetried = "error.retried"; | ||
|
|
||
| [TelemetryTag("error.retry_count", ExportScope = TagExportScope.ExportAll, Description = "Retry count")] | ||
| public const string ErrorRetryCount = "error.retry_count"; | ||
|
|
||
| [TelemetryTag("error.message", ExportScope = TagExportScope.ExportLocal, Description = "Error message")] | ||
| public const string ErrorMessage = "error.message"; | ||
|
|
||
| [TelemetryTag("error.stack_trace", ExportScope = TagExportScope.ExportLocal, Description = "Stack trace")] | ||
| public const string ErrorStackTrace = "error.stack_trace"; | ||
|
|
||
| /// <summary> | ||
| /// Returns tags allowed for Databricks export (privacy filter). | ||
| /// </summary> | ||
| public static IReadOnlyCollection<string> GetDatabricksExportTags() | ||
| { | ||
| return new HashSet<string> | ||
| { | ||
| ErrorType, | ||
| HttpStatusCode, | ||
| DbSqlState, | ||
| ErrorOperation, | ||
| ErrorRetried, | ||
| ErrorRetryCount | ||
| }; | ||
| } | ||
| } | ||
| } |
89 changes: 89 additions & 0 deletions
89
csharp/src/Telemetry/TagDefinitions/StatementExecutionEvent.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| using System.Collections.Generic; | ||
|
|
||
| namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions | ||
| { | ||
| /// <summary> | ||
| /// Tag definitions for Statement execution events. | ||
| /// </summary> | ||
| internal static class StatementExecutionEvent | ||
| { | ||
| public const string EventName = "Statement.Execute"; | ||
|
|
||
| // Identity | ||
| [TelemetryTag("statement.id", ExportScope = TagExportScope.ExportAll, Required = true, Description = "Statement ID")] | ||
| public const string StatementId = "statement.id"; | ||
|
|
||
| [TelemetryTag("session.id", ExportScope = TagExportScope.ExportAll, Required = true, Description = "Session ID")] | ||
| public const string SessionId = "session.id"; | ||
|
|
||
| // Result Metrics | ||
| [TelemetryTag("result.format", ExportScope = TagExportScope.ExportAll, Description = "Result format")] | ||
| public const string ResultFormat = "result.format"; | ||
|
|
||
| [TelemetryTag("result.chunk_count", ExportScope = TagExportScope.ExportAll, Description = "Chunk count")] | ||
| public const string ResultChunkCount = "result.chunk_count"; | ||
|
|
||
| [TelemetryTag("result.bytes_downloaded", ExportScope = TagExportScope.ExportAll, Description = "Bytes downloaded")] | ||
| public const string ResultBytesDownloaded = "result.bytes_downloaded"; | ||
|
|
||
| [TelemetryTag("result.compression_enabled", ExportScope = TagExportScope.ExportAll, Description = "Compression enabled")] | ||
| public const string ResultCompressionEnabled = "result.compression_enabled"; | ||
|
|
||
| [TelemetryTag("result.row_count", ExportScope = TagExportScope.ExportAll, Description = "Row count")] | ||
| public const string ResultRowCount = "result.row_count"; | ||
|
|
||
| // Polling Metrics | ||
| [TelemetryTag("poll.count", ExportScope = TagExportScope.ExportAll, Description = "Poll count")] | ||
| public const string PollCount = "poll.count"; | ||
|
|
||
| [TelemetryTag("poll.latency_ms", ExportScope = TagExportScope.ExportAll, Description = "Poll latency")] | ||
| public const string PollLatencyMs = "poll.latency_ms"; | ||
|
|
||
| // Operation Type | ||
| [TelemetryTag("db.operation", ExportScope = TagExportScope.ExportAll, Description = "Operation type")] | ||
| public const string DbOperation = "db.operation"; | ||
|
|
||
| [TelemetryTag("db.statement", ExportScope = TagExportScope.ExportLocal, Description = "SQL statement")] | ||
| public const string DbStatement = "db.statement"; | ||
|
|
||
| [TelemetryTag("db.catalog", ExportScope = TagExportScope.ExportLocal, Description = "Catalog name")] | ||
| public const string DbCatalog = "db.catalog"; | ||
|
|
||
| [TelemetryTag("db.schema", ExportScope = TagExportScope.ExportLocal, Description = "Schema name")] | ||
| public const string DbSchema = "db.schema"; | ||
|
|
||
| public static IReadOnlyCollection<string> GetDatabricksExportTags() | ||
| { | ||
| return new HashSet<string> | ||
| { | ||
| StatementId, | ||
| SessionId, | ||
| ResultFormat, | ||
| ResultChunkCount, | ||
| ResultBytesDownloaded, | ||
| ResultCompressionEnabled, | ||
| ResultRowCount, | ||
| PollCount, | ||
| PollLatencyMs, | ||
| DbOperation | ||
| }; | ||
| } | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions | ||
| { | ||
| /// <summary> | ||
| /// Defines the types of telemetry events that can be emitted by the driver. | ||
| /// Each event type has its own set of allowed tags defined in corresponding *Event classes. | ||
| /// </summary> | ||
| public enum TelemetryEventType | ||
| { | ||
| /// <summary> | ||
| /// Connection open event. Emitted when a connection is established. | ||
| /// Tags defined in: <see cref="ConnectionOpenEvent"/> | ||
| /// </summary> | ||
| ConnectionOpen, | ||
|
|
||
| /// <summary> | ||
| /// Statement execution event. Emitted when a query or statement is executed. | ||
| /// Tags defined in: <see cref="StatementExecutionEvent"/> | ||
| /// </summary> | ||
| StatementExecution, | ||
|
|
||
| /// <summary> | ||
| /// Error event. Emitted when an error occurs during any operation. | ||
| /// Tags defined in: <see cref="ErrorEvent"/> | ||
| /// </summary> | ||
| Error | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| using System; | ||
|
|
||
| namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions | ||
| { | ||
| /// <summary> | ||
| /// Controls where telemetry tags can be exported. | ||
| /// </summary> | ||
| [Flags] | ||
| internal enum TagExportScope | ||
| { | ||
| None = 0, | ||
| ExportLocal = 1, // Local diagnostics only | ||
| ExportDatabricks = 2, // Safe for Databricks service | ||
| ExportAll = ExportLocal | ExportDatabricks | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Attribute for defining telemetry tags with export controls. | ||
| /// </summary> | ||
| [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] | ||
| internal sealed class TelemetryTagAttribute : Attribute | ||
| { | ||
| public string TagName { get; } | ||
| public TagExportScope ExportScope { get; set; } | ||
| public string? Description { get; set; } | ||
| public bool Required { get; set; } | ||
|
|
||
| public TelemetryTagAttribute(string tagName) | ||
| { | ||
| TagName = tagName ?? throw new ArgumentNullException(nameof(tagName)); | ||
| ExportScope = TagExportScope.ExportLocal; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we log all the property for openConnection? Like query tag, etc?
Does other driver output those properties, any PII info?