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

[sdk-metrics] ExemplarFilter updates to match latest specification #5404

Conversation

CodeBlanch
Copy link
Member

@CodeBlanch CodeBlanch commented Mar 1, 2024

Changes

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@CodeBlanch CodeBlanch added pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package metrics Metrics signal related labels Mar 1, 2024
@CodeBlanch CodeBlanch requested a review from a team March 1, 2024 05:44
Copy link

codecov bot commented Mar 1, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 84.58%. Comparing base (6250307) to head (1c75977).
Report is 107 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5404      +/-   ##
==========================================
+ Coverage   83.38%   84.58%   +1.19%     
==========================================
  Files         297      284      -13     
  Lines       12531    12104     -427     
==========================================
- Hits        10449    10238     -211     
+ Misses       2082     1866     -216     
Flag Coverage Δ
unittests ?
unittests-Solution-Experimental 84.50% <92.85%> (?)
unittests-Solution-Stable 84.55% <92.85%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...emetry/Metrics/Exemplar/AlwaysOffExemplarFilter.cs 0.00% <ø> (ø)
...lemetry/Metrics/Exemplar/AlwaysOnExemplarFilter.cs 100.00% <ø> (ø)
...metry/Metrics/Exemplar/TraceBasedExemplarFilter.cs 50.00% <ø> (+50.00%) ⬆️
.../Metrics/Builder/MeterProviderBuilderExtensions.cs 98.47% <92.85%> (-1.53%) ⬇️

... and 55 files with indirect coverage changes

@@ -55,6 +55,16 @@
API.
([#5396](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5396))

* **Experimental (pre-release builds only):** Removed the `ExemplarFilter`,
Copy link
Member

Choose a reason for hiding this comment

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

Very nice wording! crisp and clear. 💯

private MeterProvider meterProvider;
private Meter meter;

[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:Enumeration items should be documented", Justification = "Test only.")]
public enum ExemplarFilterToUse
public enum ExemplarConfigurationType
Copy link
Member

Choose a reason for hiding this comment

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

can you update the benchmark numbers as well? This was added to highlight the relevance of filtering and how perf gets affected when more measurements are considered (not store) for exemplars?

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the numbers on here: 1c75977

But I will say, I think having the numbers in the source files is bad practice. The numbers are really only useful when run on the same machine and run against other numbers from the same machine run under similar circumstances. To properly benchmark, you need to run numbers on some branch, and then switch to a branch with code changes and re-run them again. Having the numbers in the source file could mislead people into thinking they have made things better or worse unless they correctly re-run the base first 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

These numbers are useful for tracking memory allocation. It's easy to check if your code adds or reduces the memory allocation by comparing with the results in the source file.

Having the numbers in the source file could mislead people into thinking they have made things better or worse unless they correctly re-run the base first

We also copy the information about the hardware config when running the benchmarks so if someone is ignoring that, then maybe we could just add a comment saying these numbers are related to that particular config only.

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably not the way to do it. We don't even turn on memory allocation tracking by default you have to add "-m" 🤣 A solution would be more like we mark the things which we expect to be allocation-free and verify that in CI so we aren't reliant on a) people running them and b) people running them correctly understanding the nuances.

Copy link
Contributor

@utpilla utpilla Mar 1, 2024

Choose a reason for hiding this comment

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

CI based solution would be much better than what we have for sure.

But with the existing approach, for anyone updating benchmarks in a PR, the reviewers check (and should check) if the memory allocation column is added or not. They also check if the PR author ran the benchmarks for both main and the feature branch.

Copy link
Member

Choose a reason for hiding this comment

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

we can still keep them with a note above.
Its very useful to look at it and see how much overhead each feature is adding on.

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

Left some nits, nothing blocking and can be follow ups.

@vishweshbankwar
Copy link
Member

@CodeBlanch This needs to be updated as well:

.SetExemplarFilter(new TraceBasedExemplarFilter())
. Curious how did the build couldn't catch this?

/// Sets the <see cref="ExemplarFilterType"/> to be used for this provider
/// which controls how measurements will be offered to exemplar reservoirs.
/// Default provider configuration: <see
/// cref="ExemplarFilterType.AlwaysOff"/>.
Copy link
Member

@vishweshbankwar vishweshbankwar Mar 1, 2024

Choose a reason for hiding this comment

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

The default is TraceBased

Edit: I see it says provider configuration. Could we reword this? If someone just does SetExemplarFilter(), the default would be TraceBased

Copy link
Member

Choose a reason for hiding this comment

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

need some spec work to clarify defaults. It is not clear if exemplars, as a feature, itself is enabled by default. once enabled, yes, tracebased is the default, but we need to see if that makes sense. (I don't think so, but will wait for Blanch's current work before we approach spec)

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree it is a bit confusing in the spec.

There's two statements in metrics sdk:

Exemplar sampling SHOULD be turned off by default. If Exemplar sampling is off, the SDK MUST NOT have overhead related to exemplar sampling.

The ExemplarFilter SHOULD be a configuration parameter of a MeterProvider for an SDK. The default value SHOULD be TraceBased.

I tried to satisfy that 🤣


/// <summary>
/// An exemplar filter which makes measurements recorded in the context of a
/// sampled <see cref="Activity"/> (span) eligible for becoming an <see
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// sampled <see cref="Activity"/> (span) eligible for becoming an <see
/// sampled parent <see cref="Activity"/> (span) eligible for becoming an <see

to match the spec definition.

Copy link
Member Author

Choose a reason for hiding this comment

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

This "parent" text was in a couple spots. I removed it because I thought it was super confusing!

An ExemplarFilter which makes those measurements eligible for being an Exemplar, which are recorded in the context of a sampled parent span.

Does that mean Activity.Current.Parent.Recorded or Activity.Current.Recorded?

An ExemplarFilter which makes those measurements eligible for being an Exemplar, which are recorded in the context of a sampled span.

Seems to more clearly mean Activity.Current.Recorded?

Copy link
Member

Choose a reason for hiding this comment

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

I think the parent term is used with respect to the measurement here. But I see the confusion, ok to keep what you have.

@CodeBlanch
Copy link
Member Author

This needs to be updated as well:

.SetExemplarFilter(new TraceBasedExemplarFilter())

. Curious how did the build couldn't catch this?

@vishweshbankwar

Updated here: ce1e34e

The build didn't catch it because #if EXPOSE_EXPERIMENTAL_FEATURES is meaningless to the example apps. Something I need to fix just haven't had a chance yet.

@CodeBlanch CodeBlanch merged commit b754b13 into open-telemetry:main Mar 1, 2024
37 checks passed
@CodeBlanch CodeBlanch deleted the sdk-metrics-exemplarfilter-spec-updates branch March 1, 2024 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metrics Metrics signal related pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants