Skip to content

Unexpected ANSI color codes appearing in the severityText field #2952

@mznet

Description

@mznet

What version of OpenTelemetry are you using?

@opentelemetry/[email protected]

What version of Node are you using?

v18.20.7

What did you do?

An example application prints logs at three different levels. In the OpenTelemetry logs emitted by this application, the severityText field contains both the log level and ANSI color codes—for example, \x1B[32minfo\x1B[39m, which represents the word “info” in green. Since severityText contains ANSI color codes, it’s difficult to search logs by log level.

OTLPExportDelegate items to be sent [ ...
LogRecordImpl {
    hrTime: [ 1753258688, 585000000 ],
    hrTimeObserved: [ 1753258688, 585000000 ],
    spanContext: undefined,
    resource: ResourceImpl {
      _rawAttributes: [Array],
      _asyncAttributesPending: false,
      _memoizedAttributes: undefined
    },
    instrumentationScope: {
      name: '@opentelemetry/winston-transport',
      version: '0.14.0',
      schemaUrl: undefined
    },
    attributes: { timestamp: '2025-07-23T08:18:08.585Z' },
    _severityText: '\x1B[32minfo\x1B[39m',
    _severityNumber: undefined,
    _body: 'Test error message',
    _eventName: undefined,
    totalAttributesCount: 1,
    _isReadonly: true,
    _logRecordLimits: { attributeCountLimit: 128, attributeValueLengthLimit: Infinity }
  }
]
Image

What did you expect to see?

  • SeverityText should contain only log level.

What did you see instead?

  • SeverityText contains both log level and color code.

Additional context

https://gist.github.com/mznet/154f00599ae05a08f58a85454e73f90b

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpkg:instrumentation-winstonpriority:p2Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions