-
Notifications
You must be signed in to change notification settings - Fork 706
Open
Labels
area: instrumentationRelated to an instrumentation packageRelated to an instrumentation packagebugSomething isn't workingSomething isn't workinginstrumentation: otelhttp
Milestone
Description
Description
otelhttp only uses span.RecordError(err) when errType is not empty
opentelemetry-go-contrib/instrumentation/net/http/otelhttp/transport.go
Lines 132 to 140 in b857249
| if err != nil { | |
| // set error type attribute if the error is part of the predefined | |
| // error types. | |
| // otherwise, record it as an exception | |
| if errType := t.semconv.ErrorType(err); errType.Valid() { | |
| span.SetAttributes(errType) | |
| } else { | |
| span.RecordError(err) | |
| } |
But ErrorType method never returns an empty attribute.
Lines 443 to 458 in b857249
| func (n CurrentHTTPClient) ErrorType(err error) attribute.KeyValue { | |
| t := reflect.TypeOf(err) | |
| var value string | |
| if t.PkgPath() == "" && t.Name() == "" { | |
| // Likely a builtin type. | |
| value = t.String() | |
| } else { | |
| value = fmt.Sprintf("%s.%s", t.PkgPath(), t.Name()) | |
| } | |
| if value == "" { | |
| return semconvNew.ErrorTypeOther | |
| } | |
| return semconvNew.ErrorTypeKey.String(value) | |
| } |
Expected behavior
I don't have a preference on whether we should record error.type with exception.type at the same time. But the comment and the logic here seem conflicted.
Metadata
Metadata
Assignees
Labels
area: instrumentationRelated to an instrumentation packageRelated to an instrumentation packagebugSomething isn't workingSomething isn't workinginstrumentation: otelhttp
Type
Projects
Status
Todo