Adds a central utility for attaching values to Spans. This has several benefits over using WeakConcurrentHashmaps all over the place:
All SpanValues share a single weak-concurrent hashmap, which means less WeakReferences need to be allocated and managed
In our agent we could use an approach which can even get rid of that map and provide almost the same performance as direct fields (see the TODO in SpanValue)
We have the "ugly" management in a single place and can easily replace it when something better is available via the OTel SDK
An example use case for this would be for the accumulator of our breaking down metrics which needs to be attached to the local root span.
In addition, based on these SpanValues a utility for gaining access to the local-root-span of any given span is added in this PR. This is to showcase the usage and the utility will also be needed for #44 .
Adds a central utility for attaching values to Spans. This has several benefits over using
WeakConcurrentHashmaps
all over the place:SpanValues
share a single weak-concurrent hashmap, which means lessWeakReference
s need to be allocated and managedSpanValue
)We have the "ugly" management in a single place and can easily replace it when something better is available via the OTel SDK
An example use case for this would be for the accumulator of our breaking down metrics which needs to be attached to the local root span.
In addition, based on these
SpanValue
s a utility for gaining access to the local-root-span of any given span is added in this PR. This is to showcase the usage and the utility will also be needed for #44 .