Skip to content

Commit 93145ab

Browse files
authored
OpenTelemetry icons and data telemetry (#78499) (#78856)
Add OpenTelemetry agent names and and icon. OpenTelemetry services will have the same icon as the corresponding APM services. Services that report "otlp" as their agent name use the OpenTelemetry icon. The OpenTelemetry agents are now collected in the data telemetry along with the other agent names. Change "ratio" in the telemetry to a float.
1 parent 56f8dbd commit 93145ab

File tree

9 files changed

+874
-33
lines changed

9 files changed

+874
-33
lines changed

x-pack/plugins/apm/common/__snapshots__/apm_telemetry.test.ts.snap

Lines changed: 751 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ import { AgentName } from '../typings/es_schemas/ui/fields/agent';
1414
* AGENT_NAMES array.
1515
*/
1616

17+
export const OPEN_TELEMETRY_AGENT_NAMES: AgentName[] = [
18+
'otlp',
19+
'opentelemetry/cpp',
20+
'opentelemetry/dotnet',
21+
'opentelemetry/erlang',
22+
'opentelemetry/go',
23+
'opentelemetry/java',
24+
'opentelemetry/nodejs',
25+
'opentelemetry/php',
26+
'opentelemetry/python',
27+
'opentelemetry/ruby',
28+
'opentelemetry/webjs',
29+
];
30+
1731
export const AGENT_NAMES: AgentName[] = [
1832
'dotnet',
1933
'go',
@@ -23,35 +37,23 @@ export const AGENT_NAMES: AgentName[] = [
2337
'python',
2438
'ruby',
2539
'rum-js',
40+
...OPEN_TELEMETRY_AGENT_NAMES,
2641
];
2742

28-
export function isAgentName(agentName: string): agentName is AgentName {
29-
return AGENT_NAMES.includes(agentName as AgentName);
30-
}
31-
32-
export const RUM_AGENTS = ['js-base', 'rum-js'];
43+
export const RUM_AGENT_NAMES: AgentName[] = [
44+
'js-base',
45+
'rum-js',
46+
'opentelemetry/webjs',
47+
];
3348

3449
export function isRumAgentName(
3550
agentName?: string
36-
): agentName is 'js-base' | 'rum-js' {
37-
return RUM_AGENTS.includes(agentName!);
51+
): agentName is 'js-base' | 'rum-js' | 'opentelemetry/webjs' {
52+
return RUM_AGENT_NAMES.includes(agentName! as AgentName);
3853
}
3954

4055
export function isJavaAgentName(
4156
agentName: string | undefined
4257
): agentName is 'java' {
4358
return agentName === 'java';
4459
}
45-
46-
/**
47-
* "Normalizes" and agent name by:
48-
*
49-
* * Converting to lowercase
50-
* * Converting "rum-js" to "js-base"
51-
*
52-
* This helps dealing with some older agent versions
53-
*/
54-
export function getNormalizedAgentName(agentName?: string) {
55-
const lowercased = agentName && agentName.toLowerCase();
56-
return isRumAgentName(lowercased) ? 'js-base' : lowercased;
57-
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export function getApmTelemetryMapping() {
1919
ignore_above: 1024,
2020
};
2121

22+
const float = {
23+
type: 'float',
24+
};
25+
2226
const long = {
2327
type: 'long',
2428
};
@@ -78,7 +82,7 @@ export function getApmTelemetryMapping() {
7882
properties: {
7983
expected_metric_document_count: long,
8084
transaction_count: long,
81-
ratio: long,
85+
ratio: float,
8286
},
8387
};
8488

x-pack/plugins/apm/public/components/app/RumDashboard/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Projection } from '../../../../common/projections';
1616
import { RumDashboard } from './RumDashboard';
1717
import { useUrlParams } from '../../../hooks/useUrlParams';
1818
import { useFetcher } from '../../../hooks/useFetcher';
19-
import { RUM_AGENTS } from '../../../../common/agent_name';
19+
import { RUM_AGENT_NAMES } from '../../../../common/agent_name';
2020
import { EnvironmentFilter } from '../../shared/EnvironmentFilter';
2121
import { URLFilter } from './URLFilter';
2222
import { LocalUIFilters } from '../../shared/LocalUIFilters';
@@ -48,7 +48,7 @@ export function RumOverview() {
4848
query: {
4949
start,
5050
end,
51-
uiFilters: JSON.stringify({ agentName: RUM_AGENTS }),
51+
uiFilters: JSON.stringify({ agentName: RUM_AGENT_NAMES }),
5252
},
5353
},
5454
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { getAgentIconKey } from './get_agent_icon';
8+
9+
const examples = {
10+
DotNet: 'dotnet', // Test for case sensitivity
11+
dotnet: 'dotnet',
12+
go: 'go',
13+
java: 'java',
14+
'js-base': 'rum',
15+
nodejs: 'nodejs',
16+
'opentelemetry/cpp': 'opentelemetry',
17+
'opentelemetry/dotnet': 'dotnet',
18+
'opentelemetry/erlang': 'opentelemetry',
19+
'opentelemetry/go': 'go',
20+
'opentelemetry/java': 'java',
21+
'opentelemetry/nodejs': 'nodejs',
22+
'opentelemetry/php': 'php',
23+
'opentelemetry/python': 'python',
24+
'opentelemetry/ruby': 'ruby',
25+
'opentelemetry/webjs': 'rum',
26+
otlp: 'opentelemetry',
27+
php: 'php',
28+
python: 'python',
29+
ruby: 'ruby',
30+
'rum-js': 'rum',
31+
'something else': undefined,
32+
};
33+
34+
describe('getAgentIconKey', () => {
35+
Object.entries(examples).forEach(([key, value]) => {
36+
describe(`with ${key}`, () => {
37+
it(`returns ${value}`, () => {
38+
expect(getAgentIconKey(key)).toEqual(value);
39+
});
40+
});
41+
});
42+
});

x-pack/plugins/apm/public/components/shared/AgentIcon/get_agent_icon.ts

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { getNormalizedAgentName } from '../../../../common/agent_name';
7+
import {
8+
OPEN_TELEMETRY_AGENT_NAMES,
9+
RUM_AGENT_NAMES,
10+
} from '../../../../common/agent_name';
11+
import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent';
812
import dotNetIcon from './icons/dot-net.svg';
913
import goIcon from './icons/go.svg';
1014
import javaIcon from './icons/java.svg';
1115
import nodeJsIcon from './icons/nodejs.svg';
16+
import openTelemetryIcon from './icons/opentelemetry.svg';
1217
import phpIcon from './icons/php.svg';
1318
import pythonIcon from './icons/python.svg';
1419
import rubyIcon from './icons/ruby.svg';
@@ -18,14 +23,42 @@ const agentIcons: { [key: string]: string } = {
1823
dotnet: dotNetIcon,
1924
go: goIcon,
2025
java: javaIcon,
21-
'js-base': rumJsIcon,
2226
nodejs: nodeJsIcon,
27+
opentelemetry: openTelemetryIcon,
2328
php: phpIcon,
2429
python: pythonIcon,
2530
ruby: rubyIcon,
31+
rum: rumJsIcon,
2632
};
2733

34+
// This only needs to be exported for testing purposes, since we stub the SVG
35+
// import values in test.
36+
export function getAgentIconKey(agentName: string) {
37+
// Ignore case
38+
const lowercasedAgentName = agentName.toLowerCase();
39+
40+
// RUM agent names
41+
if (RUM_AGENT_NAMES.includes(lowercasedAgentName as AgentName)) {
42+
return 'rum';
43+
}
44+
45+
// Remove "opentelemetry/" prefix
46+
const agentNameWithoutPrefix = lowercasedAgentName.replace(
47+
/^opentelemetry\//,
48+
''
49+
);
50+
51+
if (Object.keys(agentIcons).includes(agentNameWithoutPrefix)) {
52+
return agentNameWithoutPrefix;
53+
}
54+
55+
// OpenTelemetry-only agents
56+
if (OPEN_TELEMETRY_AGENT_NAMES.includes(lowercasedAgentName as AgentName)) {
57+
return 'opentelemetry';
58+
}
59+
}
60+
2861
export function getAgentIcon(agentName?: string) {
29-
const normalizedAgentName = getNormalizedAgentName(agentName);
30-
return normalizedAgentName && agentIcons[normalizedAgentName];
62+
const key = agentName && getAgentIconKey(agentName);
63+
return key && agentIcons[key];
3164
}
Lines changed: 1 addition & 0 deletions
Loading

x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { flatten, merge, sortBy, sum, pickBy } from 'lodash';
88
import { AggregationOptionsByType } from '../../../../typings/elasticsearch/aggregations';
99
import { ProcessorEvent } from '../../../../common/processor_event';
1010
import { TelemetryTask } from '.';
11-
import { AGENT_NAMES, RUM_AGENTS } from '../../../../common/agent_name';
11+
import { AGENT_NAMES, RUM_AGENT_NAMES } from '../../../../common/agent_name';
1212
import {
1313
AGENT_NAME,
1414
AGENT_VERSION,
@@ -1020,7 +1020,7 @@ export const tasks: TelemetryTask[] = [
10201020
timeout,
10211021
query: {
10221022
bool: {
1023-
filter: [range1d, { terms: { [AGENT_NAME]: RUM_AGENTS } }],
1023+
filter: [range1d, { terms: { [AGENT_NAME]: RUM_AGENT_NAMES } }],
10241024
},
10251025
},
10261026
aggs: {

x-pack/plugins/apm/typings/es_schemas/ui/fields/agent.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@ export type AgentName =
1616
| 'nodejs'
1717
| 'python'
1818
| 'dotnet'
19-
| 'ruby';
19+
| 'ruby'
20+
| 'otlp'
21+
| 'opentelemetry/cpp'
22+
| 'opentelemetry/dotnet'
23+
| 'opentelemetry/erlang'
24+
| 'opentelemetry/go'
25+
| 'opentelemetry/java'
26+
| 'opentelemetry/nodejs'
27+
| 'opentelemetry/php'
28+
| 'opentelemetry/python'
29+
| 'opentelemetry/ruby'
30+
| 'opentelemetry/webjs';
2031

2132
export interface Agent {
2233
ephemeral_id?: string;

0 commit comments

Comments
 (0)