Skip to content

Commit dc9c7e8

Browse files
authored
Fix build: update Telemetry.ts for applicationinsights v3 compatibility
1 parent f317ad2 commit dc9c7e8

2 files changed

Lines changed: 10 additions & 15 deletions

File tree

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ General:
88

99
- Applied npm audit fix to updates across multiple dependencies to address security vulnerabilities and maintenance updates.
1010
- Bumped `@types/args` dev dependency from 5.0.3 to 5.0.4 (patch update).
11+
- Bumped `applicationinsights` from 2.9.8 to 3.15.1 and `@opentelemetry/core` to 2.10.0; updated `src/common/Telemetry.ts` for applicationinsights v3 API compatibility (new `TelemetryClient` import path, `RequestTelemetry` type changes, and type-safe minimal envelope shape in the telemetry processor).
1112
- Bumped the default Blob, Queue, and Table service API version to `2026-06-06`.
1213
- Added support for service API versions `2026-04-06` and `2026-02-06` for Blob, Queue, and Table endpoints.
1314

src/common/Telemetry.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import TelemetryClient from "applicationinsights/out/Library/TelemetryClient";
1+
import { TelemetryClient } from "applicationinsights";
22
import {default as BlobContext} from "../blob/generated/Context";
33
import {default as QueueContext} from "../queue/generated/Context";
44
import {default as TableContext} from "../table/generated/Context";
55
import {Operation as BlobOperation} from "../blob/generated/artifacts/operation";
66
import {Operation as QueueOperation} from "../queue/generated/artifacts/operation";
77
import {Operation as TableOperation} from "../table/generated/artifacts/operation";
8-
import { Contracts } from "applicationinsights";
98
import { createHash } from "crypto";
109
import * as fs from "fs";
1110
import { randomUUID as uuid } from "crypto";
@@ -84,12 +83,16 @@ export class AzuriteTelemetryClient {
8483
}
8584
}
8685

87-
private static removeRoleInstance ( envelope: Contracts.EnvelopeTelemetry) : boolean {
86+
private static removeRoleInstance ( envelope: { tags?: Record<string, string> }) : boolean {
8887
// per privacy review, will not collect roleInstance name
89-
envelope.tags["ai.cloud.roleInstance"] = createHash('sha256').update(envelope.tags["ai.cloud.roleInstance"]).digest('hex');
88+
if (envelope.tags?.["ai.cloud.roleInstance"]) {
89+
envelope.tags["ai.cloud.roleInstance"] = createHash('sha256').update(envelope.tags["ai.cloud.roleInstance"]).digest('hex');
90+
}
9091

9192
// per privacy review, we will not collect operation name as it contains request path
92-
envelope.tags["ai.operation.name"] = "";
93+
if (envelope.tags) {
94+
envelope.tags["ai.operation.name"] = "";
95+
}
9396

9497
return true;
9598
}
@@ -197,19 +200,10 @@ export class AzuriteTelemetryClient {
197200
name:reqName,
198201
url:context.request !== undefined ? AzuriteTelemetryClient.GetRequestUri(context.request.getEndpoint()) : "",
199202
duration:context.startTime?((new Date()).getTime() - context.startTime?.getTime()):0,
200-
resultCode:context.response?.getStatusCode()??0,
203+
resultCode:String(context.response?.getStatusCode()??0),
201204
success:(context.response?.getStatusCode() ?? 500) <= 399,
202205
id: context.contextId, // Request ID
203-
source: context.request?.getHeader("user-agent"), // User Agent
204206
properties: requestProperties,
205-
contextObjects:
206-
{
207-
operationId: "",
208-
operationParentId: "",
209-
operationName: "test",
210-
operation_Name: "test",
211-
appName: ""
212-
}
213207
});
214208

215209
logger.verbose(`Send ${serviceType} telemetry: ` + reqName, context.contextId === undefined ? context.contextID : context.contextId);

0 commit comments

Comments
 (0)