-
Notifications
You must be signed in to change notification settings - Fork 764
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
Changes from all commits
2acba3a
18cfb2d
1073a12
0884011
ce1e34e
af79723
6963b0c
1c75977
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -319,36 +319,54 @@ public static MeterProvider Build(this MeterProviderBuilder meterProviderBuilder | |
|
||
#if EXPOSE_EXPERIMENTAL_FEATURES | ||
/// <summary> | ||
/// Sets the <see cref="ExemplarFilter"/> to be used for this provider. | ||
/// This is applied to all the metrics from this provider. | ||
/// 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"/>. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default is Edit: I see it says provider configuration. Could we reword this? If someone just does There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
I tried to satisfy that 🤣 |
||
/// </summary> | ||
/// <remarks><inheritdoc cref="Exemplar" path="/remarks/para[@experimental-warning='true']"/></remarks> | ||
/// <param name="meterProviderBuilder"><see cref="MeterProviderBuilder"/>.</param> | ||
/// <param name="exemplarFilter"><see cref="ExemplarFilter"/> ExemplarFilter to use.</param> | ||
/// <returns>The supplied <see cref="MeterProviderBuilder"/> for chaining.</returns> | ||
/// <remarks> | ||
/// <inheritdoc cref="Exemplar" | ||
/// path="/remarks/para[@experimental-warning='true']"/> | ||
/// <para>Note: Use <see cref="ExemplarFilterType.TraceBased"/> or <see | ||
/// cref="ExemplarFilterType.AlwaysOn"/> to enable exemplars.</para> | ||
/// <para>Specification: <see | ||
/// href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#exemplarfilter"/>.</para> | ||
/// </remarks> | ||
/// <param name="meterProviderBuilder"><see | ||
/// cref="MeterProviderBuilder"/>.</param> | ||
/// <param name="exemplarFilter"><see cref="ExemplarFilterType"/> to | ||
/// use.</param> | ||
/// <returns>The supplied <see cref="MeterProviderBuilder"/> for | ||
/// chaining.</returns> | ||
#if NET8_0_OR_GREATER | ||
[Experimental(DiagnosticDefinitions.ExemplarExperimentalApi, UrlFormat = DiagnosticDefinitions.ExperimentalApiUrlFormat)] | ||
#endif | ||
public | ||
#else | ||
/// <summary> | ||
/// Sets the <see cref="ExemplarFilter"/> to be used for this provider. | ||
/// This is applied to all the metrics from this provider. | ||
/// </summary> | ||
/// <param name="meterProviderBuilder"><see cref="MeterProviderBuilder"/>.</param> | ||
/// <param name="exemplarFilter"><see cref="ExemplarFilter"/> ExemplarFilter to use.</param> | ||
/// <returns>The supplied <see cref="MeterProviderBuilder"/> for chaining.</returns> | ||
internal | ||
#endif | ||
static MeterProviderBuilder SetExemplarFilter(this MeterProviderBuilder meterProviderBuilder, ExemplarFilter exemplarFilter) | ||
static MeterProviderBuilder SetExemplarFilter( | ||
this MeterProviderBuilder meterProviderBuilder, | ||
ExemplarFilterType exemplarFilter = ExemplarFilterType.TraceBased) | ||
{ | ||
Guard.ThrowIfNull(exemplarFilter); | ||
|
||
meterProviderBuilder.ConfigureBuilder((sp, builder) => | ||
{ | ||
if (builder is MeterProviderBuilderSdk meterProviderBuilderSdk) | ||
{ | ||
meterProviderBuilderSdk.SetExemplarFilter(exemplarFilter); | ||
switch (exemplarFilter) | ||
{ | ||
case ExemplarFilterType.AlwaysOn: | ||
meterProviderBuilderSdk.SetExemplarFilter(new AlwaysOnExemplarFilter()); | ||
break; | ||
case ExemplarFilterType.AlwaysOff: | ||
meterProviderBuilderSdk.SetExemplarFilter(new AlwaysOffExemplarFilter()); | ||
break; | ||
case ExemplarFilterType.TraceBased: | ||
meterProviderBuilderSdk.SetExemplarFilter(new TraceBasedExemplarFilter()); | ||
break; | ||
default: | ||
throw new NotSupportedException($"SdkExemplarFilter '{exemplarFilter}' is not supported."); | ||
} | ||
} | ||
}); | ||
|
||
|
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.
Very nice wording! crisp and clear. 💯