Skip to content

Add ExemplarFilter interfaces #3852

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

Closed

Conversation

cijothomas
Copy link
Member

Towards #2527
Adds ExemplarFilter interface/default implnm.
Everything is internal, and is not connected to the Metrics SDK. This will be done post 1.4.0 stable release.

Ref: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#exemplarfilter

@cijothomas cijothomas requested a review from a team November 1, 2022 17:07
/// </summary>
internal sealed class NoneExemplarFilter : IExemplarFilter
{
public bool ShouldSample(long value, ReadOnlySpan<KeyValuePair<string, object>> tags)
Copy link
Member

Choose a reason for hiding this comment

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

I suggest having two performance test cases to guide the initial exploration:

  1. A NoneExemplarFilter (or AlwaysOffExemplarFilter) is being used, and the performance should be the same as if such filter doesn't exist (in other words, folks don't have to pay any extra cost if they don't use exemplar at all).
  2. A naive exemplar which only picks the 1st item, and try to compare the performance between a hard-wired approach (by just manually putting the logic directly without leveraging any abstraction/interface) and the pluggable approach (e.g. via interface/DI/etc.) - and if the pluggable approach is introducing too much extra overhead, rethink about the design (e.g. maybe switch to a different pluggable model).

Copy link
Member Author

Choose a reason for hiding this comment

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

yup thats roughly what I plan. 1st goal is to get the shape of things, then attach it to right places and measure the perf..

@codecov
Copy link

codecov bot commented Nov 1, 2022

Codecov Report

Merging #3852 (a09dc27) into main (bb0c381) will decrease coverage by 0.97%.
The diff coverage is 23.88%.

❗ Current head a09dc27 differs from pull request most recent head 2193a9c. Consider uploading reports for the commit 2193a9c to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3852      +/-   ##
==========================================
- Coverage   85.62%   84.66%   -0.97%     
==========================================
  Files         289      298       +9     
  Lines       11255    11436     +181     
==========================================
+ Hits         9637     9682      +45     
- Misses       1618     1754     +136     
Impacted Files Coverage Δ
...elemetry.Exporter.Console/ConsoleMetricExporter.cs 0.00% <0.00%> (ø)
...DiagnosticSourceInstrumentation/ListenerHandler.cs 83.33% <ø> (ø)
src/OpenTelemetry/Metrics/Exemplar.cs 0.00% <0.00%> (ø)
...penTelemetry/Metrics/Exemplar/AllExemplarFilter.cs 0.00% <0.00%> (ø)
...c/OpenTelemetry/Metrics/Exemplar/ExemplarFilter.cs 0.00% <0.00%> (ø)
...penTelemetry/Metrics/Exemplar/ExemplarReservoir.cs 0.00% <0.00%> (ø)
src/OpenTelemetry/Metrics/Exemplars.cs 0.00% <0.00%> (ø)
...trics/Exemplar/SimpleFixedSizeExemplarReservoir.cs 13.46% <13.46%> (ø)
src/OpenTelemetry/Metrics/MetricPoint.cs 63.26% <24.28%> (-12.19%) ⬇️
...xemplar/AlignedHistogramBucketExemplarReservoir.cs 27.27% <27.27%> (ø)
... and 9 more

/// <c>false</c> to indicate this measurement is not eligible to become Exemplar
/// and will not be given to the ExemplarReservoir.
/// </returns>
bool ShouldSample(long value, ReadOnlySpan<KeyValuePair<string, object>> tags);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need an explicit parameter for timestamp? When would this method be called with respect to when a metric is recorded?

Copy link
Member Author

Choose a reason for hiding this comment

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

spec says timestamp is needed. but we do not allow user to provide timestamp for metric APIs, and is always assumed to be the current time.. so the Filter can also take current timestamp, without we providing it. (have to check if this is bad for perf.. )

(Similar with context. we dont pass it. its implicit.

Copy link
Contributor

Choose a reason for hiding this comment

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

No concerns with thread preemption here, right?

/// <summary>
/// The interface defining Exemplar Filter.
/// </summary>
internal interface IExemplarFilter
Copy link
Member

Choose a reason for hiding this comment

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

Is "filter" coming from the spec? Asking because IExemplarSampler, AlwaysOnExemplarSampler, & AlwaysOffExemplarSampler might fit in better with what we have for tracing 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

open-telemetry/opentelemetry-specification#2919 I am proposing fixes in spec in parallel.

@cijothomas
Copy link
Member Author

Marking as draft. No need to merge now. I will update once the perf implications are fully understood with basic implementations.

@cijothomas cijothomas marked this pull request as draft November 18, 2022 18:40
@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Nov 26, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2022

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Dec 4, 2022
@cijothomas cijothomas reopened this Jan 12, 2023
@github-actions github-actions bot removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jan 13, 2023
@cijothomas
Copy link
Member Author

I was planning to merge changes to main after 1.4.0 ship has sailed. Unfortunately 1.4.0 has not yet happened. I'll be creating a new branch for metrics, and maintain that temporarily until 1.4.0 is out. Starting next week, will be sending PRs to merge to the metrics branch. This is done to unblock Exemplar feature work.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Feb 4, 2023
@github-actions
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Issues and pull requests which have been flagged for closing due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants