-
Notifications
You must be signed in to change notification settings - Fork 261
OpenTelemetry: Specify span kind and don't set error type for benign exception #2048
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
c2bb055
b637997
72a76d4
23c7bf1
f17f8b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ package opentelemetry | |
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
|
|
||
| "go.opentelemetry.io/otel" | ||
|
|
@@ -14,6 +15,7 @@ import ( | |
|
|
||
| "go.temporal.io/sdk/interceptor" | ||
| "go.temporal.io/sdk/log" | ||
| "go.temporal.io/sdk/temporal" | ||
| ) | ||
|
|
||
| // DefaultTextMapPropagator is the default OpenTelemetry TextMapPropagator used | ||
|
|
@@ -196,8 +198,13 @@ func (t *tracer) StartSpan(opts *interceptor.TracerStartSpanOptions) (intercepto | |
| } | ||
| } | ||
|
|
||
| spanKind := trace.SpanKindServer | ||
| if opts.Outbound { | ||
| spanKind = trace.SpanKindClient | ||
| } | ||
|
|
||
| // Create span | ||
| span := t.options.SpanStarter(ctx, t.options.Tracer, opts.Operation+":"+opts.Name, trace.WithTimestamp(opts.Time)) | ||
| span := t.options.SpanStarter(ctx, t.options.Tracer, opts.Operation+":"+opts.Name, trace.WithTimestamp(opts.Time), trace.WithSpanKind(spanKind)) | ||
|
|
||
| // Set tags | ||
| if len(opts.Tags) > 0 { | ||
|
|
@@ -241,12 +248,22 @@ type tracerSpan struct { | |
| } | ||
|
|
||
| func (t *tracerSpan) Finish(opts *interceptor.TracerFinishSpanOptions) { | ||
| if opts.Error != nil { | ||
| if opts.Error != nil && !isBenignApplicationError(opts.Error) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think our implementation may not have been doing the right thing here because we are not calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the godoc of |
||
| t.SetStatus(codes.Error, opts.Error.Error()) | ||
| } | ||
| t.End() | ||
| } | ||
|
|
||
| func isBenignApplicationError(err error) bool { | ||
| var appErr *temporal.ApplicationError | ||
| if temporal.IsApplicationError(err) { | ||
| if errors.As(err, &appErr) { | ||
yuandrew marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return appErr.Category() == temporal.ApplicationErrorCategoryBenign | ||
| } | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| type textMapCarrier map[string]string | ||
|
|
||
| func (t textMapCarrier) Get(key string) string { return t[key] } | ||
|
|
||
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.
Does this line up roughly with what other SDKs like dotnet or python do?
Uh oh!
There was an error while loading. Please reload this page.
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 so (though I think I just spotted a bug in Python for outbound signal child workflow)
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.
should be,
see https://github.com/temporalio/sdk-python/blob/ba3d50f750ea8e1219eb30234a3a9d6a58572351/temporalio/contrib/opentelemetry.py#L345
https://github.com/temporalio/sdk-dotnet/blob/092ed33e3a2bacf59ec10d93b13bd0d7a8861e22/src/Temporalio.Extensions.OpenTelemetry/TracingInterceptor.cs#L759