Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(agent): trace propagation via agent #3328

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading