Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonWeber committed May 2, 2024
1 parent c0a08bd commit be454c7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
16 changes: 15 additions & 1 deletion common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion sdk/monitor/monitor-opentelemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"rimraf": "^5.0.5",
"sinon": "^17.0.0",
"tsx": "^4.7.1",
"typescript": "~5.4.5"
"typescript": "~5.4.5",
"@opentelemetry/instrumentation-fs": "^0.12.0"
},
"dependencies": {
"@azure/core-client": "^1.0.0",
Expand Down
20 changes: 20 additions & 0 deletions sdk/monitor/monitor-opentelemetry/test/internal/unit/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { StatsbeatFeature, StatsbeatInstrumentation } from "../../../src/types";
import { getOsPrefix } from "../../../src/utils/common";
import { ReadableSpan, Span, SpanProcessor } from "@opentelemetry/sdk-trace-base";
import { LogRecordProcessor, LogRecord } from "@opentelemetry/sdk-logs";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { FsInstrumentation } from "@opentelemetry/instrumentation-fs";

describe("Main functions", () => {
let originalEnv: NodeJS.ProcessEnv;
Expand Down Expand Up @@ -175,6 +177,24 @@ describe("Main functions", () => {
assert.strictEqual(instrumentations, 31);
});

it("should monkey patch OpenTelemetry instrumentations and update statsbeat env var", () => {
let config: AzureMonitorOpenTelemetryOptions = {
azureMonitorExporterOptions: {
connectionString: "InstrumentationKey=00000000-0000-0000-0000-000000000000",
},
};
useAzureMonitor(config);
registerInstrumentations({
instrumentations: [
new FsInstrumentation(),
]
});
let output = JSON.parse(String(process.env["AZURE_MONITOR_STATSBEAT_FEATURES"]));
const instrumentations = Number(output["instrumentation"]);
assert.ok(instrumentations & StatsbeatInstrumentation.FS, "FS not set");
assert.strictEqual(instrumentations, StatsbeatInstrumentation.FS);
})

it("should capture the app service SDK prefix correctly", () => {
const os = getOsPrefix();
const env = <{ [id: string]: string }>{};
Expand Down

0 comments on commit be454c7

Please sign in to comment.