Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 2 deletions src/platform/packages/shared/kbn-discover-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export {
formatHit,
getDocId,
getLogDocumentOverview,
getTransactionDocumentOverview,
getSpanDocumentOverview,
getTraceDocumentOverview,
getFlattenedTraceDocumentOverview,
getIgnoredReason,
getMessageFieldWithFallbacks,
getShouldShowFieldHandler,
Expand Down
17 changes: 5 additions & 12 deletions src/platform/packages/shared/kbn-discover-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,12 @@ export interface LogCloudFields {
'cloud.instance.id'?: string;
}

export interface TransactionDocumentOverview
export interface TraceDocumentOverview
extends TraceFields,
ServiceFields,
TransactionFields,
UserAgentFields {}

export interface SpanDocumentOverview
extends TraceFields,
ServiceFields,
SpanFields,
UserAgentFields {
'transaction.id'?: string;
'transaction.name'?: string;
Partial<ServiceFields>,
Partial<SpanFields>,
Partial<UserAgentFields>,
Partial<TransactionFields> {
duration?: number;
kind?: string;
'resource.attributes.telemetry.sdk.language'?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

import type { DataView } from '@kbn/data-views-plugin/common';
import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import type { DataTableRecord, SpanDocumentOverview } from '../types';
import type { DataTableRecord, TraceDocumentOverview } from '../types';
import { fieldConstants } from '..';
import { getFormattedFields } from './get_formatted_fields';
import { getFlattenedFields } from './get_flattened_fields';

const fields: Array<keyof SpanDocumentOverview> = [
const fields: Array<keyof TraceDocumentOverview> = [
fieldConstants.TIMESTAMP_FIELD,
fieldConstants.PARENT_ID_FIELD,
fieldConstants.HTTP_RESPONSE_STATUS_CODE_FIELD,
Expand All @@ -24,6 +24,10 @@ const fields: Array<keyof SpanDocumentOverview> = [
fieldConstants.AGENT_NAME_FIELD,
fieldConstants.TRANSACTION_ID_FIELD,
fieldConstants.TRANSACTION_NAME_FIELD,
fieldConstants.TRANSACTION_DURATION_FIELD,
fieldConstants.TRANSACTION_TYPE_FIELD,
fieldConstants.USER_AGENT_NAME_FIELD,
fieldConstants.USER_AGENT_VERSION_FIELD,
fieldConstants.SPAN_NAME_FIELD,
fieldConstants.SPAN_ID_FIELD,
fieldConstants.SPAN_ACTION_FIELD,
Expand All @@ -43,13 +47,13 @@ const fields: Array<keyof SpanDocumentOverview> = [
fieldConstants.OTEL_LINKS_TRACE_ID,
];

export function getSpanDocumentOverview(
export function getTraceDocumentOverview(
doc: DataTableRecord,
{ dataView, fieldFormats }: { dataView: DataView; fieldFormats: FieldFormatsStart }
): SpanDocumentOverview {
return getFormattedFields<SpanDocumentOverview>(doc, fields, { dataView, fieldFormats });
): TraceDocumentOverview {
return getFormattedFields<TraceDocumentOverview>(doc, fields, { dataView, fieldFormats });
}

export function getFlattenedSpanDocumentOverview(doc: DataTableRecord): SpanDocumentOverview {
return getFlattenedFields<SpanDocumentOverview>(doc, fields);
export function getFlattenedTraceDocumentOverview(doc: DataTableRecord): TraceDocumentOverview {
return getFlattenedFields<TraceDocumentOverview>(doc, fields);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export * from './format_value';
export * from './get_doc_id';
export * from './get_ignored_reason';
export * from './get_log_document_overview';
export * from './get_transaction_document_overview';
export * from './get_span_document_overview';
export * from './get_trace_document_overview';
export * from './get_message_field_with_fallbacks';
export * from './get_should_show_field_handler';
export * from './get_stack_trace_fields';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ describe('<DocumentProfileTable />', () => {
getDataTableRecordWithContextMock({
id: 'record2',
raw: generateEsHit({ _id: 'some other record' }),
context: getDocumentContextMock({ type: DocumentType.Span }),
context: getDocumentContextMock({ type: DocumentType.Trace }),
}),
getDataTableRecordWithContextMock({
id: 'record3',
raw: generateEsHit({ _id: 'one specific record' }),
context: getDocumentContextMock({ type: DocumentType.Transaction }),
context: getDocumentContextMock({ type: DocumentType.Trace }),
}),
];

Expand All @@ -87,8 +87,7 @@ describe('<DocumentProfileTable />', () => {

// Then
expect(screen.getByText('log')).toBeVisible();
expect(screen.getByText('span')).toBeVisible();
expect(screen.getByText('transaction')).toBeVisible();
expect(screen.getAllByText('trace')).toHaveLength(2);
});

describe('when the inspect action is clicked', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@

import type { ProfileProviderServices } from '../profile_provider_services';
import { createObservabilityLogDocumentProfileProvider } from './log_document_profile';
import { createObservabilityTracesSpanDocumentProfileProvider } from './traces_document_profile/span_document_profile';
import { createObservabilityTracesTransactionDocumentProfileProvider } from './traces_document_profile/transaction_document_profile';
import { createObservabilityTracesDocumentProfileProvider } from './traces_document_profile/document_profile';

export const createObservabilityDocumentProfileProviders = (
providerServices: ProfileProviderServices
) => {
return [
createObservabilityLogDocumentProfileProvider(providerServices),
createObservabilityTracesSpanDocumentProfileProvider(providerServices),
createObservabilityTracesTransactionDocumentProfileProvider(providerServices),
createObservabilityTracesDocumentProfileProvider(providerServices),
];
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import React from 'react';
import { i18n } from '@kbn/i18n';
import { UnifiedDocViewerObservabilityTracesSpanOverview } from '@kbn/unified-doc-viewer-plugin/public';
import { UnifiedDocViewerObservabilityTracesOverview } from '@kbn/unified-doc-viewer-plugin/public';
import type { DocViewsRegistry } from '@kbn/unified-doc-viewer';
import type { TraceIndexes } from '@kbn/discover-utils/src/data_types/traces/types';
import type { DocumentProfileProvider } from '../../../../../profiles';
Expand All @@ -20,19 +20,19 @@ export const createGetDocViewer =
(prev: (params: DocViewerExtensionParams) => DocViewerExtension) =>
(params: DocViewerExtensionParams) => {
const prevDocViewer = prev(params);
const tabTitle = i18n.translate('discover.docViews.observability.traces.spanOverview.title', {
defaultMessage: 'Span overview',
const tabTitle = i18n.translate('discover.docViews.observability.traces.overview.title', {
defaultMessage: 'Overview',
});
return {
...prevDocViewer,
docViewsRegistry: (registry: DocViewsRegistry) => {
registry.add({
id: 'doc_view_obs_traces_span_overview',
id: 'doc_view_obs_traces_overview',
title: tabTitle,
order: 0,
component: (props) => {
return <UnifiedDocViewerObservabilityTracesSpanOverview {...props} indexes={indexes} />;
},
component: (props) => (
<UnifiedDocViewerObservabilityTracesOverview {...props} indexes={indexes} />
),
});

return prevDocViewer.docViewsRegistry(registry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export { createGetDocViewer } from './doc_viewer';
export { createObservabilityTracesDocumentProfileProvider } from './profile';
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import { buildDataTableRecord } from '@kbn/discover-utils';
import type { DataSourceContext, RootContext } from '../../../../profiles';
import { DataSourceCategory, DocumentType, SolutionType } from '../../../../profiles';
import { createObservabilityTracesTransactionDocumentProfileProvider } from './profile';
import { createContextAwarenessMocks } from '../../../../__mocks__';
import { createObservabilityTracesDocumentProfileProvider } from './profile';
import type { ContextWithProfileId } from '../../../../profile_service';
import { OBSERVABILITY_ROOT_PROFILE_ID } from '../../consts';
import { createContextAwarenessMocks } from '../../../../__mocks__';
import type { ProfileProviderServices } from '../../../profile_provider_services';

describe('transactionDocumentProfileProvider', () => {
describe('tracesDocumentProfileProvider', () => {
const getRootContext = ({
profileId,
solutionType,
Expand All @@ -31,13 +31,13 @@ describe('transactionDocumentProfileProvider', () => {
};

const DATA_SOURCE_CONTEXT: ContextWithProfileId<DataSourceContext> = {
profileId: 'traces-transaction-document-profile',
profileId: 'traces-document-profile',
category: DataSourceCategory.Traces,
};
const RESOLUTION_MATCH = {
isMatch: true,
context: {
type: DocumentType.Transaction,
type: DocumentType.Trace,
},
};
const RESOLUTION_MISMATCH = {
Expand All @@ -50,55 +50,67 @@ describe('transactionDocumentProfileProvider', () => {

describe('when root profile is observability', () => {
const profileId = OBSERVABILITY_ROOT_PROFILE_ID;
const transactionDocumentProfileProvider =
createObservabilityTracesTransactionDocumentProfileProvider(mockServices);

it('matches records with the correct data stream type and the correct processor event', () => {
const spanDocumentProfileProvider =
createObservabilityTracesDocumentProfileProvider(mockServices);

it('matches records with at least the correct source and a trace id', () => {
expect(
transactionDocumentProfileProvider.resolve({
spanDocumentProfileProvider.resolve({
rootContext: getRootContext({ profileId }),
dataSourceContext: DATA_SOURCE_CONTEXT,
record: buildMockRecord('index', {
'data_stream.type': ['traces'],
'processor.event': ['transaction'],
record: buildTraceMockRecord('index', {
'trace.id': ['c0ffee'],
}),
})
).toEqual(RESOLUTION_MATCH);
});

it('does not match records with neither characteristic', () => {
it('does not match records with no trace id', () => {
expect(
transactionDocumentProfileProvider.resolve({
spanDocumentProfileProvider.resolve({
rootContext: getRootContext({ profileId }),
dataSourceContext: DATA_SOURCE_CONTEXT,
record: buildMockRecord('another-index'),
record: buildTraceMockRecord('another-index'),
})
).toEqual(RESOLUTION_MISMATCH);
});

it('matches records with the correct trace id and any OTEL `kind` field (unprocessed spans)', () => {
expect(
spanDocumentProfileProvider.resolve({
rootContext: getRootContext({ profileId }),
dataSourceContext: DATA_SOURCE_CONTEXT,
record: buildTraceMockRecord('index', {
'trace.id': ['c0ffee'],
kind: 'Internal',
}),
})
).toEqual(RESOLUTION_MATCH);
});
});

describe('when solutionType is NOT observability', () => {
const profileId = OBSERVABILITY_ROOT_PROFILE_ID;
const solutionType = SolutionType.Default;
const transactionDocumentProfileProvider =
createObservabilityTracesTransactionDocumentProfileProvider(mockServices);
describe('when root profile is NOT observability', () => {
const profileId = 'another-profile';
const solutionType = SolutionType.Security;
const spanDocumentProfileProvider =
createObservabilityTracesDocumentProfileProvider(mockServices);

it('does not match records with the correct data stream type and the correct processor event', () => {
it('does not match records with the correct data source and a trace id', () => {
expect(
transactionDocumentProfileProvider.resolve({
spanDocumentProfileProvider.resolve({
rootContext: getRootContext({ profileId, solutionType }),
dataSourceContext: DATA_SOURCE_CONTEXT,
record: buildMockRecord('index', {
'data_stream.type': ['traces'],
'processor.event': ['transaction'],
record: buildTraceMockRecord('index', {
'trace.id': ['c0ffee'],
}),
})
).toEqual(RESOLUTION_MISMATCH);
});
});
});

const buildMockRecord = (index: string, fields: Record<string, unknown> = {}) =>
const buildTraceMockRecord = (index: string, fields: Record<string, unknown> = {}) =>
buildDataTableRecord({
_id: '',
_index: index,
Expand Down
Loading