Skip to content

Commit

Permalink
unite traceid
Browse files Browse the repository at this point in the history
Signed-off-by: jyjiangkai <[email protected]>
  • Loading branch information
hwjiangkai committed Jul 13, 2023
1 parent 24da846 commit 562d119
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (ga *ceGateway) receive(ctx context.Context, event v2.Event) (re *v2.Event,
ctx, span := ga.tracer.Start(ctx, "receive")
defer span.End()

event.SetExtension("spancontext", ctx)
event.SetExtension("traceid", span.SpanContext().TraceID().String())
span.SetName("EventTracing")
span.SetAttributes(attribute.String("event_id", event.ID()))
span.AddEvent("received from source", trace.WithTimestamp(time.Now()))
Expand Down
12 changes: 6 additions & 6 deletions internal/trigger/reader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ func (elReader *eventlogReader) newSpan(ctx context.Context, event ce.Event) (co
if event.Extensions() == nil {
return elReader.config.Tracer.Start(ctx, event.ID())
}
if _, ok := event.Extensions()["spancontext"]; !ok {
if _, ok := event.Extensions()["traceid"]; !ok {
return elReader.config.Tracer.Start(ctx, event.ID())
}
var spanCtx context.Context
if err := event.ExtensionAs("spancontext", &spanCtx); err != nil {
return elReader.config.Tracer.Start(ctx, event.ID())
}
return elReader.config.Tracer.Start(spanCtx, event.ID())
traceid, _ := trace.TraceIDFromHex(event.Extensions()["traceid"].(string))
_ctx := trace.ContextWithSpanContext(ctx, trace.NewSpanContext(trace.SpanContextConfig{
TraceID: traceid,
}))
return elReader.config.Tracer.Start(_ctx, event.ID())
}

func (elReader *eventlogReader) putEvent(ctx context.Context, event info.EventRecord) error {
Expand Down

0 comments on commit 562d119

Please sign in to comment.