-
Notifications
You must be signed in to change notification settings - Fork 73
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
feat: send triggering transaction span to application exporter #947
Conversation
3a1950b
to
70f165c
Compare
71b5b1a
to
37b8662
Compare
server/executor/poller_executor.go
Outdated
pe.repeatedTraceSizeCache[trace.ID.String()] = 0 | ||
} | ||
|
||
if pe.repeatedTraceSizeCache[trace.ID.String()] >= 3 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way, we only return true if the number of spans doesn't change after 3 pollings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to remove it from this PR. This solution is too raw to be merged, I'll work on a better approach later.
6a4104b
to
7b3c12b
Compare
server/executor/poller_executor.go
Outdated
@@ -73,7 +73,9 @@ func NewPollerExecutor( | |||
|
|||
func (pe DefaultPollerExecutor) ExecuteRequest(request *PollingRequest) (bool, model.Run, error) { | |||
run := request.run | |||
otelTrace, err := pe.traceDB.GetTraceByID(request.ctx, run.TraceID.String()) | |||
traceId := run.TraceID.String() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: go conventions suggest this should be named traceID
server/executor/trigger/grpc.go
Outdated
@@ -49,15 +57,22 @@ func (te *grpcTriggerer) Trigger(_ context.Context, test model.Test, tid trace.T | |||
if trigger.GRPC == nil { | |||
return response, fmt.Errorf("no settings provided for GRPC triggerer") | |||
} | |||
|
|||
ctx, span := te.tracer.Start(context.Background(), "Tracetest Trigger") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to have the span and ctx set outside the trigger, so each trigger doesn't have to copy/paste this code
server/executor/trigger/http.go
Outdated
otelhttp.WithPropagators(propagators()), | ||
), | ||
} | ||
|
||
ctx, span := te.tracer.Start(ctx, "Tracetest Trigger") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
server/model/json.go
Outdated
Type: r.TriggerResult.Type, | ||
HTTP: r.TriggerResult.HTTP, | ||
GRPC: r.TriggerResult.GRPC, | ||
SpanID: r.TriggerResult.SpanID.String(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to move the spanID/TraceID from the Run to the trigger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We either do this or we pass the pointer to the run so we can set the spanID and traceID to the run instance.
54f7de7
to
33d8e67
Compare
server/executor/trigger/triggerer.go
Outdated
@@ -11,7 +11,7 @@ import ( | |||
) | |||
|
|||
type Triggerer interface { | |||
Trigger(context.Context, model.Test, trace.TraceID, trace.SpanID) (Response, error) | |||
Trigger(context.Context, context.Context, model.Test, trace.TraceID, trace.SpanID) (Response, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really confusing to have 2 contexts here, so it would be great to name these params so we can know what is which
server/executor/trigger/http.go
Outdated
|
||
func (te *httpTriggerer) Trigger(_ context.Context, ctx context.Context, test model.Test, tid trace.TraceID, sid trace.SpanID) (Response, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like the first context should be called ctx
and the 2nd triggerSpanCtx
or something like that
server/executor/trigger/grpc.go
Outdated
|
||
func (te *grpcTriggerer) Trigger(_ context.Context, ctx context.Context, test model.Test, tid trace.TraceID, sid trace.SpanID) (Response, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like the first context should be called ctx
and the 2nd triggerSpanCtx
or something like that
server/executor/trigger/grpc.go
Outdated
@@ -93,6 +88,8 @@ func (te *grpcTriggerer) Trigger(_ context.Context, test model.Test, tid trace.T | |||
marshaller: marshaler, | |||
} | |||
|
|||
propagators().Inject(ctx, NewGRPCHeaderCarrier(&tReq.Metadata)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need a custom carrier? it's probablly easier to do something like:
// see https://pkg.go.dev/go.opentelemetry.io/otel/propagation#MapCarrier
propagators().Inject(ctx, propagators.MapCarrier(tReq.Metadata.Map()))
// where tReq.Metadata.Map() is a func that returns a map of key->values from the metadata
"go.opentelemetry.io/otel/propagation" | ||
) | ||
|
||
type GRPCHeaderCarrier struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this entire implementation and just use https://pkg.go.dev/go.opentelemetry.io/otel/propagation#MapCarrier
server/executor/runner.go
Outdated
@@ -124,13 +127,19 @@ func (r persistentRunner) processExecQueue(job execReq) { | |||
panic(err) | |||
} | |||
|
|||
response, err := triggerer.Trigger(job.ctx, job.test, job.run.TraceID, job.run.SpanID) | |||
triggerSpanCtx, span := r.triggerSpanTracer.Start(context.Background(), "Tracetest trigger") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you move this to the instrumentedTriggerer.Trigger
func, you wouldn't need to use 2 contexts in the Trigger
interface. Given that no trigger type is actually using both contexts, I understand that this is passed just because theinstrumentedTriggerer
doesn't have the triggerSpanTracer
dependency. I'd rather add a dependency to the instrumentedTriggerer
than to have 2 contexts on an interface that aren't actually required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not only that, to do that we either have to:
- Add a pointer to the test run to the Trigger interface
- Change the trigger response object to have both traceID and spanID
Without either of those, we can't update the run object with the correct traceID and spanID.
* send triggering transaction span to application exporter * fix test * fix deploy * change how we generate the triggering transaction span * make sure all tracing tests include an assertion to check for the triggering span * change how to get a tracer * remove assertion for trigger span * fix http trigger span name * send span and change poller condition * fix test * revert parallel change in test * set spanid and traceid in grpc trigger * remove change in the poller process * make the triggering transaction send the span * fix tests * inject context into grpc call * pr changes * refactor * remove grpc carrier Co-authored-by: Sebastian Choren <[email protected]>
This PR makes tracetest send the triggering transaction to the application tracing storage.
Checklist