Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Take end of iKey
  • Loading branch information
jeanbisutti committed Jan 13, 2025
commit b3a6064565b56138273a6093a11106c0464719a2
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private static List<ByteBuffer> serialize(List<TelemetryItem> telemetryItems) {
try {
if (logger.canLogAtLevel(LogLevel.VERBOSE)) {
String json = toJson(telemetryItems);
String jsonWithoutIKeys = removeIKeys(telemetryItems, json);
String jsonWithoutIKeys = maskIKeys(telemetryItems, json);
logger.verbose("sending telemetry to ingestion service:{}{}", System.lineSeparator(), jsonWithoutIKeys);
}

Expand Down Expand Up @@ -164,11 +164,12 @@ private static String toJson(List<TelemetryItem> telemetryItems) throws IOExcept
}
}

private static String removeIKeys(List<TelemetryItem> telemetryItems, String json) {
private static String maskIKeys(List<TelemetryItem> telemetryItems, String json) {
Set<String> iKeys
= telemetryItems.stream().map(TelemetryItem::getInstrumentationKey).collect(Collectors.toSet());
for (String instrumentationKey : iKeys) {
json = json.replace(instrumentationKey, "***");
String maskedIKey = "*" + instrumentationKey.substring( instrumentationKey.length() - 13, instrumentationKey.length() - 1);
json = json.replace(instrumentationKey, maskedIKey);
}
return json;
}
Expand Down
Loading