From dc92cee8749b02ca01f2d16972ebd67b7efaf08e Mon Sep 17 00:00:00 2001 From: Connor Lindsey Date: Tue, 4 Jan 2022 07:25:14 -0700 Subject: [PATCH] Tempo: Fix Otel span kind mapping in trace upload resultTransformer (#43168) * Fix otel span kind mapping * Parse span kind from enum string --- .../app/plugins/datasource/tempo/resultTransformer.ts | 10 ++++------ public/app/plugins/datasource/tempo/testResponse.ts | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/public/app/plugins/datasource/tempo/resultTransformer.ts b/public/app/plugins/datasource/tempo/resultTransformer.ts index 2e7e010b05e..9eb4a61442c 100644 --- a/public/app/plugins/datasource/tempo/resultTransformer.ts +++ b/public/app/plugins/datasource/tempo/resultTransformer.ts @@ -10,7 +10,7 @@ import { TraceLog, TraceSpanRow, } from '@grafana/data'; -import { SpanKind, SpanStatus, SpanStatusCode } from '@opentelemetry/api'; +import { SpanStatus, SpanStatusCode } from '@opentelemetry/api'; import { collectorTypes } from '@opentelemetry/exporter-collector'; import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; import { createGraphFrames } from './graphTransform'; @@ -216,13 +216,11 @@ function getSpanTags( } } - if ( - span.kind !== undefined && - span.kind !== collectorTypes.opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_INTERNAL - ) { + if (span.kind !== undefined) { + const split = span.kind.toString().toLowerCase().split('_'); spanTags.push({ key: 'span.kind', - value: SpanKind[collectorTypes.opentelemetryProto.trace.v1.Span.SpanKind[span.kind] as any].toLowerCase(), + value: split.length ? split[split.length - 1] : span.kind.toString(), }); } diff --git a/public/app/plugins/datasource/tempo/testResponse.ts b/public/app/plugins/datasource/tempo/testResponse.ts index 55649879212..2596c5221fe 100644 --- a/public/app/plugins/datasource/tempo/testResponse.ts +++ b/public/app/plugins/datasource/tempo/testResponse.ts @@ -2000,7 +2000,7 @@ export const otlpDataFrameFromResponse = new MutableDataFrame({ }, { key: 'span.kind', - value: 'producer', + value: 'client', }, ], ],