Skip to content

feat: Move OTEL hooks to the SDK #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Jun 27, 2025
Merged

feat: Move OTEL hooks to the SDK #338

merged 53 commits into from
Jun 27, 2025

Conversation

askpt
Copy link
Member

@askpt askpt commented Dec 31, 2024

Move OTEL hooks to the SDK

This pull request introduces telemetry enhancements to the OpenFeature .NET SDK by adding new hooks for tracing and metrics, updating dependencies, and providing examples and tests. The most significant changes include the addition of the TraceEnricherHook and MetricsHook classes, integration of OpenTelemetry in the ASP.NET Core sample, and updates to dependencies to support telemetry features.

Telemetry Enhancements

  • Trace Enricher Hook: Added TraceEnricherHook to enrich telemetry traces with feature flag evaluation details, including tags and events for tracing purposes. This hook integrates with the current Activity and supports error handling.
  • Metrics Hook: Introduced MetricsHook for capturing metrics such as evaluation requests, successes, errors, and active evaluations. Metrics are collected using OpenTelemetry's Meter API. [1] [2]

Dependency Updates

  • OpenTelemetry Dependencies: Added OpenTelemetry.Extensions.Hosting, OpenTelemetry.Instrumentation.AspNetCore, and OpenTelemetry.Exporter.OpenTelemetryProtocol to the ASP.NET Core sample project to support telemetry features. [1] [2]
  • DiagnosticSource Dependency: Included System.Diagnostics.DiagnosticSource in the main project and centralized dependency management. [1] [2]

Documentation and Examples

  • README Updates: Added documentation for TraceEnricherHook and MetricsHook, including detailed descriptions, examples, and usage instructions for integrating these hooks with OpenTelemetry.
  • ASP.NET Core Sample: Updated the sample application to demonstrate the use of TraceEnricherHook and MetricsHook with OpenTelemetry tracing and metrics. [1] [2]

Testing

  • MetricsHook Tests: Added unit tests for MetricsHook to verify metrics collection during different stages of feature flag evaluation (e.g., BeforeAsync, AfterAsync, ErrorAsync, FinallyAsync).

Related Issues

Fixes #175

Notes

  • In this PR I made some changes to the samples application. This allow us to see the metrics and traces in any OTEL tool.

Check the screenshots below:

Screenshot 2025-06-25 at 18 58 59

Follow-up Tasks

  • We should remove any reference in the other repository and mark the Nuget package as deprecated.

askpt added 10 commits December 31, 2024 10:04

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>
@askpt askpt linked an issue Dec 31, 2024 that may be closed by this pull request
@askpt askpt changed the title Move OTEL hooks to the SDK feat: Move OTEL hooks to the SDK Dec 31, 2024
Copy link

codecov bot commented Dec 31, 2024

Codecov Report

