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

[repo] Metrics instrumentations - utilize advice API for histogram boundaries #2430

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

* The `http.server.request.duration` histogram (measured in seconds) produced by
the metrics instrumentation in this package now uses the [Advice API](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.10.0/docs/metrics/customizing-the-sdk/README.md#explicit-bucket-histogram-aggregation)
to set default explicit buckets following the [OpenTelemetry Specification](https://github.com/open-telemetry/semantic-conventions/blob/v1.29.0/docs/http/http-metrics.md).
([#2430](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2430))

## 1.10.0-beta.1

Released 2024-Dec-09
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ internal sealed class HttpInMetricsListener : IDisposable

public HttpInMetricsListener(Meter meter, AspNetMetricsInstrumentationOptions options)
{
this.httpServerDuration = meter.CreateHistogram<double>(
this.httpServerDuration = meter.CreateHistogram(
"http.server.request.duration",
unit: "s",
description: "Duration of HTTP server requests.");
description: "Duration of HTTP server requests.",
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10] });
TelemetryHttpModule.Options.OnRequestStoppedCallback += this.OnStopActivity;
this.options = options;
}
Expand Down
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

* The `http.server.request.duration` histogram (measured in seconds) produced by
the metrics instrumentation in this package now uses the [Advice API](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.10.0/docs/metrics/customizing-the-sdk/README.md#explicit-bucket-histogram-aggregation)
to set default explicit buckets following the [OpenTelemetry Specification](https://github.com/open-telemetry/semantic-conventions/blob/v1.29.0/docs/http/http-metrics.md).
([#2430](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2430))

## 1.10.1

Released 2024-Dec-10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ internal sealed class HttpInMetricsListener : ListenerHandler
private static readonly PropertyFetcher<HttpContext> HttpContextPropertyFetcher = new("HttpContext");
private static readonly object ErrorTypeHttpContextItemsKey = new();

private static readonly Histogram<double> HttpServerRequestDuration = Meter.CreateHistogram<double>(HttpServerRequestDurationMetricName, "s", "Duration of HTTP server requests.");
private static readonly Histogram<double> HttpServerRequestDuration = Meter.CreateHistogram(
HttpServerRequestDurationMetricName,
unit: "s",
description: " Duration of HTTP server requests.",
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10] });

internal HttpInMetricsListener(string name)
: base(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
span status. For details see: [Setting Status](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Api/README.md#setting-status).
([#2358](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2358))

* The `messaging.receive.duration` and `messaging.publish.duration` histograms
(measured in seconds) produced by the metrics instrumentation in this package
now uses the [Advice API](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.10.0/docs/metrics/customizing-the-sdk/README.md#explicit-bucket-histogram-aggregation)
to set default explicit buckets following the [OpenTelemetry Specification](https://github.com/open-telemetry/semantic-conventions/blob/v1.24.0/docs/messaging/messaging-metrics.md).
([#2430](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2430))

## 0.1.0-alpha.2

Released 2024-Sep-18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,23 @@ internal static class ConfluentKafkaCommon
internal static readonly string InstrumentationVersion = typeof(ConfluentKafkaCommon).Assembly.GetPackageVersion();
internal static readonly ActivitySource ActivitySource = new(InstrumentationName, InstrumentationVersion);
internal static readonly Meter Meter = new(InstrumentationName, InstrumentationVersion);
internal static readonly Counter<long> ReceiveMessagesCounter = Meter.CreateCounter<long>(SemanticConventions.MetricMessagingReceiveMessages);
internal static readonly Histogram<double> ReceiveDurationHistogram = Meter.CreateHistogram<double>(SemanticConventions.MetricMessagingReceiveDuration);
internal static readonly Counter<long> PublishMessagesCounter = Meter.CreateCounter<long>(SemanticConventions.MetricMessagingPublishMessages);
internal static readonly Histogram<double> PublishDurationHistogram = Meter.CreateHistogram<double>(SemanticConventions.MetricMessagingPublishDuration);
internal static readonly Counter<long> ReceiveMessagesCounter = Meter.CreateCounter<long>(
SemanticConventions.MetricMessagingReceiveMessages,
description: "Measures the number of received messages.");

internal static readonly Histogram<double> ReceiveDurationHistogram = Meter.CreateHistogram(
SemanticConventions.MetricMessagingReceiveDuration,
unit: "s",
description: "Measures the duration of receive operation.",
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10] });

internal static readonly Counter<long> PublishMessagesCounter = Meter.CreateCounter<long>(
SemanticConventions.MetricMessagingPublishMessages,
description: "Measures the number of published messages.");

internal static readonly Histogram<double> PublishDurationHistogram = Meter.CreateHistogram(
SemanticConventions.MetricMessagingPublishDuration,
unit: "s",
description: "Measures the duration of publish operation.",
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10] });
}
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Instrumentation.Http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

* The `http.client.request.duration` histogram (measured in seconds) produced by
the metrics instrumentation in this package now uses the [Advice API](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.10.0/docs/metrics/customizing-the-sdk/README.md#explicit-bucket-histogram-aggregation)
to set default explicit buckets following the [OpenTelemetry Specification](https://github.com/open-telemetry/semantic-conventions/blob/v1.29.0/docs/http/http-metrics.md).
([#2430](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2430))

## 1.10.0

Released 2024-Nov-27
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ internal sealed class HttpHandlerMetricsDiagnosticListener : ListenerHandler
internal static readonly string MeterVersion = AssemblyName.Version!.ToString();
internal static readonly Meter Meter = new(MeterName, MeterVersion);
private const string OnUnhandledExceptionEvent = "System.Net.Http.Exception";
private static readonly Histogram<double> HttpClientRequestDuration = Meter.CreateHistogram<double>("http.client.request.duration", "s", "Duration of HTTP client requests.");
private static readonly Histogram<double> HttpClientRequestDuration = Meter.CreateHistogram(
"http.client.request.duration",
unit: "s",
description: "Duration of HTTP client requests.",
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10] });

private static readonly PropertyFetcher<HttpRequestMessage> StopRequestFetcher = new("Request");
private static readonly PropertyFetcher<HttpResponseMessage> StopResponseFetcher = new("Response");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ internal static class HttpWebRequestActivitySource
private static readonly string Version = AssemblyName.Version.ToString();
private static readonly ActivitySource WebRequestActivitySource = new(ActivitySourceName, Version);
private static readonly Meter WebRequestMeter = new(MeterName, Version);
private static readonly Histogram<double> HttpClientRequestDuration = WebRequestMeter.CreateHistogram<double>("http.client.request.duration", "s", "Duration of HTTP client requests.");
private static readonly Histogram<double> HttpClientRequestDuration = WebRequestMeter.CreateHistogram(
"http.client.request.duration",
unit: "s",
description: "Duration of HTTP client requests.",
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10] });

// Fields for reflection
private static FieldInfo connectionGroupListField;
Expand Down
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
span status. For details see: [Setting Status](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Api/README.md#setting-status).
([#2358](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2358))

* The `http.server.request.duration` histogram (measured in seconds) produced by
the metrics instrumentation in this package now uses the [Advice API](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.10.0/docs/metrics/customizing-the-sdk/README.md#explicit-bucket-histogram-aggregation)
to set default explicit buckets following the [OpenTelemetry Specification](https://github.com/open-telemetry/semantic-conventions/blob/v1.29.0/docs/http/http-metrics.md).
([#2430](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2430))

## 1.0.0-rc.6

Released 2024-Apr-19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ internal static class OwinInstrumentationMetrics
internal static readonly AssemblyName AssemblyName = Assembly.GetName();
internal static readonly string MeterName = AssemblyName.Name;
internal static readonly Meter Instance = new(MeterName, Assembly.GetPackageVersion());
internal static readonly Histogram<double> HttpServerDuration = Instance.CreateHistogram<double>("http.server.request.duration", "s", "Duration of HTTP server requests.");
internal static readonly Histogram<double> HttpServerDuration = Instance.CreateHistogram(
"http.server.request.duration",
unit: "s",
description: "Duration of HTTP server requests.",
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10] });
}
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
* **Breaking change** The `EnableConnectionLevelAttributes` option has been removed.
([#2414](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2414))

* The `db.client.operation.duration` histogram (measured in seconds) produced by
the metrics instrumentation in this package now uses the [Advice API](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.10.0/docs/metrics/customizing-the-sdk/README.md#explicit-bucket-histogram-aggregation)
to set default explicit buckets following the [OpenTelemetry Specification](https://github.com/open-telemetry/semantic-conventions/blob/v1.29.0/docs/database/database-metrics.md).
([#2430](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2430))

## 1.10.0-beta.1

Released 2024-Dec-09
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ internal sealed class SqlActivitySourceHelper
public static readonly string MeterName = AssemblyName.Name!;
public static readonly Meter Meter = new(MeterName, Assembly.GetPackageVersion());

public static readonly Histogram<double> DbClientOperationDuration = Meter.CreateHistogram<double>(
public static readonly Histogram<double> DbClientOperationDuration = Meter.CreateHistogram(
"db.client.operation.duration",
"s",
"Duration of database client operations.");
unit: "s",
description: "Duration of database client operations.",
advice: new InstrumentAdvice<double> { HistogramBucketBoundaries = [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10] });

internal static readonly string[] SharedTagNames =
[
Expand Down
Loading