-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: Add OTEL compatible telemetry object builder #397
base: main
Are you sure you want to change the base?
Conversation
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>
…tionEventFactory for event creation Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…tory for event creation Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…eature flags Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
…ation Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR adds OTEL-compatible telemetry support to the OpenFeature library by introducing new classes, constants, and tests for building evaluation events used in feature flag evaluations.
- Added telemetry constants and flag metadata classes.
- Implemented an evaluation event builder to construct OTEL-compliant evaluation events.
- Included unit tests to verify the correct construction of evaluation events.
Reviewed Changes
File | Description |
---|---|
src/OpenFeature/Telemetry/TelemetryConstants.cs | Introduces constants for telemetry event attributes. |
src/OpenFeature/Telemetry/EvaluationEventBuilder.cs | Implements the builder for evaluation events. |
test/OpenFeature.Tests/Telemetry/EvaluationEventBuilderTests.cs | Adds tests to validate evaluation event building, including error handling and missing variants. |
src/OpenFeature/Telemetry/TelemetryFlagMetadata.cs | Defines well-known metadata keys for telemetry. |
src/OpenFeature/Telemetry/TelemetryEvaluationData.cs | Adds evaluation data constants for telemetry events. |
src/OpenFeature/Telemetry/EvaluationEvent.cs | Provides the EvaluationEvent class used to represent an event. |
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
src/OpenFeature/Telemetry/EvaluationEventBuilder.cs:28
- The reference 'Reason.Unknown' is undefined in this context; please ensure that the appropriate constant or enum is referenced instead.
attributes[TelemetryConstants.Reason] = !string.IsNullOrWhiteSpace(details.Reason) ? details.Reason?.ToLowerInvariant() : Reason.Unknown;
test/OpenFeature.Tests/Telemetry/EvaluationEventBuilderTests.cs:2
- The using directive 'using OpenFeature.Constant;' in the test file does not match the namespace of TelemetryConstants. Please update it to 'using OpenFeature.Telemetry;' to ensure consistency.
using OpenFeature.Constant;
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #397 +/- ##
==========================================
- Coverage 86.16% 86.12% -0.05%
==========================================
Files 39 41 +2
Lines 1605 1636 +31
Branches 173 180 +7
==========================================
+ Hits 1383 1409 +26
Misses 186 186
- Partials 36 41 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…e tests for missing flag metadata Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR adds support for OTEL-compatible telemetry events for feature flags in the OpenFeature library. The changes include the creation of new classes for evaluation events and their builders, the definition of related constants, and comprehensive tests for the new functionality.
- Added telemetry constants and flag metadata definitions.
- Introduced the EvaluationEvent and EvaluationEventBuilder classes.
- Added unit tests to verify the behavior of evaluation event creation.
Reviewed Changes
File | Description |
---|---|
src/OpenFeature/Telemetry/TelemetryConstants.cs | Defines constants for telemetry attribute keys. |
src/OpenFeature/Telemetry/EvaluationEventBuilder.cs | Provides a builder for creating evaluation events; review notes below. |
test/OpenFeature.Tests/Telemetry/EvaluationEventBuilderTests.cs | Contains tests that verify evaluation event creation behavior. |
src/OpenFeature/Telemetry/TelemetryEvaluationData.cs | Defines additional telemetry event data constants. |
src/OpenFeature/Telemetry/TelemetryFlagMetadata.cs | Specifies well-known flag metadata attribute keys. |
src/OpenFeature/Telemetry/EvaluationEvent.cs | Implements the evaluation event model with attributes and body. |
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/OpenFeature/Telemetry/EvaluationEventBuilder.cs:2
- The using directive 'OpenFeature.Constant' appears inconsistent with the location of TelemetryConstants, which is in the 'OpenFeature.Telemetry' namespace. Consider updating or removing this directive to avoid potential namespace conflicts.
using OpenFeature.Constant;
src/OpenFeature/Telemetry/EvaluationEventBuilder.cs:31
- The use of 'Reason.Unknown' appears to reference an undefined member. Consider defining a constant (e.g., TelemetryConstants.DefaultReason or similar) or replacing it with an appropriate default value such as "unknown".
attributes[TelemetryConstants.Reason] = !string.IsNullOrWhiteSpace(details.Reason) ? details.Reason?.ToLowerInvariant() : Reason.Unknown;
…er and add corresponding unit tests Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
e016fcf
to
2d81ada
Compare
This PR
This pull request introduces a new feature for telemetry in the OpenFeature library, specifically focusing on evaluation events for feature flags. The main changes include the addition of new classes and constants to support the creation and handling of these events, as well as tests to ensure the functionality works as expected.
New Features for Telemetry:
src/OpenFeature/Telemetry/EvaluationEvent.cs
: Added theEvaluationEvent
class to represent an evaluation event for feature flags, including properties for the event name, attributes, and body.src/OpenFeature/Telemetry/EvaluationEventBuilder.cs
: Introduced theEvaluationEventBuilder
class to create evaluation events based on hook context and flag evaluation details.Constants for Telemetry:
src/OpenFeature/Telemetry/TelemetryConstants.cs
: Defined constants for various attributes used in telemetry events, such asKey
,ErrorCode
,Variant
,ContextId
,ErrorMessage
,Reason
,Provider
,FlagSetId
, andVersion
.src/OpenFeature/Telemetry/TelemetryEvaluationData.cs
: Added theTelemetryEvaluationData
class for event-specific data, specifically the evaluated value of the feature flag.src/OpenFeature/Telemetry/TelemetryFlagMetadata.cs
: Introduced theTelemetryFlagMetadata
class for well-known flag metadata attributes, such asContextId
,FlagSetId
, andVersion
.Tests for Evaluation Event Builder:
test/OpenFeature.Tests/Telemetry/EvaluationEventBuilderTests.cs
: Added unit tests for theEvaluationEventBuilder
to verify that the evaluation events are built correctly, including handling of error details and missing variants.Related Issues
Fixes #381