flagd icon indicating copy to clipboard operation
flagd copied to clipboard

feat: Add OTEL default variables

Open askpt opened this issue 1 month ago • 4 comments

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 autoexport package, removing custom TLS handling and simplifying trace and metric exporter initialization in core/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.go to 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, including prometheus/client_golang, stretchr/testify, go.opentelemetry.io/otel, and related packages to their latest versions. Added new dependencies for autoexport and 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

askpt avatar Oct 13 '25 20:10 askpt

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

netlify[bot] avatar Oct 13 '25 20:10 netlify[bot]

@askpt I would suggest using https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/autoexport and not re-implement the entire otel sdk.

erka avatar Oct 14 '25 11:10 erka

@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.

askpt avatar Oct 14 '25 12:10 askpt

You can likely configure the OTEL environment variables within the code - using the flagd configuration - prior to initializing autoexport to maintain backwards compatibility.

erka avatar Oct 14 '25 13:10 erka

@askpt I've resolved the FOSSA issues.

beeme1mr avatar Nov 18 '25 15:11 beeme1mr

@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.

askpt avatar Nov 18 '25 15:11 askpt

/gemini review

toddbaert avatar Nov 21 '25 18:11 toddbaert

It seems right to me, but I'm far from being an OTel expert, especially WRT to the autoexport stuff... maybe @beeme1mr can confrim.

toddbaert avatar Nov 21 '25 18:11 toddbaert