Skip to content

Commit

Permalink
Create package for event stacktrace
Browse files Browse the repository at this point in the history
  • Loading branch information
gbamparop committed Dec 17, 2024
1 parent 360019f commit b41227d
Show file tree
Hide file tree
Showing 87 changed files with 199 additions and 65 deletions.
3 changes: 2 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/plugins/observability_solution/apm_data_access",
"@kbn/apm-data-view": "link:packages/kbn-apm-data-view",
"@kbn/apm-plugin": "link:x-pack/plugins/observability_solution/apm",
"@kbn/apm-types": "link:packages/kbn-apm-types",
"@kbn/apm-types": "link:x-pack/platform/packages/shared/kbn-apm-types",
"@kbn/apm-utils": "link:packages/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 @@ -505,6 +505,7 @@
"@kbn/event-annotation-plugin": "link:src/plugins/event_annotation",
"@kbn/event-log-fixture-plugin": "link:x-pack/test/plugin_api_integration/plugins/event_log",
"@kbn/event-log-plugin": "link:x-pack/plugins/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
1 change: 1 addition & 0 deletions src/dev/storybook/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ export const storybookAliases = {
ui_actions_enhanced: 'src/plugins/ui_actions_enhanced/.storybook',
unified_search: 'src/plugins/unified_search/.storybook',
profiling: 'x-pack/plugins/observability_solution/profiling/.storybook',
event_stacktrace: 'x-pack/platform/packages/shared/kbn-event-stacktrace/.storybook',
};
5 changes: 3 additions & 2 deletions src/plugins/unified_doc_viewer/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"requiredPlugins": [
"data",
"fieldFormats",
"share"
"share",
"kibanaReact"
],
"optionalPlugins": [
"fieldsMetadata"
Expand All @@ -23,4 +24,4 @@
"kibanaUtils"
]
}
}
}
5 changes: 4 additions & 1 deletion src/plugins/unified_doc_viewer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
"@kbn/router-utils",
"@kbn/unified-field-list",
"@kbn/core-lifecycle-browser",
"@kbn/management-settings-ids"
"@kbn/management-settings-ids",
"@kbn/apm-types",
"@kbn/event-stacktrace"

],
"exclude": [
"target/**/*",
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
"@kbn/apm-synthtrace/*": ["packages/kbn-apm-synthtrace/*"],
"@kbn/apm-synthtrace-client": ["packages/kbn-apm-synthtrace-client"],
"@kbn/apm-synthtrace-client/*": ["packages/kbn-apm-synthtrace-client/*"],
"@kbn/apm-types": ["packages/kbn-apm-types"],
"@kbn/apm-types/*": ["packages/kbn-apm-types/*"],
"@kbn/apm-types": ["x-pack/platform/packages/shared/kbn-apm-types"],
"@kbn/apm-types/*": ["x-pack/platform/packages/shared/kbn-apm-types/*"],
"@kbn/apm-utils": ["packages/kbn-apm-utils"],
"@kbn/apm-utils/*": ["packages/kbn-apm-utils/*"],
"@kbn/app-link-test-plugin": ["test/plugin_functional/plugins/app_link_test"],
Expand Down Expand Up @@ -894,6 +894,8 @@
"@kbn/event-log-fixture-plugin/*": ["x-pack/test/plugin_api_integration/plugins/event_log/*"],
"@kbn/event-log-plugin": ["x-pack/plugins/event_log"],
"@kbn/event-log-plugin/*": ["x-pack/plugins/event_log/*"],
"@kbn/event-stacktrace": ["x-pack/platform/packages/shared/kbn-event-stacktrace"],
"@kbn/event-stacktrace/*": ["x-pack/platform/packages/shared/kbn-event-stacktrace/*"],
"@kbn/expandable-flyout": ["x-pack/solutions/security/packages/expandable-flyout"],
"@kbn/expandable-flyout/*": ["x-pack/solutions/security/packages/expandable-flyout/*"],
"@kbn/expect": ["packages/kbn-expect"],
Expand Down
4 changes: 3 additions & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@
"solutions/observability/plugins/ux"
],
"xpack.urlDrilldown": "plugins/drilldowns/url_drilldown",
"xpack.watcher": "platform/plugins/private/watcher"
"xpack.watcher": "platform/plugins/private/watcher",
"xpack.eventStacktrace": "platform/packages/shared/kbn-event-stacktrace"

},
"exclude": [
"examples"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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.
*/

module.exports = require('@kbn/storybook').defaultConfig;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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 { EuiThemeProviderDecorator } from '@kbn/kibana-react-plugin/common';
export const decorators = [EuiThemeProviderDecorator];
18 changes: 18 additions & 0 deletions x-pack/platform/packages/shared/kbn-event-stacktrace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# @kbn/event-stacktrace

This package contains components that render event (error, log, span) stack traces.

## Unit Tests (Jest)

```
node scripts/jest --config packages/kbn-event-stacktrace/jest.config.js [--watch]
```

## Storybook

### Start
```
yarn storybook event_stacktrace
```

All files with a .stories.tsx extension will be loaded. You can access the development environment at http://localhost:9001.
15 changes: 15 additions & 0 deletions x-pack/platform/packages/shared/kbn-event-stacktrace/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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.
*/

export * from './src/components/stacktrace/cause_stacktrace';
export * from './src/components/stacktrace/frame_heading';
export * from './src/components/stacktrace';
export * from './src/components/stacktrace/library_stacktrace';
export * from './src/components/stacktrace/stackframe';
export * from './src/components/stacktrace/variables';
export * from './src/components/stacktrace/plain/plaintext_stacktrace';
export * from './src/components/stacktrace/exception/exception_stacktrace';
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/kbn-event-stacktrace'],
};
10 changes: 10 additions & 0 deletions x-pack/platform/packages/shared/kbn-event-stacktrace/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "shared-browser",
"id": "@kbn/event-stacktrace",
"owner": [
"@elastic/obs-ux-infra_services-team",
"@elastic/obs-ux-logs-team"
],
"group": "platform",
"visibility": "shared"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@kbn/apm-types",
"name": "@kbn/event-stacktrace",
"private": true,
"version": "1.0.0",
"license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { shallow } from 'enzyme';
import React from 'react';
import { mountWithTheme } from '../../../utils/test_helpers';
import { mountWithTheme } from '../../utils/test_helpers';
import { CauseStacktrace } from './cause_stacktrace';

