Skip to content

Commit 426dd9c

Browse files
committed
[APM] Lowercase agent names so icons work (#66824)
* [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. * Extract getNormalizedAgentName
1 parent abe68c9 commit 426dd9c

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

x-pack/plugins/apm/common/agent_name.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,16 @@ export function isJavaAgentName(
4141
): agentName is 'java' {
4242
return agentName === 'java';
4343
}
44+
45+
/**
46+
* "Normalizes" and agent name by:
47+
*
48+
* * Converting to lowercase
49+
* * Converting "rum-js" to "js-base"
50+
*
51+
* This helps dealing with some older agent versions
52+
*/
53+
export function getNormalizedAgentName(agentName?: string) {
54+
const lowercased = agentName && agentName.toLowerCase();
55+
return isRumAgentName(lowercased) ? 'js-base' : lowercased;
56+
}

x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ storiesOf('app/ServiceMap/Cytoscape', module)
186186
'agent.name': 'dotnet'
187187
}
188188
},
189+
{
190+
data: {
191+
id: 'dotNet',
192+
'service.name': 'dotNet service',
193+
'agent.name': 'dotNet'
194+
}
195+
},
189196
{
190197
data: {
191198
id: 'go',

x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import cytoscape from 'cytoscape';
8-
import { isRumAgentName } from '../../../../common/agent_name';
8+
import { getNormalizedAgentName } from '../../../../common/agent_name';
99
import {
1010
AGENT_NAME,
1111
SPAN_SUBTYPE,
@@ -87,8 +87,7 @@ const agentIcons: { [key: string]: string } = {
8787
};
8888

8989
function getAgentIcon(agentName?: string) {
90-
// RUM can have multiple names. Normalize it
91-
const normalizedAgentName = isRumAgentName(agentName) ? 'js-base' : agentName;
90+
const normalizedAgentName = getNormalizedAgentName(agentName);
9291
return normalizedAgentName && agentIcons[normalizedAgentName];
9392
}
9493

0 commit comments

Comments
 (0)