-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM UI] Fix OpenTelemetry agent names (#193134)
## Summary Fixes #180444 This PR fixes the agent names not being able to properly be retrieved by the APM UI, changing the way we map OpenTelemetry agent names. As the format changed from `(opentelemetry|otlp)/{agentName}` to `(opentelemetry|otlp)/{agentName}/{details}`, we now get the second part splitting by `/`. Added mappings for RUM, Android, and iOS OpenTelemetry client, also fixed `get_service_metadata_details` to get the correct OpenTelemetry details. |Before|After| |-|-| |![image](https://github.com/user-attachments/assets/28732018-511b-44e0-ac86-cdbe7ed0d1e0)|![image](https://github.com/user-attachments/assets/45a29cc6-f939-4c52-bcc7-54dc15b1a403)| ## How to test 1. Checkout to this branch 2. Run `node scripts/synthtrace many_otel_services.ts --live --clean` which will fill some APM Otel services. 3. Check that the icon is now rendering
- Loading branch information
Showing
16 changed files
with
551 additions
and
39 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
packages/kbn-apm-synthtrace/src/scenarios/many_otel_services.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { ApmFields, apm, Instance } from '@kbn/apm-synthtrace-client'; | ||
import { flatten, random, times } from 'lodash'; | ||
import { Scenario } from '../cli/scenario'; | ||
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment'; | ||
import { withClient } from '../lib/utils/with_client'; | ||
import { getRandomNameForIndex } from './helpers/random_names'; | ||
|
||
const ENVIRONMENT = getSynthtraceEnvironment(__filename); | ||
|
||
const scenario: Scenario<ApmFields> = async ({ logger, scenarioOpts = { services: 2000 } }) => { | ||
const numServices = scenarioOpts.services; | ||
const transactionName = 'GET /order/{id}'; | ||
const languages = [ | ||
'go', | ||
'dotnet', | ||
'java', | ||
'python', | ||
'nodejs', | ||
'php', | ||
'webjs', | ||
'swift', | ||
'android', | ||
]; | ||
const agentVersions: Record<string, string[]> = { | ||
go: ['2.1.0', '2.0.0', '1.15.0', '1.14.0', '1.13.1'], | ||
dotnet: ['1.18.0', '1.17.0', '1.16.1', '1.16.0', '1.15.0'], | ||
java: ['1.34.1', '1.34.0', '1.33.0', '1.32.0', '1.32.0'], | ||
python: ['6.12.0', '6.11.0', '6.10.2', '6.10.1', '6.10.0'], | ||
nodejs: ['1.34.1', '1.34.0', '1.33.0', '1.32.0', '1.32.0'], | ||
php: ['1.34.1', '1.34.0', '1.33.0', '1.32.0', '1.32.0'], | ||
webjs: ['6.12.0', '6.11.0', '6.10.2', '6.10.1', '6.10.0'], | ||
swift: ['1.18.0', '1.17.0', '1.16.1', '1.16.0', '1.15.0'], | ||
android: ['6.12.0', '6.11.0', '6.10.2', '6.10.1', '6.10.0'], | ||
}; | ||
|
||
return { | ||
generate: ({ range, clients: { apmEsClient } }) => { | ||
const instances = flatten( | ||
times(numServices).map((index) => { | ||
const language = languages[index % languages.length]; | ||
const agentLanguageVersions = agentVersions[language]; | ||
const agentVersion = agentLanguageVersions[index % agentLanguageVersions.length]; | ||
|
||
const numOfInstances = (index % 3) + 1; | ||
return times(numOfInstances).map((instanceIndex) => | ||
apm | ||
.service({ | ||
name: `${getRandomNameForIndex(index)}-${language}-${index}`, | ||
environment: ENVIRONMENT, | ||
agentName: | ||
index % 2 ? `opentelemetry/${language}/elastic` : `otlp/${language}/elastic`, | ||
}) | ||
.instance(`instance-${index}-${instanceIndex}`) | ||
.defaults({ 'agent.version': agentVersion, 'service.language.name': language }) | ||
); | ||
}) | ||
); | ||
|
||
const instanceSpans = (instance: Instance) => { | ||
const hasHighDuration = Math.random() > 0.5; | ||
const throughput = random(1, 10); | ||
|
||
return range.ratePerMinute(throughput).generator((timestamp) => { | ||
const parentDuration = hasHighDuration ? random(1000, 5000) : random(100, 1000); | ||
const generateError = random(1, 4) % 3 === 0; | ||
const span = instance | ||
.transaction({ transactionName }) | ||
.timestamp(timestamp) | ||
.duration(parentDuration); | ||
|
||
return !generateError | ||
? span.success() | ||
: span.failure().errors( | ||
instance | ||
.error({ | ||
message: `No handler for ${transactionName}`, | ||
type: 'No handler', | ||
culprit: 'request', | ||
}) | ||
.timestamp(timestamp + 50) | ||
); | ||
}); | ||
}; | ||
|
||
return withClient( | ||
apmEsClient, | ||
logger.perf('generating_apm_events', () => instances.map(instanceSpans)) | ||
); | ||
}, | ||
}; | ||
}; | ||
|
||
export default scenario; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.