Skip to content

bb-tracer / bb-logger: annotations and trace ids look valid locally, but on AWS NaN, Infinity and objects are dropped and log entries carry a traceId the local logger never writes #1281

Open

Description

@belaboe

Before opening, please confirm

  • I have searched for duplicate or closed issues.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Which package(s) are affected?

Other (@aws-blocks/bb-tracer, @aws-blocks/bb-logger)

Describe the bug

Tracer annotations. segment.addAnnotation(key, value) in the mock stores whatever it is given. X-Ray keeps only strings, finite numbers and booleans, so on AWS some annotations silently disappear:

Value Local Deployed
1.5, true, a 1,000- or 1,001-character string, null kept kept
NaN, Infinity (both type-check as number) kept as numbers dropped
an object kept dropped

A dashboard or trace filter built on an annotation that is sometimes NaN (for example a computed ratio) works locally and has gaps on AWS.

Trace ids. tracer.getTraceId() returns a random UUID locally and an X-Ray id (1-<8 hex>-<24 hex>) deployed, so code that parses or validates the id, or builds a console link from it, works only on one side.

Logger. On AWS every structured log entry has a traceId field (from _X_AMZN_TRACE_ID); locally the field is absent from every entry, even when the local tracer has an active trace. Log processing that keys on traceId (correlation, grouping) can't be tested locally.

Expected behavior

  • The mock tracer applies X-Ray's annotation rules: drops (and ideally warns about) non-finite numbers and non-primitive values. The AnnotationValue type could also exclude objects.
  • The mock tracer generates ids in the X-Ray format.
  • The local logger adds traceId from the mock tracer's active trace (or a generated X-Ray-format id per request), so entries have the same shape in both environments.

Reproduction steps

const tracer = new Tracer(scope, 'tracer');
const log = new Logger(scope, 'log');

export const api = new ApiNamespace(scope, 'api', () => ({
  async work() {
    await tracer.startSegment('work', async (segment) => {
      segment.addAnnotation('ratio', Number.NaN); // kept locally, dropped on AWS
    });
    log.info('done');                             // entry has traceId on AWS only
    return tracer.getTraceId();                   // UUID locally, "1-…-…" on AWS
  },
}));

Environment

  • @aws-blocks/* 0.8.0 (main at 34e758c)
  • Local: npm run dev dev server, Node 22, macOS
  • Deployed: a sandbox stack in us-east-1

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-maintainer-responseWaiting on a response from the maintainerspending-triageIssue is pending triage by the maintainers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions