diff --git a/sdk/monitor/monitor-opentelemetry-exporter/CHANGELOG.md b/sdk/monitor/monitor-opentelemetry-exporter/CHANGELOG.md index 2e00c7a73b53..32067e903bcc 100644 --- a/sdk/monitor/monitor-opentelemetry-exporter/CHANGELOG.md +++ b/sdk/monitor/monitor-opentelemetry-exporter/CHANGELOG.md @@ -6,6 +6,10 @@ - Added support for operation name on dependencies and logs. +### Bugs Fixed + +- Fixed usage of environment variable to disable resource metric creation. + ### Other Changes - Fix setting statsbeat custom dimensions. diff --git a/sdk/monitor/monitor-opentelemetry-exporter/src/utils/common.ts b/sdk/monitor/monitor-opentelemetry-exporter/src/utils/common.ts index 619188666eec..0c93dd916e2d 100644 --- a/sdk/monitor/monitor-opentelemetry-exporter/src/utils/common.ts +++ b/sdk/monitor/monitor-opentelemetry-exporter/src/utils/common.ts @@ -46,6 +46,7 @@ import type { Resource } from "@opentelemetry/resources"; import type { Attributes, HrTime } from "@opentelemetry/api"; import { hrTimeToNanoseconds } from "@opentelemetry/core"; import type { AnyValue } from "@opentelemetry/api-logs"; +import { ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED } from "../Declarations/Constants.js"; export function hrTimeToDate(hrTime: HrTime): Date { return new Date(hrTimeToNanoseconds(hrTime) / 1000000); @@ -282,5 +283,5 @@ export function serializeAttribute(value: AnyValue): string { } export function shouldCreateResourceMetric(): boolean { - return !(process.env.ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED?.toLowerCase() === "true"); + return !(process.env[ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED]?.toLowerCase() === "true"); } diff --git a/sdk/monitor/monitor-opentelemetry-exporter/test/internal/functional/trace.test.ts b/sdk/monitor/monitor-opentelemetry-exporter/test/internal/functional/trace.test.ts index 8fa6f46b8126..4b27ed58449a 100644 --- a/sdk/monitor/monitor-opentelemetry-exporter/test/internal/functional/trace.test.ts +++ b/sdk/monitor/monitor-opentelemetry-exporter/test/internal/functional/trace.test.ts @@ -3,7 +3,10 @@ import { assertCount, assertTraceExpectation } from "../../utils/assert.js"; import { TraceBasicScenario } from "../../utils/basic.js"; -import { DEFAULT_BREEZE_ENDPOINT } from "../../../src/Declarations/Constants.js"; +import { + DEFAULT_BREEZE_ENDPOINT, + ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED, +} from "../../../src/Declarations/Constants.js"; import nock from "nock"; import { successfulBreezeResponse } from "../../utils/breezeTestUtils.js"; import type { TelemetryItem as Envelope } from "../../../src/generated/index.js"; @@ -49,7 +52,7 @@ describe("Trace Exporter Scenarios", () => { let ingest: Envelope[] = []; beforeAll(() => { - process.env.ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED = "true"; + process.env[ENV_OPENTELEMETRY_RESOURCE_METRIC_DISABLED] = "true"; nock(DEFAULT_BREEZE_ENDPOINT) .post("/v2.1/track", (body: Envelope[]) => { // todo: gzip is not supported by generated applicationInsightsClient