Skip to content
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

Allow service.name otel env variable #24

Merged
merged 1 commit into from
Oct 16, 2024
Merged

Conversation

TimotejKovacka
Copy link
Contributor

@TimotejKovacka TimotejKovacka commented Sep 29, 2024

Custom Environment Variables and OTEL SDK Configuration

The current implementation of xk6-output-opentelemetry defines several custom environment variables that, while providing fine-grained control, inadvertently prevent the use of standard OTEL SDK configuration variables. This is due to how the extension initializes the SDK with its own configuration, which takes precedence over the standard OTEL environment variables.

Example: HTTP Exporter Configuration

Consider the following custom environment variables defined in the extension:

HTTPExporterEndpoint null.String `json:"httpExporterEndpoint" envconfig:"K6_OTEL_HTTP_EXPORTER_ENDPOINT"`
HTTPExporterURLPath null.String `json:"httpExporterURLPath" envconfig:"K6_OTEL_HTTP_EXPORTER_URL_PATH"`

These custom variables effectively make it impossible to use the standard OTEL variables OTEL_EXPORTER_OTLP_ENDPOINT or the more specific OTEL_EXPORTER_OTLP_METRICS_ENDPOINT. This is because:

  1. The extension always provides these values to the SDK during initialization.
  2. These provided values overwrite any configuration that might have been set using the standard OTEL environment variables.

Broader Implications

This issue is not limited to the HTTP exporter configuration. Multiple custom environment variables defined at the xk6-output-opentelemetry level create similar conflicts with their standard OTEL counterparts. As a result, users cannot rely on standard OTEL configuration methods when using this extension.

Rationale and Future Considerations

The current approach was likely adopted to provide k6-specific configurability. However, it creates a divergence from standard OTEL practices, potentially confusing users familiar with OTEL SDK configuration.

Moving forward, we should consider:

  1. Gradually aligning our custom variables with standard OTEL naming conventions.
  2. Implementing a fallback mechanism where standard OTEL variables are checked if custom ones are not set.
  3. Providing clear documentation on which standard OTEL variables are supported and which are superseded by custom configurations.

The current PR, by adding support for OTEL_SERVICE_NAME, is a small step towards better alignment with standard OTEL practices. However, a more comprehensive review and refactor of the environment variable handling may be necessary in the future to fully address this issue.

@CLAassistant
Copy link

CLAassistant commented Sep 29, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@olegbespalov olegbespalov left a comment

Choose a reason for hiding this comment

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

Hi @TimotejKovacka

It all sounds reasonable and I've opened a separate issue for tracking it #25

The change in this PR looks good to me, thanks for the contribution!

@oleiade oleiade merged commit 133ea7f into grafana:main Oct 16, 2024
10 checks passed
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