Skip to content
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

[APM][Otel] Use fields instead of _source on APM queries #195242

Merged
merged 34 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2e03596
Use fields instead of _source on APM queries
crespocarlos Oct 7, 2024
c02dd19
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Oct 7, 2024
880e270
Generic otel agent names; CR fixes
crespocarlos Oct 7, 2024
5756999
Change missing error queries for mobile
crespocarlos Oct 7, 2024
2adf0d1
Revert AgentName change; CR fixes
crespocarlos Oct 7, 2024
a466aa5
Fix service metadata details
crespocarlos Oct 7, 2024
e64e628
Improve test coverage
crespocarlos Oct 7, 2024
7b5db6c
Clean up
crespocarlos Oct 7, 2024
8e70280
More tests
crespocarlos Oct 7, 2024
e71abf1
Fix build
crespocarlos Oct 8, 2024
d0e7b12
Improve unflatten_object function and tests
crespocarlos Oct 8, 2024
7da8311
Error fixes
crespocarlos Oct 8, 2024
f99b34d
Fix error sample query
crespocarlos Oct 8, 2024
486e30e
CR fixes
crespocarlos Oct 8, 2024
548efb8
More tests fixes
crespocarlos Oct 8, 2024
2b75e7a
Revert kubernetes.namespace change
crespocarlos Oct 9, 2024
f0ab583
More tests fixes
crespocarlos Oct 9, 2024
8fc09c8
Update snapshot
crespocarlos Oct 9, 2024
f87748d
Merge branch 'main' into 192606-move-source-to-fields
elasticmachine Oct 9, 2024
cad4de0
Clean up
crespocarlos Oct 9, 2024
4382f12
Fix get_metadata_for_dependency query
crespocarlos Oct 9, 2024
1d4ebae
Merge branch 'main' into 192606-move-source-to-fields
elasticmachine Oct 11, 2024
06ec4ef
Fix error object handling
crespocarlos Oct 11, 2024
7e4e43e
Fix error correlation issue
jennypavlova Oct 11, 2024
7def09a
Merge pull request #4 from jennypavlova/fix-otel-error-correlation
crespocarlos Oct 14, 2024
3bfc69d
Merge branch 'main' into 192606-move-source-to-fields
elasticmachine Oct 14, 2024
e8dce71
Fix missing exception error in error details
jennypavlova Oct 14, 2024
cba684f
Merge pull request #5 from jennypavlova/196113-apmotelerrors-without-…
crespocarlos Oct 14, 2024
937e9f3
Make transaction fields optional because of the mobile services
jennypavlova Oct 14, 2024
40d5fa9
Merge pull request #6 from jennypavlova/196161-apmotel-fix-an-error-w…
crespocarlos Oct 14, 2024
4134daa
Make types optional to avoid error with undefined fields
jennypavlova Oct 14, 2024
bba14f9
Merge branch 'main' into 192606-move-source-to-fields
jennypavlova Oct 14, 2024
241a62f
Revert "Make types optional to avoid error with undefined fields"
crespocarlos Oct 15, 2024
db19165
Revert "Merge pull request #6 from jennypavlova/196161-apmotel-fix-an…
crespocarlos Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion packages/kbn-apm-types/src/es_fields/apm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export const TIMESTAMP = 'timestamp.us';
export const TIMESTAMP_US = 'timestamp.us';
export const AT_TIMESTAMP = '@timestamp';
export const AGENT = 'agent';
export const AGENT_NAME = 'agent.name';
export const AGENT_VERSION = 'agent.version';
Expand All @@ -21,9 +22,11 @@ export const CLOUD_PROVIDER = 'cloud.provider';
export const CLOUD_REGION = 'cloud.region';
export const CLOUD_MACHINE_TYPE = 'cloud.machine.type';
export const CLOUD_ACCOUNT_ID = 'cloud.account.id';
export const CLOUD_ACCOUNT_NAME = 'cloud.account.name';
export const CLOUD_INSTANCE_ID = 'cloud.instance.id';
export const CLOUD_INSTANCE_NAME = 'cloud.instance.name';
export const CLOUD_SERVICE_NAME = 'cloud.service.name';
export const CLOUD_PROJECT_NAME = 'cloud.project.name';

