-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for kind, status, instrumentation library, links, events and state data for traces #1043
base: main
Are you sure you want to change the base?
Conversation
…e data for traces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution! Glad to see expanded functionality for the trace columns. I've added a note regarding the intended table schema
@@ -49,6 +49,13 @@ const otel129: OtelVersion = { | |||
[ColumnHint.TraceTags, 'SpanAttributes'], | |||
[ColumnHint.TraceServiceTags, 'ResourceAttributes'], | |||
[ColumnHint.TraceStatusCode, 'StatusCode'], | |||
[ColumnHint.TraceKind, 'SpanKind'], | |||
[ColumnHint.TraceStatusMessage, 'StatusMessage'], | |||
[ColumnHint.TraceInstrumentationLibraryName, 'InstrumentationLibraryName'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed theres a few columns defined in otel.ts
that don't exist on the ClickHouse OTel exporter default schema. The intent of these definitions is to match as closely as possible to this table schema for a better out of the box experience.
Should we look into adding these columns to the otel exporter?
Also note that State
is defined too, but on the table it is called TraceState
.
Also AFAIU In the default schema Links is a Nested table and you need to select the fields individually:
|
@Sup3rGeo not disputing the table schema, but @SpencerTorres @benceszikora is it worth splitting the bits of this PR that can work with the current schema into something that's mergeable now? In my case I'm itching for span events to be supported, and this achieves that out of the box which is really nice. |
@jwhitaker-gridcog Yes, there's some parts of this that need changing. I don't mind picking apart the code myself for it, but I want to make sure the author is okay with that (@benceszikora) |
2ae07c3
to
c85b8d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey everyone! I've updated the code to be based on the OTel Collector Schema as requested, and rebased the PR onto main to incorporate #1128, which was merged last week. I've also updated the test cases to cover code merged in that PR.
I've left a couple of comments explaining the changes which aren't simple column addition.
const traceEventsPrefix = getColumnByHint(options, ColumnHint.TraceEventsPrefix); | ||
if (traceEventsPrefix !== undefined) { | ||
selectParts.push(`arrayMap((name, timestamp, attributes) -> tuple(name, toString(toUnixTimestamp64Milli(timestamp)), arrayMap( key -> map('key', key, 'value', attributes[key]), mapKeys(attributes)))::Tuple(name String, timestamp String, fields Array(Map(String, String))),${escapeIdentifier(traceEventsPrefix.name)}.Name, ${escapeIdentifier(traceEventsPrefix.name)}.Timestamp, ${escapeIdentifier(traceEventsPrefix.name)}.Attributes) AS logs`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two ways in ClickHouse to define a Nested Table, controlled by the flatten_nested
setting at column creation time.
The query as previously written does not work when flatten_nested=0
, as ClickHouse does not recognise the sub-columns such as Events.Names
in this mode.
The rewritten query should work with either mode, as ClickHouse will recognise Events
as one column even when it has been flattened.
@@ -102,6 +124,18 @@ export const TraceQueryBuilder = (props: TraceQueryBuilderProps) => { | |||
})); | |||
}, builderState); | |||
|
|||
// A function to assemble custom column definitions for the prefixed Events/Links columns | |||
const onColumnPrefixChange = (name: keyof TraceQueryBuilderState, columnHint: ColumnHint) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is necessary since at the moment, you cannot type into the "Events Prefix" field in the column selection form.
This function generates a SelectedColumn
struct for the arbitrary input, which is necessary since when flatten_nested=1
, the ColumnSelect
component recognises the Events
column as multiple sub-columns.
This PR adds support for the kind, status, instrumentation library, links, events and state fields in the trace panel in Grafana. This will bring the plugin to feature parity with what Tempo can offer today.