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

patch-console.ts preserves json formatted logs as json format. #628

Open
abroom opened this issue Mar 3, 2025 · 0 comments
Open

patch-console.ts preserves json formatted logs as json format. #628

abroom opened this issue Mar 3, 2025 · 0 comments

Comments

@abroom
Copy link

abroom commented Mar 3, 2025

Expected Behavior

patch-console.ts adds dd key and value to the log if it is json formatted (and possibly only if log args are length 1 too?).

  dd: {
    trace_id: traceId
    span_id: parentId
  }

Actual Behavior

Converts json object to a string representation and prefixes with [dd.trace_id=${traceId} dd.span_id=${parentId}], resulting in loss of datadog json log functionality.

Steps to Reproduce the Problem

  1. Send a json formatted log
  2. View the log in datadog and see that it has turned into a string representation in the message and unable to use datadog json parsing features

Workaround

  1. Turn off log injection with environmental variable: DD_LOGS_INJECTION: false
  2. Import dd-trace from lambda layer
  3. Set dd key and value
    const context = tracer.scope().active()?.context();
    const log = {
      dd: {
        trace_id: context?.toTraceId(),
        span_id: context?.toSpanId(),
      },
      // ... other log keys and values
    };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant