[APM] Added Android Agent name and icon (#136598)

* Added Android Agent icon

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* Added agent name to telemetry

* Replaced usage of isIOSAgentName to isMobileAgentName.  Added tests for new agent name functions.

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* Update telemetry collection for android/java agent

* Make opentelemetry/swift not being recognized as mobile agent

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* Fix Jest tests

* Update apm_telemetry.test.ts.snap

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Alexander Wert 2022-07-19 16:52:27 +02:00 committed by GitHub
parent 3d3e33c388
commit 6af683a4e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 239 additions and 31 deletions

View file

@ -13,6 +13,9 @@ exports[`APM telemetry helpers getApmTelemetry generates a JSON object with the
"properties": {
"services_per_agent": {
"properties": {
"android/java": {
"type": "long"
},
"dotnet": {
"type": "long"
},
@ -83,6 +86,60 @@ exports[`APM telemetry helpers getApmTelemetry generates a JSON object with the
},
"agents": {
"properties": {
"android/java": {
"properties": {
"agent": {
"properties": {
"version": {
"type": "keyword"
}
}
},
"service": {
"properties": {
"framework": {
"properties": {
"name": {
"type": "keyword"
},
"version": {
"type": "keyword"
},
"composite": {
"type": "keyword"
}
}
},
"language": {
"properties": {
"name": {
"type": "keyword"
},
"version": {
"type": "keyword"
},
"composite": {
"type": "keyword"
}
}
},
"runtime": {
"properties": {
"name": {
"type": "keyword"
},
"version": {
"type": "keyword"
},
"composite": {
"type": "keyword"
}
}
}
}
}
}
},
"dotnet": {
"properties": {
"agent": {

View file

@ -9,6 +9,8 @@ import {
isJavaAgentName,
isRumAgentName,
isIosAgentName,
isAndroidAgentName,
isMobileAgentName,
isServerlessAgent,
} from './agent_name';
@ -60,13 +62,13 @@ describe('agent name helpers', () => {
});
describe('isIosAgentName', () => {
describe('when the agent name is js-base', () => {
describe('when the agent name is iOS/swift', () => {
it('returns true', () => {
expect(isIosAgentName('iOS/swift')).toEqual(true);
});
});
describe('when the agent name is rum-js', () => {
describe('when the agent name is ios/swift', () => {
it('returns true', () => {
expect(isIosAgentName('ios/swift')).toEqual(true);
});
@ -74,7 +76,7 @@ describe('agent name helpers', () => {
describe('when the agent name is opentelemetry/swift', () => {
it('returns true', () => {
expect(isIosAgentName('opentelemetry/swift')).toEqual(true);
expect(isIosAgentName('opentelemetry/swift')).toEqual(false);
});
});
@ -85,6 +87,64 @@ describe('agent name helpers', () => {
});
});
describe('isAndroidAgentName', () => {
describe('when the agent name is android/java', () => {
it('returns true', () => {
expect(isAndroidAgentName('android/java')).toEqual(true);
});
});
describe('when the agent name is opentelemetry/java', () => {
it('returns false', () => {
expect(isAndroidAgentName('opentelemetry/java')).toEqual(false);
});
});
describe('when the agent name is something else', () => {
it('returns false', () => {
expect(isAndroidAgentName('not android')).toEqual(false);
});
});
});
describe('isMobileAgentName', () => {
describe('when the agent name is android/java', () => {
it('returns true', () => {
expect(isMobileAgentName('android/java')).toEqual(true);
});
});
describe('when the agent name is iOS/swift', () => {
it('returns true', () => {
expect(isMobileAgentName('iOS/swift')).toEqual(true);
});
});
describe('when the agent name is ios/swift', () => {
it('returns true', () => {
expect(isMobileAgentName('ios/swift')).toEqual(true);
});
});
describe('when the agent name is opentelemetry/swift', () => {
it('returns true', () => {
expect(isMobileAgentName('opentelemetry/swift')).toEqual(false);
});
});
describe('when the agent name is opentelemetry/java', () => {
it('returns false', () => {
expect(isMobileAgentName('opentelemetry/java')).toEqual(false);
});
});
describe('when the agent name is something else', () => {
it('returns false', () => {
expect(isMobileAgentName('not mobile')).toEqual(false);
});
});
});
describe('isServerlessAgent', () => {
describe('when the runtime name is AWS_LAMBDA', () => {
it('returns true', () => {

View file

@ -41,6 +41,7 @@ export const AGENT_NAMES: AgentName[] = [
'python',
'ruby',
'rum-js',
'android/java',
...OPEN_TELEMETRY_AGENT_NAMES,
];
@ -64,27 +65,13 @@ export function isRumAgentName(
return RUM_AGENT_NAMES.includes(agentName! as AgentName);
}
export function normalizeAgentName<T extends string | undefined>(
agentName: T
): T | string {
if (isRumAgentName(agentName)) {
return 'rum-js';
}
if (isJavaAgentName(agentName)) {
return 'java';
}
if (isIosAgentName(agentName)) {
return 'ios';
}
return agentName;
export function isMobileAgentName(agentName?: string) {
return isIosAgentName(agentName) || isAndroidAgentName(agentName);
}
export function isIosAgentName(agentName?: string) {
const lowercased = agentName && agentName.toLowerCase();
return lowercased === 'ios/swift' || lowercased === 'opentelemetry/swift';
return lowercased === 'ios/swift';
}
export function isJRubyAgent(agentName?: string, runtimeName?: string) {
@ -94,3 +81,8 @@ export function isJRubyAgent(agentName?: string, runtimeName?: string) {
export function isServerlessAgent(runtimeName?: string) {
return runtimeName?.toLowerCase().startsWith('aws_lambda');
}
export function isAndroidAgentName(agentName?: string) {
const lowercased = agentName && agentName.toLowerCase();
return lowercased === 'android/java';
}

View file

@ -11,7 +11,7 @@ import React from 'react';
import { useHistory } from 'react-router-dom';
import {
isRumAgentName,
isIosAgentName,
isMobileAgentName,
isServerlessAgent,
} from '../../../../common/agent_name';
import { AnnotationsContextProvider } from '../../../context/annotations/annotations_context';
@ -78,7 +78,7 @@ export function ServiceOverview() {
: chartHeight;
const rowDirection = isSingleColumn ? 'column' : 'row';
const isRumAgent = isRumAgentName(agentName);
const isIosAgent = isIosAgentName(agentName);
const isMobileAgent = isMobileAgentName(agentName);
const isServerless = isServerlessAgent(runtimeName);
const router = useApmRouter();
const dependenciesLink = router.link('/services/{serviceName}/dependencies', {
@ -199,7 +199,7 @@ export function ServiceOverview() {
)}
</EuiFlexGroup>
</EuiFlexItem>
{!isRumAgent && !isIosAgent && !isServerless && (
{!isRumAgent && !isMobileAgent && !isServerless && (
<EuiFlexItem>
<EuiFlexGroup
direction="column"

View file

@ -12,7 +12,7 @@ import { useKibana } from '@kbn/kibana-react-plugin/public';
import { createExploratoryViewUrl } from '@kbn/observability-plugin/public';
import { ALL_VALUES_SELECTED } from '@kbn/observability-plugin/public';
import {
isIosAgentName,
isMobileAgentName,
isRumAgentName,
} from '../../../../../common/agent_name';
import {
@ -49,7 +49,7 @@ export function AnalyzeDataButton() {
const canShowDashboard = services.application?.capabilities.dashboard.show;
if (
(isRumAgentName(agentName) || isIosAgentName(agentName)) &&
(isRumAgentName(agentName) || isMobileAgentName(agentName)) &&
rangeFrom &&
canShowDashboard &&
rangeTo

View file

@ -17,7 +17,6 @@ describe('APM service template', () => {
{ agentName: 'java' },
{ agentName: 'opentelemetry/java' },
{ agentName: 'ios/swift' },
{ agentName: 'opentelemetry/swift' },
{ agentName: 'ruby', runtimeName: 'jruby' },
{ runtimeName: 'aws_lambda' },
].map((input) => {

View file

@ -17,7 +17,7 @@ import { omit } from 'lodash';
import React from 'react';
import { enableInfrastructureView } from '@kbn/observability-plugin/public';
import {
isIosAgentName,
isMobileAgentName,
isJavaAgentName,
isJRubyAgent,
isRumAgentName,
@ -145,7 +145,7 @@ export function isMetricsTabHidden({
!agentName ||
isRumAgentName(agentName) ||
isJavaAgentName(agentName) ||
isIosAgentName(agentName) ||
isMobileAgentName(agentName) ||
isJRubyAgent(agentName, runtimeName) ||
isServerlessAgent(runtimeName)
);
@ -221,7 +221,7 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) {
defaultMessage: 'Dependencies',
}),
hidden:
!agentName || isRumAgentName(agentName) || isIosAgentName(agentName),
!agentName || isRumAgentName(agentName) || isMobileAgentName(agentName),
},
{
key: 'errors',
@ -286,7 +286,7 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) {
defaultMessage: 'Logs',
}),
hidden:
!agentName || isRumAgentName(agentName) || isIosAgentName(agentName),
!agentName || isRumAgentName(agentName) || isMobileAgentName(agentName),
},
{
key: 'profiling',

View file

@ -9,6 +9,7 @@ import {
isIosAgentName,
isRumAgentName,
isJavaAgentName,
isAndroidAgentName,
OPEN_TELEMETRY_AGENT_NAMES,
} from '../../../../common/agent_name';
import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent';
@ -31,6 +32,7 @@ import darkPhpIcon from './icons/php_dark.svg';
import darkRumJsIcon from './icons/rumjs_dark.svg';
import rustIcon from './icons/rust.svg';
import darkRustIcon from './icons/rust_dark.svg';
import androidIcon from './icons/android.svg';
const agentIcons: { [key: string]: string } = {
dotnet: dotNetIcon,
@ -47,6 +49,7 @@ const agentIcons: { [key: string]: string } = {
ruby: rubyIcon,
rum: rumJsIcon,
rust: rustIcon,
android: androidIcon,
};
const darkAgentIcons: { [key: string]: string } = {
@ -77,6 +80,10 @@ export function getAgentIconKey(agentName: string) {
return 'ios';
}
if (isAndroidAgentName(lowercasedAgentName)) {
return 'android';
}
// Remove "opentelemetry/" prefix
const agentNameWithoutPrefix = lowercasedAgentName.replace(
/^opentelemetry\//,

View file

@ -0,0 +1,3 @@
<svg width="32" height="32" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1274.37 718">
<path fill="#3ddc84" d="M930.77,536.42a53.07,53.07,0,1,1,53.06-53.08,53.14,53.14,0,0,1-53.06,53.08m-586.54,0a53.07,53.07,0,1,1,53.06-53.08,53.13,53.13,0,0,1-53.06,53.08M949.8,216.77,1055.85,33.09A22.06,22.06,0,1,0,1017.64,11L910.25,197c-82.12-37.48-174.35-58.35-272.76-58.35S446.86,159.55,364.74,197L257.36,11a22.06,22.06,0,1,0-38.22,22.06L325.2,216.77C143.09,315.82,18.53,500.18.31,718H1274.69c-18.24-217.82-142.79-402.18-324.89-501.23"/>
</svg>

After

Width:  |  Height:  |  Size: 538 B

View file

@ -74,6 +74,7 @@ const apmPerAgentSchema: Pick<
// TODO: Find a way for `@kbn/telemetry-tools` to understand and evaluate expressions.
// In the meanwhile, we'll have to maintain these lists up to date (TS will remind us to update)
services_per_agent: {
'android/java': long,
dotnet: long,
'iOS/swift': long,
go: long,
@ -98,6 +99,7 @@ const apmPerAgentSchema: Pick<
'opentelemetry/webjs': long,
},
agents: {
'android/java': agentSchema,
dotnet: agentSchema,
'iOS/swift': agentSchema,
go: agentSchema,

View file

@ -15,7 +15,8 @@ export type ElasticAgentName =
| 'python'
| 'dotnet'
| 'ruby'
| 'php';
| 'php'
| 'android/java';
export type OpenTelemetryAgentName =
| 'otlp'

View file

@ -2602,6 +2602,9 @@
"properties": {
"services_per_agent": {
"properties": {
"android/java": {
"type": "long"
},
"dotnet": {
"type": "long"
},
@ -2672,6 +2675,90 @@
},
"agents": {
"properties": {
"android/java": {
"properties": {
"agent": {
"properties": {
"version": {
"type": "array",
"items": {
"type": "keyword"
}
}
}
},
"service": {
"properties": {
"framework": {
"properties": {
"name": {
"type": "array",
"items": {
"type": "keyword"
}
},
"version": {
"type": "array",
"items": {
"type": "keyword"
}
},
"composite": {
"type": "array",
"items": {
"type": "keyword"
}
}
}
},
"language": {
"properties": {
"name": {
"type": "array",
"items": {
"type": "keyword"
}
},
"version": {
"type": "array",
"items": {
"type": "keyword"
}
},
"composite": {
"type": "array",
"items": {
"type": "keyword"
}
}
}
},
"runtime": {
"properties": {
"name": {
"type": "array",
"items": {
"type": "keyword"
}
},
"version": {
"type": "array",
"items": {
"type": "keyword"
}
},
"composite": {
"type": "array",
"items": {
"type": "keyword"
}
}
}
}
}
}
}
},
"dotnet": {
"properties": {
"agent": {