[FEATURE] Add support for spans instead of span events
Requirements
Currently, the TraceEnricherHook hook creates a span event on the active span. This is in line with the OpenTelemetry semantic convention. However, in some cases, it's preferred to have a span instead of a span event. The hook should take an optional configuration that allows users to opt into a span instead of a span event. The default behavior should remain a span event but this would provide additional flexibility without minimal maintenance effort.
Proposal
- Add an option to the
TraceEnricherHookhook that allows users to choose between span events or spans. It must default to span events if unspecified. - If spans are selected:
- a span is started in the before hook and passed via hook data.
- the span is fetched from hook data, attributes are added, and the span is closed
- If span events are selected:
- a span is NOT created in the before hook
- a span event is added to the current span
I believe this is a duplicate of #541.
What are your thoughts @beeme1mr and @WeihanLi ?
It doesn't look like #541 is the same as this ticket. However, the improvements suggested by @WeihanLi make sense to me.