|
1 | | -import TelemetryClient from "applicationinsights/out/Library/TelemetryClient"; |
| 1 | +import { TelemetryClient } from "applicationinsights"; |
2 | 2 | import {default as BlobContext} from "../blob/generated/Context"; |
3 | 3 | import {default as QueueContext} from "../queue/generated/Context"; |
4 | 4 | import {default as TableContext} from "../table/generated/Context"; |
5 | 5 | import {Operation as BlobOperation} from "../blob/generated/artifacts/operation"; |
6 | 6 | import {Operation as QueueOperation} from "../queue/generated/artifacts/operation"; |
7 | 7 | import {Operation as TableOperation} from "../table/generated/artifacts/operation"; |
8 | | -import { Contracts } from "applicationinsights"; |
9 | 8 | import { createHash } from "crypto"; |
10 | 9 | import * as fs from "fs"; |
11 | 10 | import { randomUUID as uuid } from "crypto"; |
@@ -84,12 +83,16 @@ export class AzuriteTelemetryClient { |
84 | 83 | } |
85 | 84 | } |
86 | 85 |
|
87 | | - private static removeRoleInstance ( envelope: Contracts.EnvelopeTelemetry) : boolean { |
| 86 | + private static removeRoleInstance ( envelope: { tags?: Record<string, string> }) : boolean { |
88 | 87 | // 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 | + } |
90 | 91 |
|
91 | 92 | // 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 | + } |
93 | 96 |
|
94 | 97 | return true; |
95 | 98 | } |
@@ -197,19 +200,10 @@ export class AzuriteTelemetryClient { |
197 | 200 | name:reqName, |
198 | 201 | url:context.request !== undefined ? AzuriteTelemetryClient.GetRequestUri(context.request.getEndpoint()) : "", |
199 | 202 | duration:context.startTime?((new Date()).getTime() - context.startTime?.getTime()):0, |
200 | | - resultCode:context.response?.getStatusCode()??0, |
| 203 | + resultCode:String(context.response?.getStatusCode()??0), |
201 | 204 | success:(context.response?.getStatusCode() ?? 500) <= 399, |
202 | 205 | id: context.contextId, // Request ID |
203 | | - source: context.request?.getHeader("user-agent"), // User Agent |
204 | 206 | properties: requestProperties, |
205 | | - contextObjects: |
206 | | - { |
207 | | - operationId: "", |
208 | | - operationParentId: "", |
209 | | - operationName: "test", |
210 | | - operation_Name: "test", |
211 | | - appName: "" |
212 | | - } |
213 | 207 | }); |
214 | 208 |
|
215 | 209 | logger.verbose(`Send ${serviceType} telemetry: ` + reqName, context.contextId === undefined ? context.contextID : context.contextId); |
|
0 commit comments