Skip to content

Commit

Permalink
Use envelope name as the telemetry name and reduce payload (#1700)
Browse files Browse the repository at this point in the history
* Use envelope name as the telemetry name

* Fix tests
  • Loading branch information
heyams authored May 21, 2021
1 parent 27cfd4b commit ca7b5c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public Map<String, String> getProperties() {
public void serialize(JsonTelemetryDataSerializer writer) throws IOException {

if (telemetryName == null || telemetryName.isEmpty()) {
telemetryName = getTelemetryName(context.getNormalizedInstrumentationKey(), this.getEnvelopName());
telemetryName = this.getEnvelopName();
}

Envelope envelope = new Envelope();
Expand Down Expand Up @@ -203,9 +203,4 @@ public static String normalizeInstrumentationKey(String instrumentationKey){
return instrumentationKey.replace("-", "").toLowerCase() + ".";
}
}

public static String getTelemetryName(String normalizedInstrumentationKey, String envelopType){
return TELEMETRY_NAME_PREFIX + normalizedInstrumentationKey + envelopType;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void testTelemetryNameWithIkey() throws IOException{
writer.close();
String asJson = new String(buffer.readByteArray(), Charsets.UTF_8);

int index = asJson.indexOf("\"name\":\"Microsoft.ApplicationInsights.aif00000000111122223333000000000000.Stub\"");
int index = asJson.indexOf("\"name\":\"Stub\"");
assertTrue(index != -1);
}

Expand All @@ -132,7 +132,7 @@ public void testTelemetryNameWithIkey_SpecialChar() throws IOException{
writer.close();
String asJson = new String(buffer.readByteArray(), Charsets.UTF_8);

int index = asJson.indexOf("\"name\":\"Microsoft.ApplicationInsights.Stub\"");
int index = asJson.indexOf("\"name\":\"Stub\"");
assertTrue(index != -1);
}

Expand All @@ -149,7 +149,7 @@ public void testTelemetryNameWithIkey_Empty() throws IOException{
writer.close();
String asJson = new String(buffer.readByteArray(), Charsets.UTF_8);

int index = asJson.indexOf("\"name\":\"Microsoft.ApplicationInsights.Stub\"");
int index = asJson.indexOf("\"name\":\"Stub\"");
assertTrue(index != -1);
}

Expand Down

0 comments on commit ca7b5c3

Please sign in to comment.