flagd
flagd copied to clipboard
feat: Add OTEL default variables
Signed-off-by: André Silva [email protected]
This PR
This pull request updates the OpenTelemetry integration in the core module to use the new autoexport package, simplifying configuration and improving compatibility with environment variables. It removes custom gRPC transport credential handling and centralizes exporter setup, making telemetry easier to configure and maintain. Several dependencies are updated to their latest versions, and tests are adjusted to reflect the new configuration logic.
OpenTelemetry Integration Refactor:
- Replaced manual OTLP exporter and gRPC credential setup with the new
autoexportpackage, removing custom TLS handling and simplifying trace and metric exporter initialization incore/pkg/telemetry/builder.go. Now, environment variables are used for configuration, and Prometheus is used as a fallback for metrics. [1] [2] [3] [4] - Updated test cases in
core/pkg/telemetry/builder_test.goto reflect the new autoexport logic, removing tests for unsupported configurations and ensuring the interceptor is always added. [1] [2]
Dependency Updates:
- Updated core dependencies in
core/go.mod, includingprometheus/client_golang,stretchr/testify,go.opentelemetry.io/otel, and related packages to their latest versions. Added new dependencies forautoexportand related exporters. - Updated various indirect dependencies to newer versions, such as
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp,github.com/cenkalti/backoff/v5,github.com/go-jose/go-jose/v4, and others. [1] [2] [3] [4] [5]
These changes make telemetry setup more robust and future-proof, reducing custom code and leveraging upstream improvements.
Related Issues
Fixes #1141
Notes
- In case the "old" variables are set, I override the "auto-export" variables. Then the library do its magic as suggested by @erka
Deploy Preview for polite-licorice-3db33c canceled.
| Name | Link |
|---|---|
| Latest commit | 0c23f00e04ac9f065dc2120cce57e2735b6416c9 |
| Latest deploy log | https://app.netlify.com/projects/polite-licorice-3db33c/deploys/691f48fc318b4f00084ef415 |
@askpt I would suggest using https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/autoexport and not re-implement the entire otel sdk.
@askpt I would suggest using https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/autoexport and not re-implement the entire otel sdk.
Thank you so much for the suggestion @erka! I was not aware of this library, and I will take a look. I am concerned that it may not be easily switched, as we need to maintain backwards compatibility with the previous settings.
You can likely configure the OTEL environment variables within the code - using the flagd configuration - prior to initializing autoexport to maintain backwards compatibility.
@askpt I've resolved the FOSSA issues.
@askpt I've resolved the FOSSA issues.
@beeme1mr Is there any library i shouldn't be using? I think they are all related to OTEL.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
/gemini review
It seems right to me, but I'm far from being an OTel expert, especially WRT to the autoexport stuff... maybe @beeme1mr can confrim.