From f9d0ef87340bafd036b2980b7b388a5fb7231d35 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 1 Jun 2021 15:28:01 -0700 Subject: [PATCH] Fix App Map display of unknown dependencies (#1716) * Fix App Map display of unknown dependencies * Add net peer mapping to target also * Add clarifying comment --- .../applicationinsights/agent/Exporter.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/agent/exporter/src/main/java/com/microsoft/applicationinsights/agent/Exporter.java b/agent/exporter/src/main/java/com/microsoft/applicationinsights/agent/Exporter.java index 88207e2a00c..246d674ceb1 100644 --- a/agent/exporter/src/main/java/com/microsoft/applicationinsights/agent/Exporter.java +++ b/agent/exporter/src/main/java/com/microsoft/applicationinsights/agent/Exporter.java @@ -322,6 +322,22 @@ private void applySemanticConventions(SpanData span, RemoteDependencyTelemetry r applyServiceBusSpan(attributes, remoteDependencyData); return; } + + // passing max value because we don't know what the default port would be in this case, + // so we always want the port included + String target = getTargetFromPeerAttributes(attributes, Integer.MAX_VALUE); + if (target != null) { + remoteDependencyData.setTarget(target); + return; + } + + // with no target, the App Map falls back to creating a node based on the telemetry name, + // which is very confusing, e.g. when multiple unrelated nodes all point to a single node + // because they had dependencies with the same telemetry name + // + // so we mark these as InProc, even though they aren't INTERNAL spans, + // in order to prevent App Map from considering them + remoteDependencyData.setType("InProc"); } private void exportLogSpan(SpanData span) {