Do we need to stitch spans before pushing to clickhouse database for grafana tempo UI?

50 Views Asked by At

I have a opentelmetry collector and full setup till the Clickhouse database. As of now I am putting spans to the clickhouse database following this blog [https://clickhouse.com/blog/storing-traces-and-spans-open-telemetry-in-clickhouse] Now when I am seeing the codebase of the tempo, I saw that we are not doing any stitching of spans in the tempo (like we have jaegar query search engine(JQSE) in this we need to store the spans only in the database and spans are collected by the JQSE by traceId and it stitch them and show them on the UI). Do I need to write the stitching logic in some service/job before pushing spans to the database? or am I missing something?

PS: As of now I am only storing spans separately in the clickhouse db.

Ref to tempo code: https://github.com/grafana/tempo/blob/main/pkg/tempopb/tempo.proto

1

There are 1 best solutions below

0
On

Author of the blog here. Not entirely clear what you mean. The stiching of spans together is done at query time through the SQL query. Grafana then determines the waterfall and does this client side.

Client side Grafana just needs the individual spans in time order with the right columns i.e.

SELECT "TraceId" as traceID, "SpanId" as spanID, "ParentSpanId" as parentSpanID, "ServiceName" as serviceName, "SpanName" as operationName, "Timestamp" as startTime, intDivOrZero("Duration", 1000000) as duration, arrayMap(key -> map('key', key, 'value',"SpanAttributes"[key]), mapKeys("SpanAttributes")) as tags, arrayMap(key -> map('key', key, 'value',"ResourceAttributes"[key]), mapKeys("ResourceAttributes")) as serviceTags FROM "default"."otel_traces" WHERE traceID = 'b6e51ec2938b30bf43b17bc5c3ec8d8a' ORDER BY startTime DESC LIMIT 1000