Skip to content

Commit

Permalink
fix(agent): trace propagation via agent (#3328)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathnogueira authored Nov 1, 2023
1 parent e6882fa commit e7e8d21
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
18 changes: 0 additions & 18 deletions agent/workers/trigger/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/goware/urlx"
"github.com/kubeshop/tracetest/server/test/trigger"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
)

func HTTP() Triggerer {
Expand All @@ -38,22 +37,6 @@ func httpClient(sslVerification bool) http.Client {
}
}

func newSpanContext(ctx context.Context) trace.SpanContext {
spanCtx := trace.SpanContextFromContext(ctx)
tid := spanCtx.TraceID()
sid := spanCtx.SpanID()

tracestate, _ := trace.ParseTraceState("tracetest=true")
var tf trace.TraceFlags
return trace.NewSpanContext(trace.SpanContextConfig{
TraceID: tid,
SpanID: sid,
TraceFlags: tf.WithSampled(true),
TraceState: tracestate,
Remote: true,
})
}

func (te *httpTriggerer) Trigger(ctx context.Context, triggerConfig trigger.Trigger, opts *Options) (Response, error) {
response := Response{
Result: trigger.TriggerResult{
Expand All @@ -67,7 +50,6 @@ func (te *httpTriggerer) Trigger(ctx context.Context, triggerConfig trigger.Trig

client := httpClient(triggerConfig.HTTP.SSLVerification)

ctx = trace.ContextWithSpanContext(ctx, newSpanContext(ctx))
ctx, cncl := context.WithTimeout(ctx, 30*time.Second)
defer cncl()

Expand Down
3 changes: 3 additions & 0 deletions agent/workers/trigger/instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ func (t *instrumentedTriggerer) Trigger(ctx context.Context, triggerConfig trigg
return Response{}, fmt.Errorf("could not create tracestate: %w", err)
}

var tf trace.TraceFlags
spanContextConfig := trace.SpanContextConfig{
TraceState: tracestate,
Remote: true,
TraceFlags: tf.WithSampled(true),
}

if opts != nil {
Expand Down

0 comments on commit e7e8d21

Please sign in to comment.