Skip to content

Commit 39d173f

Browse files
committed
fix: Add additional tests for v1 and squash some bugs
- Added additional test cases Fixes: - Added missing setting of DisableUpdateTracing for `Options()` - Add safe type safe assertions to avoid panics - Fix temporal. prefix setting
1 parent eab8fa1 commit 39d173f

File tree

2 files changed

+748
-3
lines changed

2 files changed

+748
-3
lines changed

contrib/datadog/tracing/interceptor.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func (t *tracerImpl) Options() interceptor.TracerOptions {
8484
HeaderKey: headerKey,
8585
DisableSignalTracing: t.opts.DisableSignalTracing,
8686
DisableQueryTracing: t.opts.DisableQueryTracing,
87+
DisableUpdateTracing: t.opts.DisableUpdateTracing,
8788
}
8889
}
8990

@@ -103,7 +104,11 @@ func (t *tracerImpl) UnmarshalSpan(m map[string]string) (interceptor.TracerSpanR
103104

104105
func (t *tracerImpl) MarshalSpan(span interceptor.TracerSpan) (map[string]string, error) {
105106
carrier := tracer.TextMapCarrier{}
106-
if err := tracer.Inject(span.(*tracerSpan).Context(), carrier); err != nil {
107+
tSpan, ok := span.(*tracerSpan)
108+
if !ok {
109+
return nil, fmt.Errorf("expected *tracerSpan, got %T", span)
110+
}
111+
if err := tracer.Inject(tSpan.Context(), &carrier); err != nil {
107112
return nil, err
108113
}
109114
return carrier, nil
@@ -118,7 +123,11 @@ func (t *tracerImpl) SpanFromContext(ctx context.Context) interceptor.TracerSpan
118123
}
119124

120125
func (t *tracerImpl) ContextWithSpan(ctx context.Context, span interceptor.TracerSpan) context.Context {
121-
return tracer.ContextWithSpan(ctx, span.(*tracerSpan).Span)
126+
tSpan, ok := span.(*tracerSpan)
127+
if !ok {
128+
return ctx
129+
}
130+
return tracer.ContextWithSpan(ctx, tSpan.Span)
122131
}
123132

124133
// SpanFromWorkflowContext extracts the DataDog Span object from the workflow context.
@@ -182,7 +191,7 @@ func (t *tracerImpl) StartSpan(options *interceptor.TracerStartSpanOptions) (int
182191
for k, v := range options.Tags {
183192
// TODO when custom span support is added we might have to revisit this
184193
// Display Temporal tags in a nested group in Datadog APM
185-
tagKey := "temporal." + strings.TrimPrefix(k, "temporal")
194+
tagKey := fmt.Sprintf("temporal.%s", strings.TrimPrefix(k, "temporal."))
186195
startOpts = append(startOpts, tracer.Tag(tagKey, v))
187196
}
188197

0 commit comments

Comments
 (0)