Skip to content

export const enum SemconvStability from @opentelemetry/instrumentation is problematic #5691

@trentm

Description

@trentm

We recently exported a const enum: export const enum SemconvStability from #5684, released in @opentelemetry/[email protected]. From a quick look, there are no other const enum exports from packages in this repo.

TIL exporting a const enum from a package is problematic for some usages of the package. https://ncjamieson.com/dont-export-const-enums/ explains the issue. Some tooling will compile TS modules one file at a time in isolation. In those cases, a const enum reference, e.g. SemconvStability.OLD, cannot be resolved. One such tooling example is ts-node being used by mocha for testing in opentelemetry-js.git and opentelemetry-js-contrib.git. I gather that this was not an issue for usage of SemconvStability in the same repo (e.g. in instr-http, instr-xhr, instr-fetch), because it is a monorepo where the dependencies are symlinks to the source dir.

We hit the error in this PR, the first one in opentelemetry-js-contrib to attempt to use SemconvStability: open-telemetry/opentelemetry-js-contrib#2671 (comment)

To fix this:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions