Skip to content

Commit

Permalink
chore: add sem version to gin-gonic instrumentation (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
reggiemcdonald committed Sep 9, 2020
1 parent abfd550 commit e066389
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions instrumentation/github.com/gin-gonic/gin/gintrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (

"go.opentelemetry.io/otel/codes"

otelcontrib "go.opentelemetry.io/contrib"

otelglobal "go.opentelemetry.io/otel/api/global"
otelpropagation "go.opentelemetry.io/otel/api/propagation"
oteltrace "go.opentelemetry.io/otel/api/trace"
Expand All @@ -46,7 +48,10 @@ func Middleware(service string, opts ...Option) gin.HandlerFunc {
if cfg.TracerProvider == nil {
cfg.TracerProvider = otelglobal.TraceProvider()
}
tracer := cfg.TracerProvider.Tracer(tracerName)
tracer := cfg.TracerProvider.Tracer(
tracerName,
oteltrace.WithInstrumentationVersion(otelcontrib.SemVersion()),
)
if cfg.Propagators == nil {
cfg.Propagators = otelglobal.Propagators()
}
Expand Down Expand Up @@ -98,7 +103,10 @@ func HTML(c *gin.Context, code int, name string, obj interface{}) {
tracer, ok = tracerInterface.(oteltrace.Tracer)
}
if !ok {
tracer = otelglobal.Tracer(tracerName)
tracer = otelglobal.TraceProvider().Tracer(
tracerName,
oteltrace.WithInstrumentationVersion(otelcontrib.SemVersion()),
)
}
savedContext := c.Request.Context()
defer func() {
Expand Down

0 comments on commit e066389

Please sign in to comment.