Skip to content

Commit

Permalink
modified otel-http-server-duration from microseconds to milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
To committed Nov 3, 2021
1 parent 6c86403 commit b23dca3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions instrumentation/net/http/otelhttp/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Handler struct {
filters []Filter
spanNameFormatter func(string, *http.Request) string
counters map[string]metric.Int64Counter
valueRecorders map[string]metric.Int64Histogram
valueRecorders map[string]metric.Float64Histogram
}

func defaultHandlerFormatter(operation string, _ *http.Request) string {
Expand Down Expand Up @@ -94,15 +94,15 @@ func handleErr(err error) {

func (h *Handler) createMeasures() {
h.counters = make(map[string]metric.Int64Counter)
h.valueRecorders = make(map[string]metric.Int64Histogram)
h.valueRecorders = make(map[string]metric.Float64Histogram)

requestBytesCounter, err := h.meter.NewInt64Counter(RequestContentLength)
handleErr(err)

responseBytesCounter, err := h.meter.NewInt64Counter(ResponseContentLength)
handleErr(err)

serverLatencyMeasure, err := h.meter.NewInt64Histogram(ServerLatency)
serverLatencyMeasure, err := h.meter.NewFloat64Histogram(ServerLatency)
handleErr(err)

h.counters[RequestContentLength] = requestBytesCounter
Expand Down Expand Up @@ -195,7 +195,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.counters[RequestContentLength].Add(ctx, bw.read, attributes...)
h.counters[ResponseContentLength].Add(ctx, rww.written, attributes...)

elapsedTime := time.Since(requestStartTime).Microseconds()
elapsedTime := float64(time.Since(requestStartTime)) / float64(time.Millisecond)

h.valueRecorders[ServerLatency].Record(ctx, elapsedTime, attributes...)
}
Expand Down

0 comments on commit b23dca3

Please sign in to comment.