Skip to content

Commit

Permalink
revert back recreating incoming and outgoing contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
purnesh42H committed Nov 20, 2024
1 parent 2540965 commit 4f77441
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions stats/opentelemetry/internal/tracing/carrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,18 @@ type Carrier struct {
direction propagationDirection
}

// NewIncomingCarrier creates a new Carrier with the incoming context from the
// given context and incoming propagation direction. The incoming carrier
// should be used with propagator's `Extract()` method.
// NewIncomingCarrier creates a new Carrier with the given context and incoming
// propagation direction. The incoming carrier should be used with propagator's
// `Extract()` method.
func NewIncomingCarrier(ctx context.Context) *Carrier {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return &Carrier{ctx: metadata.NewIncomingContext(ctx, metadata.MD{}), direction: incoming}
}
return &Carrier{ctx: metadata.NewIncomingContext(ctx, md), direction: incoming}
return &Carrier{ctx: ctx, direction: incoming}
}

// NewOutgoingCarrier creates a new Carrier with the outgoing context from the
// given context and outgoing propagation direction. The outgoing carrier
// should be used with propagator's `Inject()` method.
// NewOutgoingCarrier creates a new Carrier with the given context and outgoing
// propagation direction. The outgoing carrier should be used with propagator's
// `Inject()` method.
func NewOutgoingCarrier(ctx context.Context) *Carrier {
md, ok := metadata.FromOutgoingContext(ctx)
if !ok {
return &Carrier{ctx: metadata.NewOutgoingContext(ctx, metadata.MD{}), direction: outgoing}
}
return &Carrier{ctx: metadata.NewOutgoingContext(ctx, md), direction: outgoing}
return &Carrier{ctx: ctx, direction: outgoing}
}

// Get returns the string value associated with the passed key from the
Expand Down

0 comments on commit 4f77441

Please sign in to comment.