Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: SpanOptions.tags doesn't handle nested objects #5058

Open
Maxime-Reiz opened this issue Dec 27, 2024 · 0 comments
Open

[BUG]: SpanOptions.tags doesn't handle nested objects #5058

Maxime-Reiz opened this issue Dec 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Maxime-Reiz
Copy link

Maxime-Reiz commented Dec 27, 2024

Tracer Version(s)

5.29.0

Node.js Version(s)

22.12.0

Bug Report

Issue Description

I want to create a trace in Datadog with nested business tags using the tags property of the SpanOptions in the tracer. While the tags documentation suggests we can provide any value (e.g., nested objects), my nested objects are not fully displayed in the span overview. Only up to two levels of nesting are visible.

// Tags documentation in SDK
export interface SpanOptions {
    /**
     * set of key-value pairs which will be set as tags on the newly created
     * Span. Ownership of the object is passed to the created span for
     * efficiency reasons (the caller should not modify this object after
     * calling startSpan).
     */
    tags?: { [key: string]: any };
}

Expected behaviour

The span overview in Datadog should display all levels of nested tags. For example:

// > Span > Overview > Span Attributes
{
   key1: value1,
   key2: value2,
   process: {
      priority: 'high',
      payload: {
         businessKey1: value1,
         businessKey2: value2,
         businessKey3: value3,
      }
   }
}

Actual behaviour

The span overview in Datadog only displays up to two levels of nesting:

// > Span > Overview > Span Attributes
{
   key1: value1,
   key2: value2,
   process: {
      priority: 'high',
   }
}

Code to reproduce

Current Code:

import tracer from 'dd-trace'

// [...]

const priority = 'high'
const payload = {
         businessKey1: value1,
         businessKey2: value2,
         businessKey3: value3,
      }
const process = { priority, payload }
return tracer.trace(
        'my-process-name',
        { tags: { process } },
        async () => {...}
)

Other attempt, working with one less level of nesting:

import tracer from 'dd-trace'

// [...]

const priority = 'high'
const payload = {
         businessKey1: value1,
         businessKey2: value2,
         businessKey3: value3,
      }
const process = { priority, payload }
return tracer.trace(
        'my-process-name',
        { tags: { ...process } },
        async () => {...}
)

Output of other attempt:

// > Span > Overview > Span Attributes
{
   key1: value1,
   key2: value2,
   priority: 'high',
   payload: {
      businessKey1: value1,
      businessKey2: value2,
      businessKey3: value3,
   }
}

Request

Can you clarify:

  1. Is this behavior expected, or is it a bug in the SDK?
  2. If expected, is there a recommended approach to include deeply nested tags in the span overview?

Thank you for your help!

Reproduction Code

No response

Error Logs

No response

Tracer Config

No response

Operating System

No response

Bundling

Webpack

@Maxime-Reiz Maxime-Reiz added the bug Something isn't working label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant