Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Monitor-OpenTelemetry-Exporter] Fix Resource Metric Disabling Environment Variable #32697

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk/monitor/monitor-opentelemetry-exporter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
Loading