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

Unable to set object as span attribute value

Open wolff453 opened this issue 1 year ago • 1 comments
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?

image

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!

wolff453 avatar Jul 17 '24 20:07 wolff453