Skip to content

Conversation

@FabianMeiswinkel
Copy link
Member

@FabianMeiswinkel FabianMeiswinkel commented Jul 7, 2025

Description

The original version of OpenTelemetry tracing was based off of a pre-V1 semantic convention spec. This PR ensures that by default the attributes for both the Pre-V1 spec as well as the V1 spec are emitted. Optionally via the environment variable COSMOS_OTEL_SPAN_ATTRIBUTE_NAMING_SCHEME or system property COSMOS.OTEL_SPAN_ATTRIBUTE_NAMING_SCHEME the behavior can also be changed to only emit the Pre-V1 or only the V1 attributes (for slightly better efficiency). Valid values are ALL, V1 and PRE_V1_RELEASE.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI review requested due to automatic review settings July 7, 2025 11:48
@FabianMeiswinkel FabianMeiswinkel requested review from a team and kirankumarkolli as code owners July 7, 2025 11:48
@github-actions github-actions bot added the Cosmos label Jul 7, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances OpenTelemetry tracing in the Azure Cosmos SDK by emitting both Pre-V1 and GA V1 semantic convention attributes by default and making this behavior configurable via an environment variable.

  • Introduce AttributeNamingScheme and integrate it into CosmosClientTelemetryConfig.
  • Refactor tracer creation to use LibraryTelemetryOptions.
  • Extend DiagnosticsProvider to conditionally emit span attributes according to the selected naming scheme.
  • Add configuration support in Configs for the new environment variable and update tests accordingly.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
CosmosClientTelemetryConfig.java Added attributeNamingSchemes, getOrCreateTracer refactor, and new getter/setter for naming scheme.
AttributeNamingScheme.java New enum to parse and represent Pre-V1 and V1 schemes.
AttributeNamesV1.java New enum listing GA V1 semantic convention attribute names.
AttributeNamesPreV1.java New enum listing Pre-V1 semantic convention attribute names.
AttributeNamesCommon.java New enum listing common attribute names.
ImplementationBridgeHelpers.java Extended accessor interface to include naming-scheme methods.
DiagnosticsProvider.java Updated span construction to emit attributes by naming scheme.
Configs.java Added environment variable support for OTEL_SPAN_ATTRIBUTE_NAMING_SCHEME.
CosmosTracerTest.java Updated tests to cover and validate the new naming-scheme behavior.
Comments suppressed due to low confidence (3)

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ImplementationBridgeHelpers.java:1643

  • The method name 'setOtelSpanAttributeNamingSchema' (and its getter) uses 'Schema' while the corresponding methods in CosmosClientTelemetryConfig use 'Scheme'. This mismatch will break the implementation bridge — rename to 'setOtelSpanAttributeNamingScheme' and 'getOtelSpanAttributeNamingScheme'.
            CosmosClientTelemetryConfig setOtelSpanAttributeNamingSchema(

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosClientTelemetryConfig.java:468

  • This setter is package-private, but it configures a public SDK behavior. Consider making it public to allow users to fluently configure the naming scheme on the client builder.
    CosmosClientTelemetryConfig setOtelSpanAttributeNamingScheme(String name) {

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosClientTelemetryConfig.java:474

  • [nitpick] Public-facing getters and setters for the new naming scheme should have JavaDoc explaining their purpose and valid values (e.g., 'All', 'Pre_V1_Release', 'V1').
    EnumSet<AttributeNamingScheme> getOtelSpanAttributeNamingScheme() {

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - tests

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - spark

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - kafka

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - tests

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - kafka

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - spark

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

2 similar comments
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - tests

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - kafka

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - spark

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

2 similar comments
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@FabianMeiswinkel FabianMeiswinkel enabled auto-merge (squash) July 8, 2025 21:19
Copy link
Member

@xinlian12 xinlian12 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - spark

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - kafka

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@FabianMeiswinkel
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

1 similar comment
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@FabianMeiswinkel FabianMeiswinkel merged commit 0dca69d into Azure:main Jul 9, 2025
94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants