Skip to content

Pino integration omits scope tags from captured logs #21218

@sentry-junior

Description

@sentry-junior

Scope tags set via scope.setTag() (including Sentry.getIsolationScope().setTag()) are not included in logs captured by the Pino integration. Only scope attributes (set via scope.setAttribute()) and user fields (id, email, username) are propagated to log envelopes.

Root cause

In _INTERNAL_captureLog (packages/core/src/logs/internal.ts), getCombinedScopeData() is called but only user and attributes are destructured — tags is ignored:

const {
  user: { id, email, username },
  attributes: scopeAttributes = {},
} = getCombinedScopeData(getIsolationScope(), currentScope);

The tags field from ScopeData is never merged into the log's attributes before the envelope is sent. This is inconsistent with error capturing, where captureException/captureMessage run through the full scope pipeline and include tags.

Impact

  • Any tag set via Sentry.setTag(), scope.setTag(), or getIsolationScope().setTag() is silently dropped for log events.
  • This affects all integrations that call _INTERNAL_captureLog, including the Pino, Winston, and console integrations.

Workaround

Use scope.setAttribute() / getIsolationScope().setAttribute() instead of setTag() for values that need to appear on logs.

Expected behavior

Scope tags should be included in captured log attributes, consistent with how they are applied to error events.

Action taken on behalf of Kyle Tryon.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions