-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [APM][Otel] Use `fields` instead of `_source…
…0; on APM queries (#195242) (#196265) # Backport This will backport the following commits from `main` to `8.x`: - [[APM][Otel] Use `fields` instead of `_source` on APM queries (#195242)](#195242) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Carlos Crespo","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-15T09:38:44Z","message":"[APM][Otel] Use `fields` instead of `_source` on APM queries (#195242)\n\ncloses https://github.com/elastic/kibana/issues/192606\r\n\r\n## Summary\r\n\r\nv2 based on the work done in this PR\r\nhttps://github.com//pull/192608 and the suggestion from\r\nDario https://github.com/elastic/kibana/pull/194424\r\n\r\nThis PR replaces the _source usage in APM queries with fields to support\r\nOtel data. The idea is to get rid of existing UI errors we have and make\r\nsure that otel data is shown correctly in the UI.\r\n\r\nOne way to check it is using the [e2e\r\nPoC](https://github.com/elastic/otel-apm-e2e-poc/blob/main/README.md).\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Elastic Machine <[email protected]>\r\nCo-authored-by: Jenny <[email protected]>","sha":"7235ed0425100bbf04ff157d0af7980875473c99","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","apm:opentelemetry","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services"],"title":"[APM][Otel] Use `fields` instead of `_source` on APM queries","number":195242,"url":"https://github.com/elastic/kibana/pull/195242","mergeCommit":{"message":"[APM][Otel] Use `fields` instead of `_source` on APM queries (#195242)\n\ncloses https://github.com/elastic/kibana/issues/192606\r\n\r\n## Summary\r\n\r\nv2 based on the work done in this PR\r\nhttps://github.com//pull/192608 and the suggestion from\r\nDario https://github.com/elastic/kibana/pull/194424\r\n\r\nThis PR replaces the _source usage in APM queries with fields to support\r\nOtel data. The idea is to get rid of existing UI errors we have and make\r\nsure that otel data is shown correctly in the UI.\r\n\r\nOne way to check it is using the [e2e\r\nPoC](https://github.com/elastic/otel-apm-e2e-poc/blob/main/README.md).\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Elastic Machine <[email protected]>\r\nCo-authored-by: Jenny <[email protected]>","sha":"7235ed0425100bbf04ff157d0af7980875473c99"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195242","number":195242,"mergeCommit":{"message":"[APM][Otel] Use `fields` instead of `_source` on APM queries (#195242)\n\ncloses https://github.com/elastic/kibana/issues/192606\r\n\r\n## Summary\r\n\r\nv2 based on the work done in this PR\r\nhttps://github.com//pull/192608 and the suggestion from\r\nDario https://github.com/elastic/kibana/pull/194424\r\n\r\nThis PR replaces the _source usage in APM queries with fields to support\r\nOtel data. The idea is to get rid of existing UI errors we have and make\r\nsure that otel data is shown correctly in the UI.\r\n\r\nOne way to check it is using the [e2e\r\nPoC](https://github.com/elastic/otel-apm-e2e-poc/blob/main/README.md).\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>\r\nCo-authored-by: Elastic Machine <[email protected]>\r\nCo-authored-by: Jenny <[email protected]>","sha":"7235ed0425100bbf04ff157d0af7980875473c99"}}]}] BACKPORT--> Co-authored-by: Carlos Crespo <[email protected]>
- Loading branch information
1 parent
0f2489e
commit ba5a8fc
Showing
67 changed files
with
1,612 additions
and
385 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,7 @@ | |
|
||
export interface Container { | ||
id?: string | null; | ||
image?: string | null; | ||
image?: { | ||
name?: string; | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,5 @@ | |
|
||
// only for RUM agent: shared by error and transaction | ||
export interface Page { | ||
url: string; | ||
url?: string; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,6 @@ | |
|
||
export interface Url { | ||
domain?: string; | ||
full: string; | ||
full?: string; | ||
original?: string; | ||
} |
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 |
---|---|---|
|
@@ -8,5 +8,5 @@ | |
*/ | ||
|
||
export interface User { | ||
id: string; | ||
id?: string; | ||
} |
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
40 changes: 40 additions & 0 deletions
40
x-pack/packages/observability/observability_utils/object/unflatten_object.test.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,40 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { unflattenObject } from './unflatten_object'; | ||
|
||
describe('unflattenObject', () => { | ||
it('unflattens deeply nested objects', () => { | ||
expect(unflattenObject({ 'first.second.third': 'third' })).toEqual({ | ||
first: { | ||
second: { | ||
third: 'third', | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
it('does not unflatten arrays', () => { | ||
expect( | ||
unflattenObject({ | ||
simpleArray: ['0', '1', '2'], | ||
complexArray: [{ one: 'one', two: 'two', three: 'three' }], | ||
'nested.array': [0, 1, 2], | ||
'complex.nested': [{ one: 'one', two: 'two', 'first.second': 'foo', 'first.third': 'bar' }], | ||
}) | ||
).toEqual({ | ||
simpleArray: ['0', '1', '2'], | ||
complexArray: [{ one: 'one', two: 'two', three: 'three' }], | ||
nested: { | ||
array: [0, 1, 2], | ||
}, | ||
complex: { | ||
nested: [{ one: 'one', two: 'two', first: { second: 'foo', third: 'bar' } }], | ||
}, | ||
}); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
x-pack/packages/observability/observability_utils/object/unflatten_object.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,28 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { set } from '@kbn/safer-lodash-set'; | ||
|
||
export function unflattenObject(source: Record<string, any>, target: Record<string, any> = {}) { | ||
// eslint-disable-next-line guard-for-in | ||
for (const key in source) { | ||
const val = source[key as keyof typeof source]; | ||
|
||
if (Array.isArray(val)) { | ||
const unflattenedArray = val.map((item) => { | ||
if (item && typeof item === 'object' && !Array.isArray(item)) { | ||
return unflattenObject(item); | ||
} | ||
return item; | ||
}); | ||
set(target, key, unflattenedArray); | ||
} else { | ||
set(target, key, val); | ||
} | ||
} | ||
return target; | ||
} |
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 |
---|---|---|
|
@@ -21,5 +21,6 @@ | |
"@kbn/es-types", | ||
"@kbn/apm-utils", | ||
"@kbn/es-query", | ||
"@kbn/safer-lodash-set", | ||
] | ||
} |
Oops, something went wrong.