Ability to set error event metadata when using withSpan
When using swift-distributing-tracing with the withSpan methods, you get the benefit of having recordError automatically being called on the span if an error was raised. However, you do not get the opportunity to annotate the error event attributes. In particular, OpenTelemetry has specific attributes that should be set of the error event attributes. There's no easy way for those to be set currently, and an adopter needs to drop down to catching the error and calling recordError manually.
We could consider adding some hook or exposing some metadata to recordError to make this specific information available to the implementers of a Tracer backend.
This might potentially look something like this:
try withSpan { span in
throw CancellationError()
}
onError: { error, span in
// Modify the span
}
and/or we could introduce a new protocol that errors could conform to that allows them to add additional context to the span