Skip to content

Commit e762e37

Browse files
dmerrickclaude
andcommitted
chore(telemetry): drop http_server body-size histograms via OTel views
The http.server.{request,response}.body.size histograms are auto-instrumented by otelhttp and pushed OTLP-direct to Grafana Cloud (bypassing Alloy), so they can't be dropped with a chart-side relabel. They account for ~700 active series and back no panels. Register sdkmetric.NewView for each, applying AggregationDrop{}, on the OTLP MeterProvider. The http.server.request.duration histogram is left untouched — its buckets back the p50/p95/p99 latency panels. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent de5cc53 commit e762e37

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

pkg/telemetry/telemetry.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ func Init(ctx context.Context, serviceName, serviceVersion string) (ShutdownFunc
8383
if err != nil {
8484
return noopShutdown, fmt.Errorf("prometheus exporter: %w", err)
8585
}
86-
mp := sdkmetric.NewMeterProvider(
86+
mpOpts := []sdkmetric.Option{
8787
sdkmetric.WithReader(sdkmetric.NewPeriodicReader(metricExp)),
8888
sdkmetric.WithReader(promExp),
8989
sdkmetric.WithResource(res),
90-
)
90+
}
91+
mpOpts = append(mpOpts, dropBodySizeHistograms()...)
92+
mp := sdkmetric.NewMeterProvider(mpOpts...)
9193
otel.SetMeterProvider(mp)
9294

9395
if err := otelruntime.Start(otelruntime.WithMinimumReadMemStatsInterval(15 * time.Second)); err != nil {
@@ -141,6 +143,26 @@ func Init(ctx context.Context, serviceName, serviceVersion string) (ShutdownFunc
141143
}, nil
142144
}
143145

146+
// dropBodySizeHistograms returns MeterProvider options that drop the
147+
// http_server_{request,response}_body_size_bytes histograms via OTel SDK
148+
// views. These auto-instrumented histograms are pushed OTLP-direct to the
149+
// metrics backend (bypassing Alloy, so they can't be relabeled chart-side)
150+
// and account for ~700 active series with no panels reading them. The
151+
// http_server_request_duration_seconds histogram is deliberately left
152+
// untouched — its buckets back the p50/p95/p99 latency panels.
153+
func dropBodySizeHistograms() []sdkmetric.Option {
154+
drop := func(name string) sdkmetric.Option {
155+
return sdkmetric.WithView(sdkmetric.NewView(
156+
sdkmetric.Instrument{Name: name},
157+
sdkmetric.Stream{Aggregation: sdkmetric.AggregationDrop{}},
158+
))
159+
}
160+
return []sdkmetric.Option{
161+
drop("http.server.request.body.size"),
162+
drop("http.server.response.body.size"),
163+
}
164+
}
165+
144166
func disabled() bool {
145167
switch strings.ToLower(os.Getenv("OTEL_SDK_DISABLED")) {
146168
case "true", "1", "yes":

0 commit comments

Comments
 (0)