export const EVENT_SUCCESS_COUNT = 'event.success_count';

Expand All @@ -48,10 +51,14 @@ export const USER_ID = 'user.id';
export const USER_AGENT_ORIGINAL = 'user_agent.original';
export const USER_AGENT_NAME = 'user_agent.name';

export const OBSERVER_VERSION = 'observer.version';
export const OBSERVER_VERSION_MAJOR = 'observer.version_major';
export const OBSERVER_HOSTNAME = 'observer.hostname';
export const OBSERVER_LISTENING = 'observer.listening';
export const PROCESSOR_EVENT = 'processor.event';
export const PROCESSOR_NAME = 'processor.name';

export const TRANSACTION_AGENT_MARKS = 'transaction.agent.marks';
export const TRANSACTION_DURATION = 'transaction.duration.us';
export const TRANSACTION_DURATION_HISTOGRAM = 'transaction.duration.histogram';
export const TRANSACTION_DURATION_SUMMARY = 'transaction.duration.summary';
Expand Down Expand Up @@ -110,6 +117,7 @@ export const ERROR_EXC_MESSAGE = 'error.exception.message'; // only to be used i
export const ERROR_EXC_HANDLED = 'error.exception.handled'; // only to be used in es queries, since error.exception is now an array
export const ERROR_EXC_TYPE = 'error.exception.type';
export const ERROR_PAGE_URL = 'error.page.url';
export const ERROR_STACK_TRACE = 'error.stack_trace';
export const ERROR_TYPE = 'error.type';

// METRICS
Expand Down Expand Up @@ -153,6 +161,15 @@ export const CONTAINER_IMAGE = 'container.image.name';
export const KUBERNETES = 'kubernetes';
export const KUBERNETES_POD_NAME = 'kubernetes.pod.name';
export const KUBERNETES_POD_UID = 'kubernetes.pod.uid';
export const KUBERNETES_NAMESPACE = 'kubernetes.namespace';
export const KUBERNETES_NAMESPACE_NAME = 'kubernetes.namespace.name';
export const KUBERNETES_NODE_NAME = 'kubernetes.node.name';
export const KUBERNETES_CONTAINER_NAME = 'kubernetes.container.name';
export const KUBERNETES_CONTAINER_ID = 'kubernetes.container.id';
export const KUBERNETES_DEPLOYMENT = 'kubernetes.deployment';
crespocarlos marked this conversation as resolved.
Show resolved Hide resolved
export const KUBERNETES_DEPLOYMENT_NAME = 'kubernetes.deployment.name';
export const KUBERNETES_REPLICASET = 'kubernetes.replicaset';
export const KUBERNETES_REPLICASET_NAME = 'kubernetes.replicaset.name';

export const FAAS_ID = 'faas.id';
export const FAAS_NAME = 'faas.name';
Expand Down Expand Up @@ -198,3 +215,7 @@ export const CLIENT_GEO_REGION_NAME = 'client.geo.region_name';
export const CHILD_ID = 'child.id';

export const LOG_LEVEL = 'log.level';

