Allow service.name otel env variable #24
Merged
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.
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:
These custom variables effectively make it impossible to use the standard OTEL variables
OTEL_EXPORTER_OTLP_ENDPOINT
or the more specificOTEL_EXPORTER_OTLP_METRICS_ENDPOINT
. This is because: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:
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.