opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

Add support of Number type into Span.setAttribute(Spring, Number)

Open RuslanHryn opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe.

Currently Span class supports only primitive number types such as long, double, int. It would be nice to have the support of the Number class because it will simplify the use of wrapper classes. It will not be necessary to cast wrappers to primitive types. Also, this casting may lead to precision loss.

Describe the solution you'd like

Have the following method setAttribute(Spring, Number) in the Span class to be able to set wrapper types without casting to primitives.

Describe alternatives you've considered

No response

Additional context

No response

RuslanHryn avatar Oct 20 '23 09:10 RuslanHryn

Transferred issue to opentelemetry-java since this repository contains the Span class.

jack-berg avatar Nov 01 '23 16:11 jack-berg

Our support for numbers (long, double, int) are only primitives, so we'd have to figure out what type the number is and cast down to the primitive type.

jkwatson avatar Nov 01 '23 19:11 jkwatson

I think this is problematic for the reason @jkwatson described and for the precision problem that the submitter raised. Still might be possible. I wonder if it also raises a question about symmetry on the receiving/getting side.

breedx-splk avatar Jan 26 '24 00:01 breedx-splk