Skip to content
1 change: 1 addition & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ For notes on migrating to 2.x / 0.200.x see [the upgrade guide](doc/upgrade-to-2

### :house: Internal

* refactor: use getStringFromEnv instead of process.env [#5594](https://github.com/open-telemetry/opentelemetry-js/pull/5594) @weyert
* chore(sdk-node): Refactored using `get*FromEnv` utility function instead of `process.env` for NodeSDK's logging setup. [#5563](https://github.com/open-telemetry/opentelemetry-js/issues/5563) @weyert

## 0.200.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { parseKeyPairsIntoRecord } from '@opentelemetry/core';
import { getStringFromEnv, parseKeyPairsIntoRecord } from '@opentelemetry/core';
import { diag } from '@opentelemetry/api';
import { getSharedConfigurationFromEnvironment } from './shared-env-configuration';
import { OtlpHttpConfiguration } from './otlp-http-configuration';
Expand All @@ -22,10 +22,12 @@ import { wrapStaticHeadersInFunction } from './shared-configuration';
function getStaticHeadersFromEnv(
signalIdentifier: string
): Record<string, string> | undefined {
const signalSpecificRawHeaders =
process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]?.trim();
const nonSignalSpecificRawHeaders =
process.env['OTEL_EXPORTER_OTLP_HEADERS']?.trim();
const signalSpecificRawHeaders = getStringFromEnv(
`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`
);
const nonSignalSpecificRawHeaders = getStringFromEnv(
'OTEL_EXPORTER_OTLP_HEADERS'
);

const signalSpecificHeaders = parseKeyPairsIntoRecord(
signalSpecificRawHeaders
Expand Down Expand Up @@ -98,16 +100,17 @@ function appendResourcePathToUrl(
function getNonSpecificUrlFromEnv(
signalResourcePath: string
): string | undefined {
const envUrl = process.env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();
const envUrl = getStringFromEnv('OTEL_EXPORTER_OTLP_ENDPOINT');
if (envUrl == null || envUrl === '') {
return undefined;
}
return appendResourcePathToUrl(envUrl, signalResourcePath);
}

function getSpecificUrlFromEnv(signalIdentifier: string): string | undefined {
const envUrl =
process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]?.trim();
const envUrl = getStringFromEnv(
`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`
);
if (envUrl == null || envUrl === '') {
return undefined;
}
Expand Down