diff --git a/src/platform/plugins/shared/unified_doc_viewer/public/components/observability/traces/components/full_screen_waterfall/helpers/is_span.test.ts b/src/platform/plugins/shared/unified_doc_viewer/public/components/observability/traces/components/full_screen_waterfall/helpers/is_span.test.ts index 945cef927bbad..f7990d6d6b103 100644 --- a/src/platform/plugins/shared/unified_doc_viewer/public/components/observability/traces/components/full_screen_waterfall/helpers/is_span.test.ts +++ b/src/platform/plugins/shared/unified_doc_viewer/public/components/observability/traces/components/full_screen_waterfall/helpers/is_span.test.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { OTEL_SPAN_KIND, PROCESSOR_EVENT_FIELD, DataTableRecord } from '@kbn/discover-utils'; +import { PROCESSOR_EVENT_FIELD, DataTableRecord } from '@kbn/discover-utils'; import { isSpanHit } from './is_span'; describe('isSpanHit', () => { @@ -19,17 +19,6 @@ describe('isSpanHit', () => { expect(isSpanHit(hit)).toBe(false); }); - it('returns true for an OTEL span (spanKind is present)', () => { - const hit = { - flattened: { - [OTEL_SPAN_KIND]: 'client', - [PROCESSOR_EVENT_FIELD]: 'span', - }, - } as unknown as DataTableRecord; - - expect(isSpanHit(hit)).toBe(true); - }); - it('returns true when processorEvent is null (OTEL fallback)', () => { const hit = { flattened: { @@ -50,11 +39,10 @@ describe('isSpanHit', () => { expect(isSpanHit(hit)).toBe(true); }); - it('returns false when processorEvent is not "span" and spanKind is null', () => { + it('returns false when processorEvent is not "span" ', () => { const hit = { flattened: { [PROCESSOR_EVENT_FIELD]: 'transaction', - [OTEL_SPAN_KIND]: null, }, } as unknown as DataTableRecord; diff --git a/src/platform/plugins/shared/unified_doc_viewer/public/components/observability/traces/components/full_screen_waterfall/helpers/is_span.ts b/src/platform/plugins/shared/unified_doc_viewer/public/components/observability/traces/components/full_screen_waterfall/helpers/is_span.ts index 258b78ef6bc19..a57471da056d0 100644 --- a/src/platform/plugins/shared/unified_doc_viewer/public/components/observability/traces/components/full_screen_waterfall/helpers/is_span.ts +++ b/src/platform/plugins/shared/unified_doc_viewer/public/components/observability/traces/components/full_screen_waterfall/helpers/is_span.ts @@ -7,17 +7,19 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import { DataTableRecord, OTEL_SPAN_KIND, PROCESSOR_EVENT_FIELD } from '@kbn/discover-utils'; +import { DataTableRecord, PROCESSOR_EVENT_FIELD } from '@kbn/discover-utils'; +import { getFlattenedFields } from '@kbn/discover-utils/src/utils/get_flattened_fields'; export const isSpanHit = (hit: DataTableRecord | null): boolean => { if (!hit?.flattened) { return false; } - const processorEvent = hit.flattened[PROCESSOR_EVENT_FIELD]; - const spanKind = hit.flattened[OTEL_SPAN_KIND]; + const processorEvent = getFlattenedFields<{ [PROCESSOR_EVENT_FIELD]: string }>(hit, [ + PROCESSOR_EVENT_FIELD, + ])[PROCESSOR_EVENT_FIELD]; - const isOtelSpan = spanKind != null || processorEvent == null; + const isOtelSpan = processorEvent == null; const isApmSpan = processorEvent === 'span'; return isApmSpan || isOtelSpan;