From 56288f46b18f67010775757cfc37dbc708d95f89 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 14 Mar 2024 23:25:19 +0300 Subject: [PATCH] cleanup tracing Signed-off-by: Vasiliy Tolstov --- tracer.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tracer.go b/tracer.go index 39889de..850dc87 100644 --- a/tracer.go +++ b/tracer.go @@ -72,7 +72,7 @@ func (m *hookTracer) OnProduceRecordBuffered(r *kgo.Record) { attrs = append(attrs, semconv.MessagingKafkaClientIDKey.String(m.clientID)) } opts := []tracer.SpanOption{ - tracer.WithSpanLabels(otel2Micro(attrs...)), + tracer.WithSpanLabels(attrs...), tracer.WithSpanKind(tracer.SpanKindProducer), } // Start the "publish" span. @@ -126,7 +126,7 @@ func (m *hookTracer) OnFetchRecordBuffered(r *kgo.Record) { attrs = append(attrs, semconv.MessagingKafkaConsumerGroupKey.String(m.group)) } opts := []tracer.SpanOption{ - tracer.WithSpanLabels(otel2Micro(attrs...)), + tracer.WithSpanLabels(attrs...), tracer.WithSpanKind(tracer.SpanKindConsumer), } @@ -176,7 +176,7 @@ func (m *hookTracer) WithProcessSpan(r *kgo.Record) (context.Context, tracer.Spa attrs = append(attrs, semconv.MessagingKafkaConsumerGroupKey.String(m.group)) } opts := []tracer.SpanOption{ - tracer.WithSpanLabels(otel2Micro(attrs...)), + tracer.WithSpanLabels(attrs...), tracer.WithSpanKind(tracer.SpanKindConsumer), } @@ -198,11 +198,3 @@ func maybeKeyAttr(attrs []attribute.KeyValue, r *kgo.Record) []attribute.KeyValu keykey = string(r.Key) return append(attrs, semconv.MessagingKafkaMessageKeyKey.String(keykey)) } - -func otel2Micro(attrs ...attribute.KeyValue) []interface{} { - ret := make([]interface{}, 0, len(attrs)) - for _, a := range attrs { - ret = append(ret, a.Key, a.Value) - } - return ret -}