-
Notifications
You must be signed in to change notification settings - Fork 621
Description
Description
Description
Important
This issue is reserved for attendees of OpenTelemetry ContribFest at KubeCon EU 2025
If you are attending KubeCon EU 2025, please join us at Level 3 | ICC Capital Suite 1 on Wednesday April 2, 2025 16:15 - 17:30 BST π
If you are not attending KubeCon EU 2025, the remainder of this issue will be
marked as "good-first-issue" starting Thursday. π
With open-telemetry/opentelemetry-js#5443 we've introduced new utility functions for getting getting environment variables in an OTel Spec compliant manner, and we've migrated from using the old getEnv() utility function (#2708).
However, to provide an easier upgrade-path, for users of getEnv() we've also introduced a utility function to get a log level from a string, so the mapping we now do is now obsolete and we should align it with the core repo.
The goal of this issue is to replace the diagnostics logging setup here:
| diag.setLogger(new DiagConsoleLogger(), getLogLevelFromEnv()); |
with a setup which is the same as in the core repo.
You can then remove this code here:
opentelemetry-js-contrib/metapackages/auto-instrumentations-node/src/utils.ts
Lines 307 to 318 in 03350ef
| export function getLogLevelFromEnv(): DiagLogLevel { | |
| const rawLogLevel = process.env.OTEL_LOG_LEVEL; | |
| // NOTE: as per specification we should actually only register if something is set, but our previous implementation | |
| // always registered a logger, even when nothing was set. Falling back to 'INFO' here to keep the same behavior as | |
| // with previous implementations. | |
| // Also: no point in warning - no logger is registered yet | |
| return ( | |
| logLevelMap[rawLogLevel?.trim().toUpperCase() ?? 'INFO'] ?? | |
| DiagLogLevel.INFO | |
| ); | |
| } |
and any other code that becomes unused from this change.
To complete this issue:
- check the implementation of the new env var utility functions as well as the utility to convert strings to
DiagLogLevel. - use these new utility functions in the auto-instrumentations-node setup code
- the new utility functions do already drop blank and nullish strings, please remove any now-unncessary code
- ensure unit-tests are still passing