Skip to content

Commit

Permalink
fix semconv changes [goreleaser]
Browse files Browse the repository at this point in the history
  • Loading branch information
trajan0x committed Jul 6, 2024
1 parent 3427d97 commit a41b903
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/metrics/instrumentation/otelginmetrics/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func defaultConfig() *config {

var DefaultAttributes = func(serverName, route string, request *http.Request) []attribute.KeyValue {
attrs := []attribute.KeyValue{
semconv.HTTPMethodKey.String(request.Method),
semconv.HTTPRequestMethodKey.String(request.Method),

Check warning on line 35 in core/metrics/instrumentation/otelginmetrics/config.go

View check run for this annotation

Codecov / codecov/patch

core/metrics/instrumentation/otelginmetrics/config.go#L35

Added line #L35 was not covered by tests
}

if serverName != "" {
Expand Down
5 changes: 4 additions & 1 deletion core/metrics/instrumentation/otelginmetrics/middleware.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package otelginmetrics

import (
"go.opentelemetry.io/otel/attribute"
"net/http"
"time"

"github.com/gin-gonic/gin"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
)

const statusKey = attribute.Key("http.status_code")

// Middleware returns middleware that will trace incoming requests.
// The service parameter should describe the name of the (virtual)
// server handling the request.
Expand Down Expand Up @@ -47,7 +50,7 @@ func Middleware(service string, options ...Option) gin.HandlerFunc {

if cfg.groupedStatus {
code := int(ginCtx.Writer.Status()/100) * 100
resAttributes = append(resAttributes, semconv.HTTPStatusCodeKey.Int(code))
resAttributes = append(resAttributes, statusKey.Int(code))

Check warning on line 53 in core/metrics/instrumentation/otelginmetrics/middleware.go

View check run for this annotation

Codecov / codecov/patch

core/metrics/instrumentation/otelginmetrics/middleware.go#L53

Added line #L53 was not covered by tests
} else {
resAttributes = append(resAttributes, semconv.HTTPResponseStatusCodeKey.Int(ginCtx.Writer.Status()))
}
Expand Down

0 comments on commit a41b903

Please sign in to comment.