Skip to content

Commit

Permalink
remove unnecessary []metric.AddOption
Browse files Browse the repository at this point in the history
  • Loading branch information
VinozzZ committed Sep 5, 2024
1 parent b99f0da commit 54876b8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions instrumentation/net/http/otelhttp/internal/semconv/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ func (s HTTPServer) RecordMetrics(ctx context.Context, md ServerMetricData) {

attributes := oldHTTPServer{}.MetricAttributes(md.ServerName, md.Req, md.StatusCode, md.AdditionalAttributes)
o := metric.WithAttributeSet(attribute.NewSet(attributes...))
addOpts := []metric.AddOption{o} // Allocate vararg slice once.
s.requestBytesCounter.Add(ctx, md.RequestSize, addOpts...)
s.responseBytesCounter.Add(ctx, md.ResponseSize, addOpts...)
addOpts := metric.AddOption(o)
s.requestBytesCounter.Add(ctx, md.RequestSize, addOpts)
s.responseBytesCounter.Add(ctx, md.ResponseSize, addOpts)
s.serverLatencyMeasure.Record(ctx, md.ElapsedTime, o)

// TODO: Duplicate Metrics
Expand Down Expand Up @@ -183,14 +183,14 @@ func (c HTTPClient) ErrorType(err error) attribute.KeyValue {

type MetricOpts struct {
measurement metric.MeasurementOption
addOptions []metric.AddOption
addOptions metric.AddOption
}

func (o MetricOpts) MeasurementOption() metric.MeasurementOption {
return o.measurement
}

func (o MetricOpts) AddOptions() []metric.AddOption {
func (o MetricOpts) AddOptions() metric.AddOption {
return o.addOptions
}

Expand All @@ -200,7 +200,7 @@ func (c HTTPClient) MetricOptions(ma MetricAttributes) MetricOpts {
set := metric.WithAttributeSet(attribute.NewSet(attributes...))
return MetricOpts{
measurement: set,
addOptions: []metric.AddOption{set},
addOptions: set,
}
}

Expand All @@ -210,7 +210,7 @@ func (s HTTPClient) RecordMetrics(ctx context.Context, md MetricData, opts Metri
return
}

s.requestBytesCounter.Add(ctx, md.RequestSize, opts.AddOptions()...)
s.requestBytesCounter.Add(ctx, md.RequestSize, opts.AddOptions())
s.latencyMeasure.Record(ctx, md.ElapsedTime, opts.MeasurementOption())

// TODO: Duplicate Metrics
Expand Down

0 comments on commit 54876b8

Please sign in to comment.