Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

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 https://github.com/grafana/xk6-output-opentelemetry/issues/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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants