Skip to content

Commit

Permalink
[APM] Lowercase agent names so icons work (#66824)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
smith authored May 18, 2020
1 parent 4f1b9a2 commit 1006c31
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
13 changes: 13 additions & 0 deletions x-pack/plugins/apm/common/agent_name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -87,8 +87,7 @@ const agentIcons: { [key: string]: string } = {
};

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

Expand Down

0 comments on commit 1006c31

Please sign in to comment.