Skip to content

feat: Add OTEL default variables#1812

Merged
beeme1mr merged 11 commits into
open-feature:mainfrom
askpt:askpt/1141-add-otel-variables
Dec 8, 2025
Merged

feat: Add OTEL default variables#1812
beeme1mr merged 11 commits into
open-feature:mainfrom
askpt:askpt/1141-add-otel-variables

Conversation

@askpt

@askpt askpt commented Oct 13, 2025

Copy link
Copy Markdown
Member

Signed-off-by: André Silva 2493377+askpt@users.noreply.github.com

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

@netlify

netlify Bot commented Oct 13, 2025

Copy link
Copy Markdown

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit 87a4a69
🔍 Latest deploy log https://app.netlify.com/projects/polite-licorice-3db33c/deploys/6932f5cdf8cbe80008140251

@erka

erka commented Oct 14, 2025

Copy link
Copy Markdown
Member

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

@askpt

askpt commented Oct 14, 2025

Copy link
Copy Markdown
Member Author

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

@erka

erka commented Oct 14, 2025

Copy link
Copy Markdown
Member

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

askpt added 7 commits October 23, 2025 14:38
…erride

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…ation

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…sistency

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…uration.

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
@askpt askpt marked this pull request as ready for review October 31, 2025 16:16
@askpt askpt requested review from a team as code owners October 31, 2025 16:16
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 31, 2025
@beeme1mr

Copy link
Copy Markdown
Member

@askpt I've resolved the FOSSA issues.

@askpt

askpt commented Nov 18, 2025

Copy link
Copy Markdown
Member Author

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

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
@toddbaert

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request is a significant improvement, refactoring the OpenTelemetry integration to use the autoexport package. This change greatly simplifies the codebase by removing custom logic for OTLP exporter setup and transport credentials, instead relying on standard environment variable-based configuration. The addition of backward compatibility for existing flag-based configurations by setting the corresponding environment variables is a well-thought-out approach. The overall result is a cleaner, more maintainable, and more standard-compliant telemetry setup. The dependency updates and test adjustments are also appropriate and align with the refactoring. Great work!

Comment thread core/pkg/telemetry/builder.go Outdated
Comment thread core/pkg/telemetry/builder.go
@toddbaert toddbaert requested a review from beeme1mr November 21, 2025 18:56
@toddbaert

toddbaert commented Nov 21, 2025

Copy link
Copy Markdown
Member

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 toddbaert self-requested a review November 21, 2025 18:59
@sonarqubecloud

sonarqubecloud Bot commented Dec 5, 2025

Copy link
Copy Markdown

@beeme1mr beeme1mr merged commit c2e3fc6 into open-feature:main Dec 8, 2025
17 checks passed
@github-actions github-actions Bot mentioned this pull request Dec 2, 2025
@askpt askpt deleted the askpt/1141-add-otel-variables branch December 9, 2025 05:32
toddbaert added a commit that referenced this pull request Dec 24, 2025
🤖 I have created a release *beep* *boop*
---


<details><summary>flagd: 0.13.0</summary>

##
[0.13.0](flagd/v0.12.9...flagd/v0.13.0)
(2025-12-23)


### 🐛 Bug Fixes

* fixing sync return format missing flag layer, adding full e2e suite
([#1827](#1827))
([570693d](570693d))
* **security:** update module github.com/go-viper/mapstructure/v2 to
v2.4.0 [security]
([#1784](#1784))
([037e30b](037e30b))
* **security:** update module golang.org/x/crypto to v0.45.0 [security]
([#1826](#1826))
([7e0762b](7e0762b))


### ✨ New Features

* add support for http-based ofrep metrics
([#1803](#1803))
([fcd19b3](fcd19b3))
* cleanup evaluator interface
([#1793](#1793))
([aa504f7](aa504f7))
* enable parsing of array flag configurations for flagd
([#1797](#1797))
([97c6ffa](97c6ffa))
* multi-project support via selectors and flagSetId namespacing
([#1702](#1702))
([f9ce46f](f9ce46f))
* normalize selector in sync (use header as in OFREP and RPC)
([#1815](#1815))
([c1f06cb](c1f06cb))


### 🧹 Chore

* **refactor:** use memdb for flag storage
([#1697](#1697))
([5c5c1cf](5c5c1cf))


### 🔄 Refactoring

* store cleanup
([#1705](#1705))
([bcff8d7](bcff8d7))
</details>

<details><summary>flagd-proxy: 0.8.1</summary>

##
[0.8.1](flagd-proxy/v0.8.0...flagd-proxy/v0.8.1)
(2025-12-23)


### 🐛 Bug Fixes

* **security:** update module github.com/go-viper/mapstructure/v2 to
v2.4.0 [security]
([#1784](#1784))
([037e30b](037e30b))
* **security:** update module golang.org/x/crypto to v0.45.0 [security]
([#1826](#1826))
([7e0762b](7e0762b))
</details>

<details><summary>core: 0.13.0</summary>

##
[0.13.0](core/v0.12.1...core/v0.13.0)
(2025-12-23)


### ⚠ BREAKING CHANGES

* enable parsing of array flag configurations for flagd
([#1797](#1797))
* cleanup evaluator interface
([#1793](#1793))
* removes the `fractionalEvaluation` operator since it has been replaced
with `fractional`.
([#1704](#1704))

### 🐛 Bug Fixes

* **security:** update module github.com/go-viper/mapstructure/v2 to
v2.4.0 [security]
([#1784](#1784))
([037e30b](037e30b))
* **security:** update module golang.org/x/crypto to v0.45.0 [security]
([#1825](#1825))
([44edcc9](44edcc9))
* **security:** update module golang.org/x/crypto to v0.45.0 [security]
([#1826](#1826))
([7e0762b](7e0762b))


### ✨ New Features

* Add OAuth support for HTTP Sync
([#1791](#1791))
([268fd75](268fd75))
* Add OTEL default variables
([#1812](#1812))
([c2e3fc6](c2e3fc6))
* allow null flagSetId Selector, restrict Selector to single
key-value-pairs
([#1708](#1708))
([#1811](#1811))
([c12a0ae](c12a0ae))
* change jsonschema parser
([#1794](#1794))
([bf3f722](bf3f722))
* cleanup evaluator interface
([#1793](#1793))
([aa504f7](aa504f7))
* enable parsing of array flag configurations for flagd
([#1797](#1797))
([97c6ffa](97c6ffa))
* multi-project support via selectors and flagSetId namespacing
([#1702](#1702))
([f9ce46f](f9ce46f))


### 🧹 Chore

* **refactor:** use memdb for flag storage
([#1697](#1697))
([5c5c1cf](5c5c1cf))
* removes the `fractionalEvaluation` operator since it has been replaced
with `fractional`.
([#1704](#1704))
([3228ad8](3228ad8))


### 🔄 Refactoring

* remove deprecated bearerToken option
([#1816](#1816))
([efda06a](efda06a))
* removed unused Selector from Flag and Store.
([#1747](#1747))
([1083005](1083005))
* store cleanup
([#1705](#1705))
([bcff8d7](bcff8d7))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] flagd should use standard OTel SDK env vars

5 participants