Skip to content

Commit

Permalink
otelhttp: set unit and description on all instruments
Browse files Browse the repository at this point in the history
  • Loading branch information
ash2k committed Oct 31, 2023
1 parent cff1423 commit 14124df
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions instrumentation/net/http/otelhttp/handler.go
Expand Up @@ -107,13 +107,16 @@ func (h *middleware) createMeasures() {
h.counters = make(map[string]metric.Int64Counter)
h.valueRecorders = make(map[string]metric.Float64Histogram)

requestBytesCounter, err := h.meter.Int64Counter(RequestContentLength)
requestBytesCounter, err := h.meter.Int64Counter(RequestContentLength, metric.WithUnit("By"),
metric.WithDescription("Measures the size of HTTP request content length (uncompressed)"))
handleErr(err)

responseBytesCounter, err := h.meter.Int64Counter(ResponseContentLength)
responseBytesCounter, err := h.meter.Int64Counter(ResponseContentLength, metric.WithUnit("By"),
metric.WithDescription("Measures the size of HTTP response content length (uncompressed)"))
handleErr(err)

serverLatencyMeasure, err := h.meter.Float64Histogram(ServerLatency, metric.WithUnit("ms"))
serverLatencyMeasure, err := h.meter.Float64Histogram(ServerLatency, metric.WithUnit("ms"),
metric.WithDescription("Measures the duration of HTTP request handling"))
handleErr(err)

h.counters[RequestContentLength] = requestBytesCounter
Expand Down

0 comments on commit 14124df

Please sign in to comment.