Skip to content

Commit c502ad2

Browse files
authored
[Monitor OpenTelemetry][Monitor OpenTelemetry Exporter] Hide iKey in Debug Logs (#33759)
### Packages impacted by this PR @azure/monitor-opentelemetry @azure/monitor-opentelemetry-exporter ### Describe the problem that is addressed by this PR We should hide iKey in debug logs. ### Checklists - [x] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [x] Added a changelog (if necessary)
1 parent 0e6c400 commit c502ad2

File tree

5 files changed

+10
-17
lines changed

5 files changed

+10
-17
lines changed

sdk/monitor/monitor-opentelemetry-exporter/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Filter OpenTelemetry semantic attributes from being double recorded as custom dimensions.
1313
- Add support for detecting the Application Insights shim on internal verison.
1414
- Do not filter out `_MS.ProcessedByMetricExtractors` value on envelopes.
15+
- Hide iKey in debug logs.
1516

1617
## 1.0.0-beta.29 (2025-03-04)
1718

sdk/monitor/monitor-opentelemetry-exporter/src/utils/connectionStringParser.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ export class ConnectionStringParser {
3232
return { ...fields, [key]: value };
3333
}
3434
diag.error(
35-
`Connection string key-value pair is invalid: ${kv}`,
36-
`Entire connection string will be discarded`,
37-
connectionString,
35+
"Connection string key-value pair is invalid: Entire connection string will be discarded",
3836
);
3937
isValid = false;
4038
return fields;
@@ -60,14 +58,11 @@ export class ConnectionStringParser {
6058
: Constants.DEFAULT_LIVEMETRICS_ENDPOINT;
6159
if (result.authorization && result.authorization.toLowerCase() !== "ikey") {
6260
diag.warn(
63-
`Connection String contains an unsupported 'Authorization' value: ${result.authorization}. Defaulting to 'Authorization=ikey'. Instrumentation Key ${result.instrumentationkey!}`,
61+
`Connection String contains an unsupported 'Authorization' value. Defaulting to 'Authorization=ikey'`,
6462
);
6563
}
6664
} else {
67-
diag.error(
68-
"An invalid connection string was passed in. There may be telemetry loss",
69-
connectionString,
70-
);
65+
diag.error("An invalid connection string was passed in. There may be telemetry loss");
7166
}
7267

7368
return result;

sdk/monitor/monitor-opentelemetry-exporter/src/utils/logUtils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import {
2121
} from "@opentelemetry/semantic-conventions";
2222
import type { Measurements, Properties, Tags } from "../types.js";
2323
import { httpSemanticValues, legacySemanticValues, MaxPropertyLengths } from "../types.js";
24-
import { Attributes, diag } from "@opentelemetry/api";
24+
import type { Attributes } from "@opentelemetry/api";
25+
import { diag } from "@opentelemetry/api";
2526
import {
2627
ApplicationInsightsAvailabilityBaseType,
2728
ApplicationInsightsAvailabilityName,

sdk/monitor/monitor-opentelemetry/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Add support for detecting the Application Insights shim on internal verison.
1212
- Native ESM support has been added, and this package will now emit both CommonJS and ESM. [#32819](https://github.com/Azure/azure-sdk-for-js/pull/32819)
1313
- Add undefined checks for document filtering functions.
14+
- Hide iKey in debug logs.
1415

1516
## 1.9.0 (2025-03-04)
1617

sdk/monitor/monitor-opentelemetry/src/utils/connectionStringParser.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ export class ConnectionStringParser {
3232
return { ...fields, [key]: value };
3333
}
3434
diag.error(
35-
`Connection string key-value pair is invalid: ${kv}`,
36-
`Entire connection string will be discarded`,
37-
connectionString,
35+
`Connection string key-value pair is invalid: Entire connection string will be discarded`,
3836
);
3937
isValid = false;
4038
return fields;
@@ -60,14 +58,11 @@ export class ConnectionStringParser {
6058
: DEFAULT_LIVEMETRICS_ENDPOINT;
6159
if (result.authorization && result.authorization.toLowerCase() !== "ikey") {
6260
diag.warn(
63-
`Connection String contains an unsupported 'Authorization' value: ${result.authorization}. Defaulting to 'Authorization=ikey'. Instrumentation Key ${result.instrumentationkey!}`,
61+
`Connection String contains an unsupported 'Authorization' value. Defaulting to 'Authorization=ikey'.`,
6462
);
6563
}
6664
} else {
67-
diag.error(
68-
"An invalid connection string was passed in. There may be telemetry loss",
69-
connectionString,
70-
);
65+
diag.error("An invalid connection string was passed in. There may be telemetry loss");
7166
}
7267

7368
return result;

0 commit comments

Comments
 (0)