From 0cb05ec91575f7f49909b1f4d79818b6d67cf559 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Fri, 15 May 2020 16:44:49 -0500 Subject: [PATCH 1/2] [APM] Lowercase agent names so icons work .NET agent name can be reported as "dotNet" instead of "dotnet". Lowercase the key so either one will work. --- .../public/components/app/ServiceMap/Cytoscape.stories.tsx | 7 +++++++ .../plugins/apm/public/components/app/ServiceMap/icons.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.stories.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.stories.tsx index 340c299f52c0b..2d1e99096a44f 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.stories.tsx +++ b/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.stories.tsx @@ -186,6 +186,13 @@ storiesOf('app/ServiceMap/Cytoscape', module) 'agent.name': 'dotnet' } }, + { + data: { + id: 'dotNet', + 'service.name': 'dotNet service', + 'agent.name': 'dotNet' + } + }, { data: { id: 'go', diff --git a/x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts b/x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts index 9fe5cbd23b07c..2407d58d5b59e 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts +++ b/x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts @@ -89,7 +89,7 @@ const agentIcons: { [key: string]: string } = { function getAgentIcon(agentName?: string) { // RUM can have multiple names. Normalize it const normalizedAgentName = isRumAgentName(agentName) ? 'js-base' : agentName; - return normalizedAgentName && agentIcons[normalizedAgentName]; + return normalizedAgentName && agentIcons[normalizedAgentName.toLowerCase()]; } function getSpanIcon(type?: string, subtype?: string) { From 1f1fa4557dad68128e343db6fcd45cc3888626f9 Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Mon, 18 May 2020 12:04:07 -0500 Subject: [PATCH 2/2] Extract getNormalizedAgentName --- x-pack/plugins/apm/common/agent_name.ts | 13 +++++++++++++ .../apm/public/components/app/ServiceMap/icons.ts | 7 +++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/apm/common/agent_name.ts b/x-pack/plugins/apm/common/agent_name.ts index 085828b729ea5..dac29a4f50682 100644 --- a/x-pack/plugins/apm/common/agent_name.ts +++ b/x-pack/plugins/apm/common/agent_name.ts @@ -41,3 +41,16 @@ export function isJavaAgentName( ): agentName is 'java' { return agentName === 'java'; } + +/** + * "Normalizes" and agent name by: + * + * * Converting to lowercase + * * Converting "rum-js" to "js-base" + * + * This helps dealing with some older agent versions + */ +export function getNormalizedAgentName(agentName?: string) { + const lowercased = agentName && agentName.toLowerCase(); + return isRumAgentName(lowercased) ? 'js-base' : lowercased; +} diff --git a/x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts b/x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts index 2407d58d5b59e..1b4bf1b77791c 100644 --- a/x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts +++ b/x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts @@ -5,7 +5,7 @@ */ import cytoscape from 'cytoscape'; -import { isRumAgentName } from '../../../../common/agent_name'; +import { getNormalizedAgentName } from '../../../../common/agent_name'; import { AGENT_NAME, SPAN_SUBTYPE, @@ -87,9 +87,8 @@ const agentIcons: { [key: string]: string } = { }; function getAgentIcon(agentName?: string) { - // RUM can have multiple names. Normalize it - const normalizedAgentName = isRumAgentName(agentName) ? 'js-base' : agentName; - return normalizedAgentName && agentIcons[normalizedAgentName.toLowerCase()]; + const normalizedAgentName = getNormalizedAgentName(agentName); + return normalizedAgentName && agentIcons[normalizedAgentName]; } function getSpanIcon(type?: string, subtype?: string) {