Skip to content

Commit

Permalink
Merge pull request #71 from lyt122/bugfix
Browse files Browse the repository at this point in the history
bugfix:fix the traceid cannot be shown in the response
  • Loading branch information
CocaineCong authored Mar 3, 2024
2 parents 17afc7e + d6a554d commit 6a125d2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package tracing

import (
"context"
"github.com/gin-gonic/gin"

"go.opentelemetry.io/otel/trace"

Expand Down Expand Up @@ -68,8 +69,8 @@ func newResource(serviceName string) *resource.Resource {
)
}

func GetTraceID(ctx context.Context) string {
spanCtx := trace.SpanContextFromContext(ctx)
func GetTraceID(ctx *gin.Context) string {
spanCtx := trace.SpanContextFromContext(ctx.Request.Context())
if spanCtx.HasTraceID() {
traceID := spanCtx.TraceID()
return traceID.String()
Expand Down

0 comments on commit 6a125d2

Please sign in to comment.