diff --git a/CHANGELOG.md b/CHANGELOG.md index e5783ad2f..bd5fb2282 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Add `go.opentelemetry.io/otel/semconv/v1.41.0` package. The package contains semantic conventions from the `v1.41.0` version of the OpenTelemetry Semantic Conventions. See the [migration documentation](./semconv/v1.41.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.40.0`. (#8324) +- Generate explicit histogram bucket boundaries from weaver configuration for HTTP and RPC duration instruments in `go.opentelemetry.io/otel/semconv/v1.41.0`. (#8002) ### Changed diff --git a/semconv/templates/registry/go/metric.go.j2 b/semconv/templates/registry/go/metric.go.j2 index 679ddfcaa..4bfced571 100644 --- a/semconv/templates/registry/go/metric.go.j2 +++ b/semconv/templates/registry/go/metric.go.j2 @@ -53,6 +53,7 @@ var ( {%- for metric in ctx.metrics %} {%- set metric_name = h.to_go_name(metric.metric_name, ctx.root_namespace) %} {%- set metric_inst = metric.metric_name | map_text("instrument", i.instrument_default(metric)) %} +{%- set metric_bucket_boundaries = metric.metric_name | map_text("custom_bucket_boundaries", "") %} {{ h.metric_typedoc(metric, ctx.root_namespace) | comment | trim }} type {{ metric_name }} struct { @@ -62,6 +63,9 @@ type {{ metric_name }} struct { var new{{ metric_name }}Opts = []metric.{{ metric_inst }}Option{ metric.WithDescription("{{ i.desc(metric) }}"), metric.WithUnit("{{metric.unit}}"), +{%- if metric.instrument == "histogram" and metric_bucket_boundaries != "" %} + metric.WithExplicitBucketBoundaries({{ metric_bucket_boundaries }}...), +{%- endif %} } {{ ["New" ~ metric_name ~ " returns a new " ~ metric_name ~ " instrument."] | comment }} diff --git a/semconv/templates/registry/go/weaver.yaml b/semconv/templates/registry/go/weaver.yaml index 814793616..66368f5cf 100644 --- a/semconv/templates/registry/go/weaver.yaml +++ b/semconv/templates/registry/go/weaver.yaml @@ -86,6 +86,11 @@ text_maps: system.memory.usage: Int64ObservableUpDownCounter system.memory.utilization: Float64ObservableGauge system.network.io: Int64ObservableCounter + custom_bucket_boundaries: + http.client.request.duration: "[]float64{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}" + http.server.request.duration: "[]float64{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}" + rpc.client.call.duration: "[]float64{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}" + rpc.server.call.duration: "[]float64{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}" acronyms: - ACL - AI diff --git a/semconv/v1.41.0/httpconv/metric.go b/semconv/v1.41.0/httpconv/metric.go index 550abba38..0fa5cc074 100644 --- a/semconv/v1.41.0/httpconv/metric.go +++ b/semconv/v1.41.0/httpconv/metric.go @@ -739,6 +739,7 @@ type ClientRequestDuration struct { var newClientRequestDurationOpts = []metric.Float64HistogramOption{ metric.WithDescription("Duration of HTTP client requests."), metric.WithUnit("s"), + metric.WithExplicitBucketBoundaries([]float64{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}...), } // NewClientRequestDuration returns a new ClientRequestDuration instrument. @@ -1450,6 +1451,7 @@ type ServerRequestDuration struct { var newServerRequestDurationOpts = []metric.Float64HistogramOption{ metric.WithDescription("Duration of HTTP server requests."), metric.WithUnit("s"), + metric.WithExplicitBucketBoundaries([]float64{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}...), } // NewServerRequestDuration returns a new ServerRequestDuration instrument. diff --git a/semconv/v1.41.0/rpcconv/metric.go b/semconv/v1.41.0/rpcconv/metric.go index 1bb450554..5799539ef 100644 --- a/semconv/v1.41.0/rpcconv/metric.go +++ b/semconv/v1.41.0/rpcconv/metric.go @@ -65,6 +65,7 @@ type ClientCallDuration struct { var newClientCallDurationOpts = []metric.Float64HistogramOption{ metric.WithDescription("Measures the duration of an outgoing Remote Procedure Call (RPC)."), metric.WithUnit("s"), + metric.WithExplicitBucketBoundaries([]float64{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}...), } // NewClientCallDuration returns a new ClientCallDuration instrument. @@ -223,6 +224,7 @@ type ServerCallDuration struct { var newServerCallDurationOpts = []metric.Float64HistogramOption{ metric.WithDescription("Measures the duration of an incoming Remote Procedure Call (RPC)."), metric.WithUnit("s"), + metric.WithExplicitBucketBoundaries([]float64{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}...), } // NewServerCallDuration returns a new ServerCallDuration instrument.