describe('CauseStacktrace', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { EuiAccordion, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { Stackframe } from '@kbn/apm-types';
import { Stacktrace } from '.';
import { Stackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';

const Accordion = euiStyled(EuiAccordion)`
border-top: ${({ theme }) => theme.eui.euiBorderThin};
Expand All @@ -37,7 +37,7 @@ function CausedBy({ message }: { message: string }) {
return (
<CausedByContainer>
<CausedByHeading>
{i18n.translate('xpack.apm.stacktraceTab.causedByFramesToogleButtonLabel', {
{i18n.translate('xpack.eventStacktrace.stacktraceTab.causedByFramesToogleButtonLabel', {
defaultMessage: 'Caused By',
})}
</CausedByHeading>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import python from 'react-syntax-highlighter/dist/cjs/languages/hljs/python';
import ruby from 'react-syntax-highlighter/dist/cjs/languages/hljs/ruby';
import xcode from 'react-syntax-highlighter/dist/cjs/styles/hljs/xcode';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { StackframeWithLineContext } from '../../../../typings/es_schemas/raw/fields/stackframe';
import { StackframeWithLineContext } from '@kbn/apm-types/src/es_schemas/raw/fields/stackframe';

SyntaxHighlighter.registerLanguage('javascript', javascript);
SyntaxHighlighter.registerLanguage('python', python);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/

import React from 'react';
import { Exception } from '../../../../../typings/es_schemas/raw/error_raw';
import { Stacktrace } from '../../../shared/stacktrace';
import { CauseStacktrace } from '../../../shared/stacktrace/cause_stacktrace';
import type { Exception } from '@kbn/apm-types/es_schemas_raw';
import { ExceptionStacktraceTitle } from './exception_stacktrace_title';
import { CauseStacktrace } from '../cause_stacktrace';
import { Stacktrace } from '..';

interface ExceptionStacktraceProps {
codeLanguage?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import React from 'react';
import { Stackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
import { renderWithTheme } from '../../../utils/test_helpers';
import { Stackframe } from '@kbn/apm-types';
import { renderWithTheme } from '../../utils/test_helpers';
import { FrameHeading } from './frame_heading';

function getRenderedStackframeText(stackframe: Stackframe, codeLanguage: string, idx: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React, { ComponentType } from 'react';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { Stackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
import type { Stackframe } from '@kbn/apm-types';
import {
CSharpFrameHeadingRenderer,
DefaultFrameHeadingRenderer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { ComponentType } from 'react';
import { Stackframe } from '../../../../../typings/es_schemas/raw/fields/stackframe';
import type { Stackframe } from '@kbn/apm-types';

export interface FrameHeadingRendererProps {
fileDetailComponent: ComponentType<React.PropsWithChildren<{}>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import { i18n } from '@kbn/i18n';
import { isEmpty, last } from 'lodash';
import React, { Fragment } from 'react';
import { EuiCodeBlock } from '@elastic/eui';
import { Stackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
import { EmptyMessage } from '../empty_message';
import { EuiCodeBlock, EuiEmptyPrompt } from '@elastic/eui';
import type { Stackframe } from '@kbn/apm-types';
import { LibraryStacktrace } from './library_stacktrace';
import { Stackframe as StackframeComponent } from './stackframe';

Expand All @@ -23,11 +22,15 @@ interface Props {
export function Stacktrace({ stackframes = [], codeLanguage }: Props) {
if (isEmpty(stackframes)) {
return (
<EmptyMessage
heading={i18n.translate('xpack.apm.stacktraceTab.noStacktraceAvailableLabel', {
defaultMessage: 'No stack trace available.',
})}
hideSubheading
<EuiEmptyPrompt
titleSize="s"
title={
<div>
{i18n.translate('xpack.eventStacktrace.stacktraceTab.noStacktraceAvailableLabel', {
defaultMessage: 'No stack trace available.',
})}
</div>
}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import { renderWithTheme } from '../../../utils/test_helpers';
import { renderWithTheme } from '../../utils/test_helpers';
import { LibraryStacktrace } from './library_stacktrace';

describe('LibraryStacktrace', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiAccordion } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { Stackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
import type { Stackframe } from '@kbn/apm-types';
import { Stackframe as StackframeComponent } from './stackframe';

const LibraryStacktraceAccordion = euiStyled(EuiAccordion)`
Expand All @@ -29,10 +29,13 @@ export function LibraryStacktrace({ codeLanguage, id, stackframes }: Props) {

return (
<LibraryStacktraceAccordion
buttonContent={i18n.translate('xpack.apm.stacktraceTab.libraryFramesToogleButtonLabel', {
defaultMessage: '{count, plural, one {# library frame} other {# library frames}}',
values: { count: stackframes.length },
})}
buttonContent={i18n.translate(
'xpack.eventStacktrace.stacktraceTab.libraryFramesToogleButtonLabel',
{
defaultMessage: '{count, plural, one {# library frame} other {# library frames}}',
values: { count: stackframes.length },
}
)}
data-test-subj="LibraryStacktraceAccordion"
id={id}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';
import { EuiCodeBlock } from '@elastic/eui';
import { ExceptionStacktraceTitle } from './exception_stacktrace_title';
import { ExceptionStacktraceTitle } from '../exception/exception_stacktrace_title';

interface PlaintextStacktraceProps {
codeLanguage?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import React from 'react';
import { ReactWrapper, shallow } from 'enzyme';
import { Stackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
import { mountWithTheme } from '../../../utils/test_helpers';
import type { Stackframe } from '@kbn/apm-types';
import { mountWithTheme } from '../../utils/test_helpers';
import { Stackframe as StackframeComponent } from './stackframe';
import stacktracesMock from './__fixtures__/stacktraces.json';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import { EuiAccordion } from '@elastic/eui';
import React from 'react';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import {
Stackframe as StackframeType,
StackframeWithLineContext,
} from '../../../../typings/es_schemas/raw/fields/stackframe';
import type { Stackframe as StackframeType, StackframeWithLineContext } from '@kbn/apm-types';
import { Context } from './context';
import { FrameHeading } from './frame_heading';
import { Variables } from './variables';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { Stackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
import { Stackframe } from '@kbn/apm-types';
import { getGroupedStackframes } from '.';
import stacktracesMock from './__fixtures__/stacktraces.json';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n';
import React from 'react';
import { euiStyled } from '@kbn/kibana-react-plugin/common';
import { KeyValueTable, flattenObject } from '@kbn/key-value-metadata-table';
import { Stackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
import { Stackframe } from '@kbn/apm-types';

const VariablesContainer = euiStyled.div`
background: ${({ theme }) => theme.eui.euiColorEmptyShade};
Expand All @@ -27,17 +27,19 @@ export function Variables({ vars }: Props) {
if (!vars) {
return null;
}
console.log(vars);
const flattenedVariables = flattenObject(vars);
return (
<React.Fragment>
<VariablesContainer>
<EuiAccordion
id="local-variables"
className="euiAccordion"
buttonContent={i18n.translate('xpack.apm.stacktraceTab.localVariablesToogleButtonLabel', {
defaultMessage: 'Local variables',
})}
buttonContent={i18n.translate(
'xpack.eventStacktrace.stacktraceTab.localVariablesToogleButtonLabel',
{
defaultMessage: 'Local variables',
}
)}
>
<React.Fragment>
<KeyValueTable keyValuePairs={flattenedVariables} />
Expand Down
Loading

0 comments on commit b41227d

Please sign in to comment.