forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.15] [APM UI] Fix OpenTelemetry agent names (elastic#193134) (elast…
…ic#193511) # Backport This will backport the following commits from `main` to `8.15`: - [[APM UI] Fix OpenTelemetry agent names (elastic#193134)](elastic#193134) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Sergi Romeu","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-20T07:07:14Z","message":"[APM UI] Fix OpenTelemetry agent names (elastic#193134)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/180444\r\n\r\nThis PR fixes the agent names not being able to properly be retrieved by\r\nthe APM UI, changing the way we map OpenTelemetry agent names.\r\nAs the format changed from `(opentelemetry|otlp)/{agentName}` to\r\n`(opentelemetry|otlp)/{agentName}/{details}`, we now get the second part\r\nsplitting by `/`.\r\n\r\nAdded mappings for RUM, Android, and iOS OpenTelemetry client, also\r\nfixed `get_service_metadata_details` to get the correct OpenTelemetry\r\ndetails.\r\n\r\n|Before|After|\r\n|-|-|\r\n\r\n|![image](https://github.com/user-attachments/assets/28732018-511b-44e0-ac86-cdbe7ed0d1e0)|![image](https://github.com/user-attachments/assets/45a29cc6-f939-4c52-bcc7-54dc15b1a403)|\r\n\r\n## How to test\r\n1. Checkout to this branch\r\n2. Run `node scripts/synthtrace many_otel_services.ts --live --clean`\r\nwhich will fill some APM Otel services.\r\n3. Check that the icon is now rendering","sha":"735e216a952670eb57eaea1229be16e89f9bf1cd","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","apm:opentelemetry","backport:prev-major","ci:project-deploy-observability","Team:obs-ux-infra_services","backport:version"],"number":193134,"url":"https://github.com/elastic/kibana/pull/193134","mergeCommit":{"message":"[APM UI] Fix OpenTelemetry agent names (elastic#193134)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/180444\r\n\r\nThis PR fixes the agent names not being able to properly be retrieved by\r\nthe APM UI, changing the way we map OpenTelemetry agent names.\r\nAs the format changed from `(opentelemetry|otlp)/{agentName}` to\r\n`(opentelemetry|otlp)/{agentName}/{details}`, we now get the second part\r\nsplitting by `/`.\r\n\r\nAdded mappings for RUM, Android, and iOS OpenTelemetry client, also\r\nfixed `get_service_metadata_details` to get the correct OpenTelemetry\r\ndetails.\r\n\r\n|Before|After|\r\n|-|-|\r\n\r\n|![image](https://github.com/user-attachments/assets/28732018-511b-44e0-ac86-cdbe7ed0d1e0)|![image](https://github.com/user-attachments/assets/45a29cc6-f939-4c52-bcc7-54dc15b1a403)|\r\n\r\n## How to test\r\n1. Checkout to this branch\r\n2. Run `node scripts/synthtrace many_otel_services.ts --live --clean`\r\nwhich will fill some APM Otel services.\r\n3. Check that the icon is now rendering","sha":"735e216a952670eb57eaea1229be16e89f9bf1cd"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193134","number":193134,"mergeCommit":{"message":"[APM UI] Fix OpenTelemetry agent names (elastic#193134)\n\n## Summary\r\n\r\nFixes https://github.com/elastic/kibana/issues/180444\r\n\r\nThis PR fixes the agent names not being able to properly be retrieved by\r\nthe APM UI, changing the way we map OpenTelemetry agent names.\r\nAs the format changed from `(opentelemetry|otlp)/{agentName}` to\r\n`(opentelemetry|otlp)/{agentName}/{details}`, we now get the second part\r\nsplitting by `/`.\r\n\r\nAdded mappings for RUM, Android, and iOS OpenTelemetry client, also\r\nfixed `get_service_metadata_details` to get the correct OpenTelemetry\r\ndetails.\r\n\r\n|Before|After|\r\n|-|-|\r\n\r\n|![image](https://github.com/user-attachments/assets/28732018-511b-44e0-ac86-cdbe7ed0d1e0)|![image](https://github.com/user-attachments/assets/45a29cc6-f939-4c52-bcc7-54dc15b1a403)|\r\n\r\n## How to test\r\n1. Checkout to this branch\r\n2. Run `node scripts/synthtrace many_otel_services.ts --live --clean`\r\nwhich will fill some APM Otel services.\r\n3. Check that the icon is now rendering","sha":"735e216a952670eb57eaea1229be16e89f9bf1cd"}},{"url":"https://github.com/elastic/kibana/pull/193509","number":193509,"branch":"8.x","state":"OPEN"}]}] BACKPORT-->
- Loading branch information
Showing
15 changed files
with
541 additions
and
30 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
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,101 @@ | ||
/* | ||
* 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 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 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.