RecordError marks the span as failed and stores error.type for the duration metric. errType should be a short, low-cardinality string; when empty, ClassifyError(err) supplies a value (one of "context_canceled", "deadline_exceeded", "rpc_error").
(err error, errType string)
| 173 | // when empty, ClassifyError(err) supplies a value (one of |
| 174 | // "context_canceled", "deadline_exceeded", "rpc_error"). |
| 175 | func (s *Span) RecordError(err error, errType string) { |
| 176 | if s == nil || err == nil { |
| 177 | return |
| 178 | } |
| 179 | if errType == "" { |
| 180 | errType = ClassifyError(err) |
| 181 | } |
| 182 | s.mu.Lock() |
| 183 | s.errType = errType |
| 184 | s.mu.Unlock() |
| 185 | s.span.RecordError(err) |
| 186 | s.span.SetStatus(codes.Error, err.Error()) |
| 187 | s.span.SetAttributes(attribute.String("error.type", errType)) |
| 188 | } |
| 189 | |
| 190 | // End closes the span and records the operation duration metric. Safe to |
| 191 | // call multiple times; subsequent calls are no-ops. |
nothing calls this directly
no test coverage detected