-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[APM][Otel] Add Otel client based on PoC data #192293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jennypavlova
merged 24 commits into
elastic:main
from
jennypavlova:192115-apmotel-add-synthtrace-scenarios-to-test-with-otel-data
Oct 14, 2024
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
268638f
[WIP] Add Otel client based on PoC data
jennypavlova fdf43bd
Add fields and changed indecies
jennypavlova 1c471e4
Add service name and fields
jennypavlova c023d45
[WIP] Add Otel client based on PoC data
jennypavlova 309487f
Add fields and changed indecies
jennypavlova e214bfc
Add service name and fields
jennypavlova 5c95114
rename indices and refactor code
MiriamAparicio 2ab2b78
review fields for errors
MiriamAparicio bff034b
remove redundant trace.is
MiriamAparicio 46b62aa
Merge branch 'main' into 192115-apmotel-add-synthtrace-scenarios-to-t…
jennypavlova 4c827c2
Merge branch '192115-apmotel-add-synthtrace-scenarios-to-test-with-ot…
jennypavlova 71a607d
Resolve conflicts
jennypavlova 0d08420
Fix error docs and update metrics and traces
jennypavlova d5d9eb0
Merge branch 'main' into 192115-apmotel-add-synthtrace-scenarios-to-t…
jennypavlova 832abf1
Fix types
jennypavlova d68e935
Merge branch 'main' into 192115-apmotel-add-synthtrace-scenarios-to-t…
jennypavlova 6a59171
Rename to OtelSharedResourceAttributes
jennypavlova 59fa9fd
Merge branch 'main' into 192115-apmotel-add-synthtrace-scenarios-to-t…
jennypavlova 3a66c44
CR changes
jennypavlova 61f38b7
Add exception.handled
jennypavlova 18446fd
Merge branch 'main' into 192115-apmotel-add-synthtrace-scenarios-to-t…
jennypavlova 3d972e7
Merge branch 'main' into 192115-apmotel-add-synthtrace-scenarios-to-t…
jennypavlova 7ce3a70
Move metricset.name to attributes type
jennypavlova 7382cc8
Merge branch 'main' into 192115-apmotel-add-synthtrace-scenarios-to-t…
jennypavlova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,33 @@ | ||
| /* | ||
| * 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 type { OtelDocument } from '../../..'; | ||
| import { Serializable } from '../serializable'; | ||
|
|
||
| export interface OtelErrorDocument extends OtelDocument { | ||
| 'event.name'?: string; | ||
| attributes?: { | ||
| 'exception.message'?: string; | ||
| 'error.stack_trace'?: string; | ||
| 'exception.handled'?: boolean; | ||
| 'exception.type'?: string; | ||
| 'processor.event'?: string; | ||
| 'timestamp.us'?: number; | ||
| 'event.name'?: string; | ||
| 'error.id'?: string; | ||
| }; | ||
| } | ||
|
|
||
| export class OtelError extends Serializable<OtelErrorDocument> { | ||
| constructor(fields: OtelErrorDocument) { | ||
| super({ | ||
| ...fields, | ||
| }); | ||
| } | ||
| } | ||
213 changes: 213 additions & 0 deletions
213
packages/kbn-apm-synthtrace-client/src/lib/otel/index.ts
This file contains hidden or 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,213 @@ | ||
| /* | ||
| * 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 { Fields } from '../entity'; | ||
| import { Serializable } from '../serializable'; | ||
| import { OtelError } from './error'; | ||
| import { OtelMetric } from './metric'; | ||
| import { OtelTransaction } from './transaction'; | ||
|
|
||
| interface OtelSharedResourceAttributes { | ||
| 'service.name'?: string; | ||
| 'agent.name'?: string; | ||
| 'agent.version'?: string; | ||
| 'metricset.interval'?: string; | ||
| 'service.instance.id'?: string; | ||
| 'telemetry.sdk.language'?: string; | ||
| 'telemetry.sdk.name'?: string; | ||
| 'telemetry.sdk.version'?: string; | ||
| 'some.resource.attribute'?: string; | ||
| } | ||
|
|
||
| export interface OtelDocument extends Fields { | ||
| data_stream?: { | ||
| dataset: string; | ||
| namespace: string; | ||
| type: string; | ||
| }; | ||
| attributes?: { | ||
| 'timestamp.us'?: number; | ||
| 'metricset.name'?: string; | ||
| [key: string]: any; | ||
| }; | ||
| resource?: { | ||
| attributes?: OtelSharedResourceAttributes; | ||
| dropped_attributes_count?: number; | ||
| schema_url?: string; | ||
| }; | ||
| scope?: { | ||
| attributes?: { | ||
| 'service.framework.name'?: string; | ||
| 'service.framework.version'?: string; | ||
| }; | ||
| dropped_attributes_count?: number; | ||
| name?: string; | ||
| }; | ||
| name?: string; | ||
| trace_id?: string; | ||
| trace?: { id: string }; | ||
| span_id?: string; | ||
| span?: { id: string }; | ||
| dropped_attributes_count?: number; | ||
| dropped_events_count?: number; | ||
| dropped_links_count?: number; | ||
| timestamp_us?: number; | ||
| } | ||
|
|
||
| class Otel extends Serializable<OtelDocument> { | ||
| constructor(fields: OtelDocument) { | ||
| super({ | ||
| ...fields, | ||
| }); | ||
| } | ||
|
|
||
| error(spanId: string) { | ||
| return new OtelError({ | ||
| ...this.fields, | ||
| attributes: { | ||
| 'exception.message': 'boom', | ||
| 'exception.handled': false, | ||
| 'exception.type': '*errors.errorString', | ||
| 'error.stack_trace': 'Error: INTERNAL: Boom', | ||
| 'processor.event': 'error', | ||
| 'timestamp.us': 1726580752010657, | ||
| 'event.name': 'exception', | ||
| 'error.id': `error-${spanId}`, | ||
| }, | ||
| data_stream: { | ||
| dataset: 'generic.otel', | ||
| namespace: 'default', | ||
| type: 'logs', | ||
| }, | ||
| 'event.name': 'exception', | ||
| dropped_attributes_count: 0, | ||
| resource: { | ||
| attributes: { | ||
| 'agent.name': 'opentelemetry/go', | ||
| 'agent.version': '1.28.0', | ||
| 'service.name': 'sendotlp-synth', | ||
| 'service.instance.id': '89117ac1-0dbf-4488-9e17-4c2c3b76943a', | ||
| }, | ||
| dropped_attributes_count: 0, | ||
| schema_url: 'https://opentelemetry.io/schemas/1.26.0', | ||
| }, | ||
| scope: { | ||
| attributes: { | ||
| 'service.framework.name': 'sendotlp-synth', | ||
| 'service.framework.version': '', | ||
| }, | ||
| dropped_attributes_count: 0, | ||
| name: 'sendotlp-synth', | ||
| }, | ||
| span_id: spanId, | ||
| }); | ||
| } | ||
|
|
||
| metric() { | ||
| return new OtelMetric({ | ||
| ...this.fields, | ||
| attributes: { | ||
jennypavlova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 'metricset.name': 'service_destination', | ||
| 'processor.event': 'metric', | ||
| 'event.outcome': 'success', | ||
| 'service.target.name': 'foo_service', | ||
| 'service.target.type': 'http', | ||
| 'span.name': 'child1', | ||
| 'span.destination.service.resource': 'foo_service:8080', | ||
| }, | ||
| data_stream: { | ||
| dataset: 'service_destination.10m.otel', | ||
| namespace: 'default', | ||
| type: 'metrics', | ||
| }, | ||
| metrics: { | ||
| service_summary: 2, | ||
| }, | ||
| resource: { | ||
| attributes: { | ||
| 'agent.name': 'otlp', | ||
| 'agent.version': '1.28.0', | ||
| 'service.instance.id': '89117ac1-0dbf-4488-9e17-4c2c3b76943a', | ||
| 'service.name': 'sendotlp-synth', | ||
| 'metricset.interval': '10m', | ||
| }, | ||
| dropped_attributes_count: 0, | ||
| }, | ||
| scope: { | ||
| dropped_attributes_count: 0, | ||
| name: 'github.com/elastic/opentelemetry-collector-components/connector/spanmetricsconnectorv2', | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| // In Otel we have only spans (https://opentelemetry.io/docs/concepts/signals/traces/#spans) | ||
| // we call the root span a transaction to match our data model | ||
| transaction(id: string) { | ||
| return new OtelTransaction({ | ||
gregkalapos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ...this.fields, | ||
| attributes: { | ||
| 'event.outcome': 'success', | ||
| 'event.success_count': 1, | ||
| 'processor.event': 'transaction', | ||
| 'timestamp.us': 1726580752010657, | ||
| 'transaction.duration.us': 15202, | ||
| 'transaction.id': id, | ||
| 'transaction.name': 'parent-synth', | ||
| 'transaction.representative_count': 1, | ||
| 'transaction.result': 'HTTP 2xx', | ||
| 'transaction.root': true, | ||
| 'transaction.sampled': true, | ||
| 'transaction.type': 'unknown', | ||
| }, | ||
| data_stream: { | ||
| dataset: 'generic.otel', | ||
| namespace: 'default', | ||
| type: 'traces', | ||
| }, | ||
| duration: 11742370, | ||
| kind: 'Internal', | ||
| name: 'parent-synth', | ||
| resource: { | ||
| attributes: { | ||
| 'agent.name': 'otlp', | ||
| 'agent.version': '1.28.0', | ||
| 'service.instance.id': '89117ac1-0dbf-4488-9e17-4c2c3b76943a', | ||
| 'service.name': 'sendotlp-synth', | ||
| }, | ||
| dropped_attributes_count: 0, | ||
| schema_url: 'https://opentelemetry.io/schemas/1.26.0', | ||
| }, | ||
| scope: { | ||
| attributes: { | ||
| 'service.framework.name': 'sendotlp-synth', | ||
| 'service.framework.version': '', | ||
| }, | ||
| dropped_attributes_count: 0, | ||
| name: 'sendotlp-synth', | ||
| }, | ||
| span_id: id, | ||
| status: { | ||
| code: 'Unset', | ||
| }, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| export function create(id: string): Otel { | ||
| return new Otel({ | ||
| trace_id: id, | ||
| dropped_attributes_count: 0, | ||
| dropped_events_count: 0, | ||
| dropped_links_count: 0, | ||
| }); | ||
| } | ||
|
|
||
| export const otel = { | ||
| create, | ||
| }; | ||
This file contains hidden or 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,33 @@ | ||
| /* | ||
| * 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 { OtelDocument } from '.'; | ||
| import { Serializable } from '../serializable'; | ||
|
|
||
| export interface OtelMetricDocument extends OtelDocument { | ||
| attributes?: { | ||
| 'metricset.name'?: string; | ||
| 'processor.event'?: string; | ||
| 'event.outcome'?: string; | ||
| 'service.target.name'?: string; | ||
| 'service.target.type'?: string; | ||
| 'span.name'?: string; | ||
| 'span.destination.service.resource'?: string; | ||
| }; | ||
| metrics?: { | ||
| service_summary?: number; | ||
| }; | ||
| } | ||
| export class OtelMetric extends Serializable<OtelMetricDocument> { | ||
| constructor(fields: OtelMetricDocument) { | ||
| super({ | ||
| ...fields, | ||
| }); | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
packages/kbn-apm-synthtrace-client/src/lib/otel/transaction.ts
This file contains hidden or 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,44 @@ | ||
| /* | ||
| * 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 { OtelDocument } from '.'; | ||
| import { Serializable } from '../serializable'; | ||
|
|
||
| export interface OtelTransactionDocument extends OtelDocument { | ||
| attributes?: { | ||
| 'event.outcome'?: string; | ||
| 'event.success_count'?: number; | ||
| 'processor.event'?: string; | ||
| 'timestamp.us'?: number; | ||
| 'transaction.duration.us'?: number; | ||
| 'transaction.id'?: string; | ||
| 'transaction.name'?: string; | ||
| 'transaction.representative_count'?: number; | ||
| 'transaction.result'?: string; | ||
| 'transaction.root'?: boolean; | ||
| 'transaction.sampled'?: boolean; | ||
| 'transaction.type'?: string; | ||
| }; | ||
| status?: { | ||
| code?: string; | ||
| }; | ||
| dropped_events_count?: number; | ||
| dropped_links_count?: number; | ||
| duration?: number; | ||
| kind?: string; | ||
| name?: string; | ||
| } | ||
|
|
||
| export class OtelTransaction extends Serializable<OtelTransactionDocument> { | ||
| constructor(fields: OtelTransactionDocument) { | ||
| super({ | ||
| ...fields, | ||
| }); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.