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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const SPAN_TYPE_FIELD = 'span.type';
export const SPAN_SUBTYPE_FIELD = 'span.subtype';
export const SPAN_DESTINATION_SERVICE_RESOURCE_FIELD = 'span.destination.service.resource';
export const PROCESSOR_EVENT_FIELD = 'processor.event';
export const OTEL_SPAN_KIND = 'kind';

export const LOG_FILE_PATH_FIELD = 'log.file.path';
export const DATASTREAM_NAMESPACE_FIELD = 'data_stream.namespace';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,44 @@ describe('spanDocumentProfileProvider', () => {
})
).toEqual(RESOLUTION_MISMATCH);
});

it('does not match records with the correct data stream type but the incorrect processor event', () => {
expect(
spanDocumentProfileProvider.resolve({
rootContext: getRootContext({ profileId }),
dataSourceContext: DATA_SOURCE_CONTEXT,
record: buildMockRecord('index', {
'data_stream.type': ['traces'],
'processor.event': ['other'],
}),
})
).toEqual(RESOLUTION_MISMATCH);
});

it('matches records with the correct data stream type and any OTEL `kind` field', () => {
expect(
spanDocumentProfileProvider.resolve({
rootContext: getRootContext({ profileId }),
dataSourceContext: DATA_SOURCE_CONTEXT,
record: buildMockRecord('index', {
'data_stream.type': ['traces'],
kind: 'Internal',
}),
})
).toEqual(RESOLUTION_MATCH);
});

it('defaults to matching records with the correct data stream type but no processor event field', () => {
expect(
spanDocumentProfileProvider.resolve({
rootContext: getRootContext({ profileId }),
dataSourceContext: DATA_SOURCE_CONTEXT,
record: buildMockRecord('index', {
'data_stream.type': ['traces'],
}),
})
).toEqual(RESOLUTION_MATCH);
});
});

describe('when root profile is NOT observability', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
*/

import type { DataTableRecord } from '@kbn/discover-utils';
import { DATASTREAM_TYPE_FIELD, getFieldValue, PROCESSOR_EVENT_FIELD } from '@kbn/discover-utils';
import {
DATASTREAM_TYPE_FIELD,
getFieldValue,
OTEL_SPAN_KIND,
PROCESSOR_EVENT_FIELD,
} from '@kbn/discover-utils';
import { TRACES_PRODUCT_FEATURE_ID } from '../../../../../../common/constants';
import type { DocumentProfileProvider } from '../../../../profiles';
import { DocumentType, SolutionType } from '../../../../profiles';
Expand Down Expand Up @@ -65,5 +70,10 @@ const getIsSpanRecord = ({ record }: { record: DataTableRecord }) => {
const isSpanDocument = (record: DataTableRecord) => {
const dataStreamType = getFieldValue(record, DATASTREAM_TYPE_FIELD);
const processorEvent = getFieldValue(record, PROCESSOR_EVENT_FIELD);
return dataStreamType === 'traces' && processorEvent === 'span';
const spanKind = getFieldValue(record, OTEL_SPAN_KIND);

const isApmSpan = processorEvent === 'span';
const isOtelSpan = spanKind != null || processorEvent == null;

return dataStreamType === 'traces' && (isApmSpan || isOtelSpan);
};