// Process
export const PROCESS_ARGS = 'process.args';
export const PROCESS_PID = 'process.pid';
18 changes: 9 additions & 9 deletions packages/kbn-apm-types/src/es_schemas/raw/fields/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@
export interface Cloud {
availability_zone?: string;
instance?: {
name: string;
id: string;
name?: string;
id?: string;
};
machine?: {
type: string;
type?: string;
};
project?: {
id: string;
name: string;
id?: string;
name?: string;
};
provider?: string;
region?: string;
account?: {
id: string;
name: string;
id?: string;
name?: string;
};
image?: {
id: string;
id?: string;
};
service?: {
name: string;
name?: string;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@

export interface Container {
id?: string | null;
image?: string | null;
image?: {
name?: string;
};
}
4 changes: 2 additions & 2 deletions packages/kbn-apm-types/src/es_schemas/raw/fields/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

export interface Http {
request?: { method: string; [key: string]: unknown };
response?: { status_code: number; [key: string]: unknown };
request?: { method?: string };
response?: { status_code?: number };
version?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

export interface Kubernetes {
pod?: { uid?: string | null; [key: string]: unknown };
pod?: { uid?: string | null; name?: string };
namespace?: string;
replicaset?: {
name?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export interface Observer {
id?: string;
name?: string;
type?: string;
version: string;
version_major: number;
version?: string;
version_major?: number;
}
2 changes: 1 addition & 1 deletion packages/kbn-apm-types/src/es_schemas/raw/fields/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

// only for RUM agent: shared by error and transaction
export interface Page {
url: string;
url?: string;
}
8 changes: 4 additions & 4 deletions packages/kbn-apm-types/src/es_schemas/raw/fields/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ export interface Service {
name: string;
environment?: string;
framework?: {
name: string;
name?: string;
version?: string;
};
node?: {
name?: string;
};
runtime?: {
name: string;
version: string;
name?: string;
version?: string;
};
language?: {
name: string;
name?: string;
version?: string;
};
version?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-apm-types/src/es_schemas/raw/fields/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

export interface Url {
domain?: string;
full: string;
full?: string;
original?: string;
}
2 changes: 1 addition & 1 deletion packages/kbn-apm-types/src/es_schemas/raw/fields/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
*/

export interface User {
id: string;
id?: string;
}
30 changes: 3 additions & 27 deletions packages/kbn-elastic-agent-utils/src/agent_names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,10 @@ export const ELASTIC_AGENT_NAMES: ElasticAgentName[] = [
];

export type OpenTelemetryAgentName =
| 'otlp'
| 'opentelemetry'
| 'opentelemetry/cpp'
| 'opentelemetry/dotnet'
| 'opentelemetry/erlang'
| 'opentelemetry/go'
| 'opentelemetry/java'
| 'opentelemetry/nodejs'
| 'opentelemetry/php'
| 'opentelemetry/python'
| 'opentelemetry/ruby'
| 'opentelemetry/rust'
| 'opentelemetry/swift'
| 'opentelemetry/android'
| 'opentelemetry/webjs'
| 'otlp/cpp'
| 'otlp/dotnet'
| 'otlp/erlang'
| 'otlp/go'
| 'otlp/java'
| 'otlp/nodejs'
| 'otlp/php'
| 'otlp/python'
| 'otlp/ruby'
| 'otlp/rust'
| 'otlp/swift'
| 'otlp/android'
| 'otlp/webjs';
| 'otlp'
| `opentelemetry/${string}`
| `otlp/${string}`;
export const OPEN_TELEMETRY_AGENT_NAMES: OpenTelemetryAgentName[] = [
'otlp',
'opentelemetry',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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> = {}) {
crespocarlos marked this conversation as resolved.
Show resolved Hide resolved
// eslint-disable-next-line guard-for-in
for (const key in source) {
const val = source[key as keyof typeof source];
set(target, key, val);
}
return target;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
"@kbn/es-types",
"@kbn/apm-utils",
"@kbn/es-query",
"@kbn/safer-lodash-set",
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ export interface WaterfallSpan {
links?: SpanLink[];
};
transaction?: {
id: string;
id?: string;
};
child?: { id: string[] };
}

export interface WaterfallError {
timestamp: TimestampUs;
trace?: { id: string };
transaction?: { id: string };
parent?: { id: string };
trace?: { id?: string };
transaction?: { id?: string };
parent?: { id?: string };
span?: { id?: string };
error: {
id: string;
log?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,36 @@ import { EuiFlexItem, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import type { Message } from '@kbn/observability-ai-assistant-plugin/public';
import React, { useMemo, useState } from 'react';
import { AT_TIMESTAMP } from '@kbn/apm-types';
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
import { APMError } from '../../../../../typings/es_schemas/ui/apm_error';
import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import { ErrorSampleDetailTabContent } from './error_sample_detail';
import { exceptionStacktraceTab, logStacktraceTab } from './error_tabs';

export function ErrorSampleContextualInsight({
error,
transaction,
}: {
error: APMError;
transaction?: Transaction;
error: {
[AT_TIMESTAMP]: string;
error: Pick<APMError['error'], 'log' | 'exception' | 'id'>;
service: {
name: string;
environment?: string;
language?: {
name?: string;
};
runtime?: {
name?: string;
version?: string;
};
};
};
transaction?: {
transaction: {
name: string;
};
};
}) {
const { observabilityAIAssistant } = useApmPluginContext();

Expand Down
Loading