Open
Description
Problem Statement
There is no easy way to set error.type (stable) attribute.
Proposed Solution
We can add a helper method to semconv
package:
func 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 ErrorTypeOther
}
return ErrorTypeKey.String(value)
}
Additional Context
Related to: