opentelemetry-js
opentelemetry-js copied to clipboard
Unable to set object as span attribute value
trafficstars
Hi!
I tried setting an object to the value of span attribute, but it’s not working. I checked the OpenTelemetry.js library and found that an object is not a valid attribute type to send. For example, Datadog accepts an object as a span attribute, which is useful because it allows for easy filtering in their APM.
My question: Is there anything stopping from sending an object as an attribute value? Why we can't sent a object as span attribute?
My function to set an attribute to a span:
const setAttribute = (key, value) => {
const activeSpan = trace.getSpan(context.active())
if (activeSpan) {
activeSpan.setAttribute(key, value)
}
}
Thank you!