Attention: Patch coverage is 95.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 87.23%. Comparing base (39f884d) to head (2b4306a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/OpenFeature/Hooks/MetricsHook.cs 94.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #338      +/-   ##
==========================================
+ Coverage   87.02%   87.23%   +0.21%     
==========================================
  Files          45       47       +2     
  Lines        1757     1794      +37     
  Branches      184      182       -2     
==========================================
+ Hits         1529     1565      +36     
- Misses        188      190       +2     
+ Partials       40       39       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>
@askpt askpt marked this pull request as ready for review December 31, 2024 11:48
@askpt askpt requested a review from a team as a code owner December 31, 2024 11:48

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
# Conflicts:
#	Directory.Packages.props

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@beeme1mr
Copy link
Member

beeme1mr commented Jan 6, 2025

Thanks for starting this PR but I think we should wait until this spec PR is merged before moving this hook to the SDK.

askpt added 2 commits January 7, 2025 08:40

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Signed-off-by: André Silva <[email protected]>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@askpt askpt force-pushed the askpt/175-promote-otel-hooks branch from c95eefa to 47cd3f4 Compare April 8, 2025 13:36
askpt added 4 commits June 23, 2025 16:54

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
…mental status

Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
… related tests

Signed-off-by: André Silva <[email protected]>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
askpt added 2 commits June 25, 2025 17:49

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
…cing

Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
…ne error handling

Signed-off-by: André Silva <[email protected]>
@askpt askpt mentioned this pull request Jun 25, 2025
2 tasks
askpt added 5 commits June 25, 2025 18:06

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
…acingConstants class

Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
…uationEventBuilder

Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
…okTests

Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
Signed-off-by: André Silva <[email protected]>
@askpt askpt marked this pull request as draft June 25, 2025 17:27
askpt added 2 commits June 25, 2025 18:46

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
…iption

Signed-off-by: André Silva <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
askpt André Silva
… sample

Signed-off-by: André Silva <[email protected]>
@askpt
Copy link
Member Author

askpt commented Jun 25, 2025

@beeme1mr, @toddbaert, @kinyoklion, and @kylejuliandev, I made a couple of changes since your last review. Please look to see if they make sense.

@askpt askpt marked this pull request as ready for review June 25, 2025 18:09

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@askpt askpt added this pull request to the merge queue Jun 27, 2025
Merged via the queue into main with commit 77f6e1b Jun 27, 2025
17 checks passed
@askpt askpt deleted the askpt/175-promote-otel-hooks branch June 27, 2025 14:36
github-merge-queue bot pushed a commit that referenced this pull request Jul 3, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
🤖 I have created a release *beep* *boop*
---


##
[2.7.0](v2.6.0...v2.7.0)
(2025-07-03)


### 🐛 Bug Fixes

* Add generic to evaluation event builder
([#500](#500))
([68af649](68af649))
* ArgumentNullException when creating a client with optional name
([#508](#508))
([9151dcd](9151dcd))


### ✨ New Features

* Move OTEL hooks to the SDK
([#338](#338))
([77f6e1b](77f6e1b))


### 🧹 Chore

* **deps:** update actions/attest-build-provenance action to v2.4.0
([#495](#495))
([349c073](349c073))
* **deps:** update actions/attest-sbom action to v2.4.0
([#496](#496))
([f7ca416](f7ca416))
* **deps:** update dependency benchmarkdotnet to 0.15.0
([#481](#481))
([714425d](714425d))
* **deps:** update dependency benchmarkdotnet to 0.15.2
([#494](#494))
([cab3807](cab3807))
* **deps:** update dependency microsoft.net.test.sdk to 17.14.0
([#482](#482))
([520d383](520d383))
* **deps:** update dependency microsoft.net.test.sdk to 17.14.1
([#485](#485))
([78bfdbf](78bfdbf))
* **deps:** update dependency opentelemetry.instrumentation.aspnetcore
to 1.12.0
([#505](#505))
([241d880](241d880))
* **deps:** update dependency reqnroll.xunit to 2.4.1
([#483](#483))
([99f7584](99f7584))
* **deps:** update dependency system.valuetuple to 4.6.1
([#503](#503))
([39f884d](39f884d))
* **deps:** update github/codeql-action digest to 39edc49
([#504](#504))
([08ff43c](08ff43c))
* **deps:** update github/codeql-action digest to ce28f5b
([#492](#492))
([cce224f](cce224f))
* **deps:** update github/codeql-action digest to fca7ace
([#486](#486))
([e18ad50](e18ad50))
* **deps:** update opentelemetry-dotnet monorepo to 1.12.0
([#506](#506))
([69dc186](69dc186))
* **deps:** update spec digest to 1965aae
([#499](#499))
([2e3dffd](2e3dffd))
* **deps:** update spec digest to 42340bb
([#493](#493))
([909c51d](909c51d))
* **deps:** update spec digest to c37ac17
([#502](#502))
([38f63fc](38f63fc))
* **deps:** update spec digest to f014806
([#479](#479))
([dbe8b08](dbe8b08))
* fix sample build warning
([#498](#498))
([08a00e1](08a00e1))


### 📚 Documentation

* add XML comment on FeatureClient
([#507](#507))
([f923cea](f923cea))
* updated contributing link on the README
([8435bf7](8435bf7))

---
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Promote OTel hooks from contrib to in-the-box
5 participants