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

[One Discover] Display stacktrace in the logs overview tab #204521

Merged
merged 45 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
360019f
Create key-value-metadata-table package for the local variables table
gbamparop Dec 16, 2024
b41227d
Create package for event stacktrace
gbamparop Dec 17, 2024
6d1ad15
Update license
gbamparop Dec 17, 2024
b86953e
Delete metadata table from APM
gbamparop Dec 17, 2024
8939e2a
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Dec 17, 2024
dc0d679
Mark kbn-apm-types as platform/shared
gbamparop Dec 17, 2024
ca3ad1f
Mark kbn-key-value-metadata-table as platform/shared
gbamparop Dec 17, 2024
ee1df5b
Merge remote-tracking branch 'upstream/main' into discover-logs-stack…
gbamparop Dec 17, 2024
09296d5
Add stacktrace to the overview tab
gbamparop Dec 17, 2024
f3a7554
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine Dec 17, 2024
4411afa
Fix types
gbamparop Dec 17, 2024
fae18f2
Fix jest config
gbamparop Dec 17, 2024
2883cea
Fix Jest tests
gbamparop Dec 17, 2024
8b0965f
Fix Jest tests
gbamparop Dec 17, 2024
1321d95
Clean up code in logs overview stacktrace
gbamparop Dec 18, 2024
bda64c4
Add checks to not display the stacktrace section if there are no rele…
gbamparop Dec 18, 2024
0239a95
Add stacktrace section only when there is data available
gbamparop Dec 18, 2024
82c9f10
Handle cases when the data format is not the one expected
gbamparop Dec 18, 2024
2db6a10
Migrate styled components to emotion
gbamparop Dec 18, 2024
947f4a7
Merge remote-tracking branch 'upstream/main' into discover-logs-stack…
gbamparop Dec 18, 2024
73d2bc0
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Dec 18, 2024
26dc723
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Dec 19, 2024
94863ab
Merge remote-tracking branch 'upstream/main' into discover-logs-stack…
gbamparop Dec 30, 2024
4f6bdb9
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine Dec 30, 2024
afed5ff
Fix CODEOWNERS
gbamparop Dec 31, 2024
6838a56
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Dec 31, 2024
315327d
Remove kibanaReact dependency
gbamparop Dec 31, 2024
aaebe33
Update jest config path in README
gbamparop Dec 31, 2024
9280aab
Add package.json to kbn-apm-types package
gbamparop Dec 31, 2024
a98458d
Fix funtional tests
gbamparop Dec 31, 2024
e469f4e
Add jest tests
gbamparop Dec 31, 2024
c93fa17
Update functional tests
gbamparop Dec 31, 2024
ce72d6e
Fix synthtrace types
gbamparop Dec 31, 2024
23fbe85
Merge remote-tracking branch 'upstream/main' into discover-logs-stack…
gbamparop Jan 6, 2025
997e251
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jan 6, 2025
b16b154
Merge remote-tracking branch 'upstream/main' into discover-logs-stack…
gbamparop Jan 16, 2025
4b3d5cd
Fix typo
gbamparop Jan 16, 2025
23c45e4
Import StackframeWithLineContext as a type
gbamparop Jan 16, 2025
1e0567e
Change font size for exception title
gbamparop Jan 16, 2025
63dc8a2
Merge remote-tracking branch 'upstream/main' into discover-logs-stack…
gbamparop Jan 21, 2025
b4136ae
Remove emotion.d.ts from packages
gbamparop Jan 21, 2025
4df34cf
Rename flattenObject function to getFlattenedKeyValuePairs
gbamparop Jan 21, 2025
818bd02
Add horizontal rule after the stacktrace section
gbamparop Jan 21, 2025
346a621
Remove IntlProvider from tests
gbamparop Jan 21, 2025
79a2b20
Merge remote-tracking branch 'upstream/main' into discover-logs-stack…
gbamparop Jan 21, 2025
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
4 changes: 3 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -801,12 +801,15 @@ x-pack/platform/packages/shared/index-lifecycle-management/index_lifecycle_manag
x-pack/platform/packages/shared/index-management/index_management_shared_types @elastic/kibana-management
x-pack/platform/packages/shared/kbn-ai-assistant @elastic/search-kibana
x-pack/platform/packages/shared/kbn-alerting-comparators @elastic/response-ops
x-pack/platform/packages/shared/kbn-apm-types @elastic/obs-ux-infra_services-team
x-pack/platform/packages/shared/kbn-cloud-security-posture/common @elastic/kibana-cloud-security-posture
x-pack/platform/packages/shared/kbn-data-forge @elastic/obs-ux-management-team
x-pack/platform/packages/shared/kbn-elastic-assistant @elastic/security-generative-ai
x-pack/platform/packages/shared/kbn-elastic-assistant-common @elastic/security-generative-ai
x-pack/platform/packages/shared/kbn-entities-schema @elastic/obs-entities
x-pack/platform/packages/shared/kbn-event-stacktrace @elastic/obs-ux-infra_services-team @elastic/obs-ux-logs-team
x-pack/platform/packages/shared/kbn-inference-endpoint-ui-common @elastic/response-ops @elastic/appex-ai-infra @elastic/obs-ai-assistant @elastic/security-generative-ai
x-pack/platform/packages/shared/kbn-key-value-metadata-table @elastic/obs-ux-infra_services-team @elastic/obs-ux-logs-team
x-pack/platform/packages/shared/kbn-langchain @elastic/security-generative-ai
x-pack/platform/packages/shared/kbn-slo-schema @elastic/obs-ux-management-team
x-pack/platform/packages/shared/ml/aiops_common @elastic/ml-ui
Expand Down Expand Up @@ -907,7 +910,6 @@ x-pack/solutions/observability/packages/alert_details @elastic/obs-ux-management
x-pack/solutions/observability/packages/alerting_test_data @elastic/obs-ux-management-team
x-pack/solutions/observability/packages/get_padded_alert_time_range_util @elastic/obs-ux-management-team
x-pack/solutions/observability/packages/kbn-alerts-grouping @elastic/response-ops
x-pack/solutions/observability/packages/kbn-apm-types @elastic/obs-ux-infra_services-team
x-pack/solutions/observability/packages/kbn-custom-integrations @elastic/obs-ux-logs-team
x-pack/solutions/observability/packages/kbn-investigation-shared @elastic/obs-ux-management-team
x-pack/solutions/observability/packages/kbn-streams-schema @elastic/streams-program-team
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"@kbn/apm-data-access-plugin": "link:x-pack/solutions/observability/plugins/apm_data_access",
"@kbn/apm-data-view": "link:src/platform/packages/shared/kbn-apm-data-view",
"@kbn/apm-plugin": "link:x-pack/solutions/observability/plugins/apm",
"@kbn/apm-types": "link:x-pack/solutions/observability/packages/kbn-apm-types",
"@kbn/apm-types": "link:x-pack/platform/packages/shared/kbn-apm-types",
"@kbn/apm-utils": "link:src/platform/packages/shared/kbn-apm-utils",
"@kbn/app-link-test-plugin": "link:test/plugin_functional/plugins/app_link_test",
"@kbn/application-usage-test-plugin": "link:x-pack/test/usage_collection/plugins/application_usage_test",
Expand Down Expand Up @@ -499,6 +499,7 @@
"@kbn/event-annotation-plugin": "link:src/platform/plugins/private/event_annotation",
"@kbn/event-log-fixture-plugin": "link:x-pack/test/plugin_api_integration/plugins/event_log",
"@kbn/event-log-plugin": "link:x-pack/platform/plugins/shared/event_log",
"@kbn/event-stacktrace": "link:x-pack/platform/packages/shared/kbn-event-stacktrace",
"@kbn/expandable-flyout": "link:x-pack/solutions/security/packages/expandable-flyout",
"@kbn/exploratory-view-example-plugin": "link:x-pack/examples/exploratory_view_example",
"@kbn/exploratory-view-plugin": "link:x-pack/solutions/observability/plugins/exploratory_view",
Expand Down Expand Up @@ -596,6 +597,7 @@
"@kbn/kbn-top-nav-plugin": "link:test/plugin_functional/plugins/kbn_top_nav",
"@kbn/kbn-tp-custom-visualizations-plugin": "link:test/plugin_functional/plugins/kbn_tp_custom_visualizations",
"@kbn/kbn-tp-run-pipeline-plugin": "link:test/interpreter_functional/plugins/kbn_tp_run_pipeline",
"@kbn/key-value-metadata-table": "link:x-pack/platform/packages/shared/kbn-key-value-metadata-table",
"@kbn/kibana-cors-test-plugin": "link:x-pack/test/functional_cors/plugins/kibana_cors_test",
"@kbn/kibana-overview-plugin": "link:src/platform/plugins/private/kibana_overview",
"@kbn/kibana-react-plugin": "link:src/platform/plugins/shared/kibana_react",
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-apm-synthtrace-client/src/lib/logs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export type LogDocument = Fields &
'cloud.project.id'?: string;
'cloud.instance.id'?: string;
'error.stack_trace'?: string;
'error.exception.stacktrace'?: string;
'error.log.stacktrace'?: string;
'error.exception'?: unknown;
'error.log'?: unknown;
'log.custom': Record<string, unknown>;
'host.geo.location': number[];
'host.ip': string;
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-apm-synthtrace/src/scenarios/simple_logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const scenario: Scenario<LogDocument> = async (runOptions) => {
.defaults({
...commonLongEntryFields,
'error.message': message,
'error.exception.stacktrace': 'Error message in error.exception.stacktrace',
'error.stack_trace': 'Stacktrace',
})
.timestamp(timestamp);
});
Expand Down Expand Up @@ -174,7 +174,7 @@ const scenario: Scenario<LogDocument> = async (runOptions) => {
.defaults({
...commonLongEntryFields,
'event.original': message,
'error.log.stacktrace': 'Error message in error.log.stacktrace',
'error.stack_trace': 'Stacktrace',
'event.start': eventDate,
'event.end': moment(eventDate).add(1, 'm').toDate(),
})
Expand Down Expand Up @@ -203,7 +203,7 @@ const scenario: Scenario<LogDocument> = async (runOptions) => {
.setHostIp(getIpAddress())
.defaults({
...commonLongEntryFields,
'error.stack_trace': 'Error message in error.stack_trace',
'error.stack_trace': 'Stacktrace',
})
.timestamp(timestamp);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
generateLongId,
generateShortId,
Instance,
LogDocument,
} from '@kbn/apm-synthtrace-client';
import { Scenario } from '../cli/scenario';
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment';
Expand All @@ -26,7 +27,7 @@ const ENVIRONMENT = getSynthtraceEnvironment(__filename);
const alwaysSpikeTransactionName = 'GET /always-spike';
const sometimesSpikeTransactionName = 'GET /sometimes-spike';

const scenario: Scenario<ApmFields> = async ({ logger, ...runOptions }) => {
const scenario: Scenario<LogDocument | ApmFields> = async ({ logger, ...runOptions }) => {
const { isLogsDb } = parseLogsScenarioOpts(runOptions.scenarioOpts);

return {
Expand Down
1 change: 1 addition & 0 deletions src/dev/storybook/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ export const storybookAliases = {
ui_actions_enhanced: 'src/platform/plugins/shared/ui_actions_enhanced/.storybook',
unified_search: 'src/platform/plugins/shared/unified_search/.storybook',
profiling: 'x-pack/solutions/observability/plugins/profiling/.storybook',
event_stacktrace: 'x-pack/platform/packages/shared/kbn-event-stacktrace/.storybook',
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export interface LogDocument extends DataTableRecord {
'data_stream.dataset': string;

'error.stack_trace'?: string;
'error.exception.stacktrace'?: string;
'error.log.stacktrace'?: string;
'error.exception.stacktrace.abs_path'?: string;
'error.log.stacktrace.abs_path'?: string;
};
}

Expand Down Expand Up @@ -83,8 +83,8 @@ export interface ResourceFields {

export interface StackTraceFields {
'error.stack_trace'?: string;
'error.exception.stacktrace'?: string;
'error.log.stacktrace'?: string;
'error.exception.stacktrace.abs_path'?: string;
'error.log.stacktrace.abs_path'?: string;
}

export interface SmartFieldGridColumnOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const TRACE_ID_FIELD = 'trace.id';
export const LOG_FILE_PATH_FIELD = 'log.file.path';
export const DATASTREAM_NAMESPACE_FIELD = 'data_stream.namespace';
export const DATASTREAM_DATASET_FIELD = 'data_stream.dataset';
export const DATASTREAM_TYPE_FIELD = 'data_stream.type';

// Resource Fields
export const AGENT_NAME_FIELD = 'agent.name';
Expand All @@ -41,5 +42,5 @@ export const DEGRADED_DOCS_FIELDS = [IGNORED_FIELD, IGNORED_FIELD_VALUES_FIELD]

// Error Stacktrace
export const ERROR_STACK_TRACE = 'error.stack_trace';
export const ERROR_EXCEPTION_STACKTRACE = 'error.exception.stacktrace';
export const ERROR_LOG_STACKTRACE = 'error.log.stacktrace';
export const ERROR_EXCEPTION_STACKTRACE_ABS_PATH = 'error.exception.stacktrace.abs_path';
export const ERROR_LOG_STACKTRACE_ABS_PATH = 'error.log.stacktrace.abs_path';
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@

import { getFieldValue, LogDocument, StackTraceFields } from '..';
import {
ERROR_EXCEPTION_STACKTRACE,
ERROR_LOG_STACKTRACE,
ERROR_EXCEPTION_STACKTRACE_ABS_PATH,
ERROR_LOG_STACKTRACE_ABS_PATH,
ERROR_STACK_TRACE,
} from '../field_constants';

export const getStacktraceFields = (doc: LogDocument): StackTraceFields => {
const errorStackTrace = getFieldValue(doc, ERROR_STACK_TRACE);
const errorExceptionStackTrace = getFieldValue(doc, ERROR_EXCEPTION_STACKTRACE);
const errorLogStackTrace = getFieldValue(doc, ERROR_LOG_STACKTRACE);
const errorExceptionStackTrace = getFieldValue(doc, ERROR_EXCEPTION_STACKTRACE_ABS_PATH);
const errorLogStackTrace = getFieldValue(doc, ERROR_LOG_STACKTRACE_ABS_PATH);

return {
[ERROR_STACK_TRACE]: errorStackTrace,
[ERROR_EXCEPTION_STACKTRACE]: errorExceptionStackTrace,
[ERROR_LOG_STACKTRACE]: errorLogStackTrace,
[ERROR_EXCEPTION_STACKTRACE_ABS_PATH]: errorExceptionStackTrace,
[ERROR_LOG_STACKTRACE_ABS_PATH]: errorLogStackTrace,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"kibanaUtils"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import { DocViewRenderProps } from '@kbn/unified-doc-viewer/types';
import { getLogDocumentOverview } from '@kbn/discover-utils';
import { EuiHorizontalRule, EuiSpacer } from '@elastic/eui';
import { ObservabilityLogsAIAssistantFeatureRenderDeps } from '@kbn/discover-shared-plugin/public';
import { getStacktraceFields, LogDocument } from '@kbn/discover-utils/src';
import { LogsOverviewHeader } from './logs_overview_header';
import { LogsOverviewHighlights } from './logs_overview_highlights';
import { FieldActionsProvider } from '../../hooks/use_field_actions';
import { getUnifiedDocViewerServices } from '../../plugin';
import { LogsOverviewDegradedFields } from './logs_overview_degraded_fields';
import { LogsOverviewStacktraceSection } from './logs_overview_stacktrace_section';

export type LogsOverviewProps = DocViewRenderProps & {
renderAIAssistant?: (deps: ObservabilityLogsAIAssistantFeatureRenderDeps) => JSX.Element;
Expand All @@ -34,6 +36,8 @@ export function LogsOverview({
const { fieldFormats } = getUnifiedDocViewerServices();
const parsedDoc = getLogDocumentOverview(hit, { dataView, fieldFormats });
const LogsOverviewAIAssistant = renderAIAssistant;
const stacktraceFields = getStacktraceFields(hit as LogDocument);
const isStacktraceAvailable = Object.values(stacktraceFields).some(Boolean);

return (
<FieldActionsProvider
Expand All @@ -47,6 +51,7 @@ export function LogsOverview({
<EuiHorizontalRule margin="xs" />
<LogsOverviewHighlights formattedDoc={parsedDoc} flattenedDoc={hit.flattened} />
<LogsOverviewDegradedFields rawDoc={hit.raw} />
{isStacktraceAvailable && <LogsOverviewStacktraceSection hit={hit} dataView={dataView} />}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we probably need some spacing here to separate from the AI Assistant.
Screenshot 2025-01-17 at 14 46 18

Copy link
Contributor Author

@gbamparop gbamparop Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot, a horizontal rule was added in 818bd02 to match the other sections:

Quality

Screenshot 2025-01-21 at 14 50 54

Stacktrace

Screenshot 2025-01-21 at 14 51 22

{LogsOverviewAIAssistant && <LogsOverviewAIAssistant doc={hit} />}
</FieldActionsProvider>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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 { EuiAccordion, EuiHorizontalRule, EuiTitle, useGeneratedHtmlId } from '@elastic/eui';
import { DataTableRecord } from '@kbn/discover-utils';
import { i18n } from '@kbn/i18n';
import React from 'react';
import type { DataView } from '@kbn/data-views-plugin/public';
import { StacktraceContent } from './sub_components/stacktrace/stacktrace_content';

const stacktraceAccordionTitle = i18n.translate(
'unifiedDocViewer.docView.logsOverview.accordion.title.stacktrace',
{
defaultMessage: 'Stacktrace',
}
);

export function LogsOverviewStacktraceSection({
hit,
dataView,
}: {
hit: DataTableRecord;
dataView: DataView;
}) {
const accordionId = useGeneratedHtmlId({
prefix: stacktraceAccordionTitle,
});

return (
<>
<EuiAccordion
id={accordionId}
buttonContent={
<EuiTitle size="xs">
<p>{stacktraceAccordionTitle}</p>
</EuiTitle>
}
paddingSize="m"
initialIsOpen={false}
data-test-subj="unifiedDocViewLogsOverviewStacktraceAccordion"
>
<StacktraceContent hit={hit} dataView={dataView} />
</EuiAccordion>
<EuiHorizontalRule margin="xs" />
</>
);
}
Loading
Loading