Skip to content
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 Metrics Hook #114

Merged
merged 26 commits into from
Dec 19, 2023
Merged

feat: Add Metrics Hook #114

merged 26 commits into from
Dec 19, 2023

Conversation

askpt
Copy link
Member

@askpt askpt commented Dec 14, 2023

This PR

  • This PR adds the metrics to the Feature Flag evaluation hook.

Related Issues

Fixes #113

@askpt askpt marked this pull request as ready for review December 14, 2023 17:40
@askpt askpt requested a review from a team as a code owner December 14, 2023 17:40
@toddbaert
Copy link
Member

@thisthat @beeme1mr adding you guys because you have a bit more OTel experience than me.

internal const string SuccessDescription = "feature flag evaluation success counter";
internal const string ErrorDescription = "feature flag evaluation error counter";

internal const string KeyAttr = "key";
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Not sure if they expect PRs for this or not, but we could open one.

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems the library has not "updated" since 2022: https://www.nuget.org/packages/OpenTelemetry.SemanticConventions/1.0.0-rc9.9

Might need some help to reopen engagement there

Copy link
Member

@thisthat thisthat left a comment

Choose a reason for hiding this comment

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

LGTM, I only left a minor suggestion :)
I don't know enough of C# to feel confident approving the PR tho, I'll delegate someone else for this :)

@toddbaert
Copy link
Member

@beeme1mr is there a spec for these metrics somewhere? I know we have the trace semantics covered in OTel now - but I don't think there's anything specifically about metrics (correct me if I'm wrong)

LGTM, I only left a minor suggestion :) I don't know enough of C# to feel confident approving the PR tho, I'll delegate someone else for this :)

Yes, thanks @thisthat . I will review from a C# perspective, just glad to have you vet the OTel-specific stuff.

Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

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

Really good work, much appreciated. I think my only concern is a lack of assertions on the attributes (if I missed that, please point me in the right direction).

@askpt
Copy link
Member Author

askpt commented Dec 15, 2023

Really good work, much appreciated. I think my only concern is a lack of assertions on the attributes (if I missed that, please point me in the right direction).

@toddbaert: after inspecting the Java library I noticed a few differences that I want to correct:

  • Units are wrong. All are long and it should be another unit.
  • Missing a clear table with Metrics exposed
  • Doesn't support at the moment what they called Custom dimensions.
  • Needs assertions at the tag list level. I am currently investigating this since I cannot find an easy way to assert the tag list.

@toddbaert
Copy link
Member

toddbaert commented Dec 15, 2023

  • Doesn't support at the moment what they called Custom dimensions.

I noticed this, and it didn't immediately concern me because it's something that can be added later without breakage.

If you want, you can add it in this PR though. Otherwise I'll simply create a new issue.

  • Needs assertions at the tag list level. I am currently investigating this since I cannot find an easy way to assert the tag list.

Here's how it was implemented in JS: https://github.com/open-feature/js-sdk-contrib/blob/1db63dca9a392c14f1574ec5ea8bda53f44123cd/libs/hooks/open-telemetry/src/lib/metrics/metrics-hook.spec.ts#L103-L112, if that's at all helpful!

@@ -4,6 +4,7 @@ components:
src/OpenFeature.Contrib.Hooks.Otel:
- bacherfl
- toddbaert
- askpt
Copy link
Member

Choose a reason for hiding this comment

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

@askpt I hope you don't mind I've added you here. This will add you to PRs for this component automatically, once you're an org member.

@askpt
Copy link
Member Author

askpt commented Dec 18, 2023

  • Doesn't support at the moment what they called Custom dimensions.

I noticed this, and it didn't immediately concern me because it's something that can be added later without breakage.

If you want, you can add it in this PR though. Otherwise I'll simply create a new issue.

Please create a new issue. This PR is already big enough and it's not a breaking change as you mentioned.

  • Needs assertions at the tag list level. I am currently investigating this since I cannot find an easy way to assert the tag list.

Here's how it was implemented in JS: https://github.com/open-feature/js-sdk-contrib/blob/1db63dca9a392c14f1574ec5ea8bda53f44123cd/libs/hooks/open-telemetry/src/lib/metrics/metrics-hook.spec.ts#L103-L112, if that's at all helpful!

I am trying to find a way to do it but it doesn't seem possible. The counter tags are private in the meter class tagsToMetricPointIndexDictionary. This is all I can find:
Screenshot 2023-12-18 at 18 03 10

@toddbaert
Copy link
Member

  • Doesn't support at the moment what they called Custom dimensions.

I noticed this, and it didn't immediately concern me because it's something that can be added later without breakage.
If you want, you can add it in this PR though. Otherwise I'll simply create a new issue.

Please create a new issue. This PR is already big enough and it's not a breaking change as you mentioned.

Done.

  • Needs assertions at the tag list level. I am currently investigating this since I cannot find an easy way to assert the tag list.

Here's how it was implemented in JS: https://github.com/open-feature/js-sdk-contrib/blob/1db63dca9a392c14f1574ec5ea8bda53f44123cd/libs/hooks/open-telemetry/src/lib/metrics/metrics-hook.spec.ts#L103-L112, if that's at all helpful!

I am trying to find a way to do it but it doesn't seem possible. The counter tags are private in the meter class tagsToMetricPointIndexDictionary. This is all I can find: Screenshot 2023-12-18 at 18 03 10

OK in that case I'm tempted to call the testing good enough, given the limitations.

Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

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

Approved in light of this comment.

@toddbaert
Copy link
Member

I'll merge this EOD unless I hear objections.

@toddbaert toddbaert merged commit 5845e2b into open-feature:main Dec 19, 2023
9 checks passed
@askpt askpt deleted the askpt/113-add-metrics branch December 22, 2023 14:03
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.

Create a new MetricsHook
4 participants