From 047f7d5c57709bb8514506a27e42ea2c4be7e542 Mon Sep 17 00:00:00 2001 From: Jennie Pham <94262131+ie-pham@users.noreply.github.com> Date: Fri, 21 Jun 2024 10:39:12 -0400 Subject: [PATCH] Event intrinsics tag (#3788) * add event name to search tags * do i know my abc? * lint --- docs/sources/tempo/traceql/_index.md | 11 +++++---- modules/ingester/instance_search_test.go | 6 ++++- pkg/search/util.go | 3 ++- pkg/traceql/enum_attributes.go | 29 ++++++++++++------------ 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/docs/sources/tempo/traceql/_index.md b/docs/sources/tempo/traceql/_index.md index cdc2e73892d..6efc8dd14a7 100644 --- a/docs/sources/tempo/traceql/_index.md +++ b/docs/sources/tempo/traceql/_index.md @@ -84,14 +84,17 @@ The following table shows the current available scoped intrinsic fields: | `span:duration` | duration | end - start time of the span | `{ span:duration > 100ms }` | | `span:name` | string | operation or span name | `{ span:name = "HTTP POST" }` | | `span:kind` | kind enum | kind: server, client, producer, consumer, internal, unspecified | `{ span:kind = server }` | -| `span:id` | strig | span id using hex string | `{ span:id = "0000000000000001" }` | +| `span:id` | string | span id using hex string | `{ span:id = "0000000000000001" }` | | `trace:duration` | duration | max(end) - min(start) time of the spans in the trace | `{ trace:duration > 100ms }` | | `trace:rootName` | string | if it exists the name of the root span in the trace | `{ trace:rootName = "HTTP GET" }` | -| `trace:rootServiceName` | string | if it exists the service name of the root span in the trace | `{ trace:rootServiceName = "gateway" }`| -| `trace:id` | string | trace id using hex string | `{ trace:id = "1234567890abcdef" }` | +| `trace:rootService` | string | if it exists the service name of the root span in the trace | `{ trace:rootServiceName = "gateway" }`| +| `trace:id` | string | trace id using hex string | `{ trace:id = "1234567890abcde" }` | +| `event:name` | string | name of event | `{ event:name = "exception" }` | +| `link:spanID` | string | link span id using hex string | `{ link:spanID = "0000000000000001" }` | +| `link:traceID` | string | link trace id using hex string | `{ link:traceID = "1234567890abcde" }` | {{< admonition type="note" >}} -`traceDuration`, `rootName`, and `rootServiceName` are trace-level intrinsics and will be the same for all spans in the same trace. Additionally, +`trace:duration`, `trace:rootName`, and `trace:rootService` are trace-level intrinsics and will be the same for all spans in the same trace. Additionally, these intrinsics are significantly more performant because they have to inspect much less data then a span-level intrinsic. They should be preferred whenever possible to span-level intrinsics. {{% /admonition %}} diff --git a/modules/ingester/instance_search_test.go b/modules/ingester/instance_search_test.go index faf751e5a93..68c5766f990 100644 --- a/modules/ingester/instance_search_test.go +++ b/modules/ingester/instance_search_test.go @@ -377,7 +377,11 @@ func TestInstanceSearchTagsSpecialCases(t *testing.T) { require.NoError(t, err) require.Equal( t, - []string{"duration", "kind", "name", "rootName", "rootServiceName", "span:duration", "span:kind", "span:name", "span:status", "span:statusMessage", "status", "statusMessage", "trace:rootName", "trace:rootServiceName", "trace:traceDuration", "traceDuration"}, + []string{ + "duration", "event:name", "kind", "name", "rootName", "rootServiceName", + "span:duration", "span:kind", "span:name", "span:status", "span:statusMessage", "status", "statusMessage", + "trace:duration", "trace:rootName", "trace:rootService", "traceDuration", + }, resp.TagNames, ) } diff --git a/pkg/search/util.go b/pkg/search/util.go index d4d81d363fc..447cb4c0832 100644 --- a/pkg/search/util.go +++ b/pkg/search/util.go @@ -70,8 +70,9 @@ func GetVirtualIntrinsicValues() []string { traceql.ScopedIntrinsicSpanName.String(), traceql.ScopedIntrinsicSpanKind.String(), traceql.ScopedIntrinsicTraceRootName.String(), - traceql.ScopedIntrinsicTraceRootServiceName.String(), + traceql.ScopedIntrinsicTraceRootService.String(), traceql.ScopedIntrinsicTraceDuration.String(), + traceql.IntrinsicEventName.String(), /* these are technically intrinsics that can be requested, but they are not generally of interest to a user typing a query. for simplicity and clarity we are leaving them out of autocomplete IntrinsicNestedSetLeft diff --git a/pkg/traceql/enum_attributes.go b/pkg/traceql/enum_attributes.go index 67051d963ab..e5aad481d0f 100644 --- a/pkg/traceql/enum_attributes.go +++ b/pkg/traceql/enum_attributes.go @@ -95,8 +95,9 @@ const ( ScopedIntrinsicSpanName ScopedIntrinsicSpanKind ScopedIntrinsicTraceRootName - ScopedIntrinsicTraceRootServiceName + ScopedIntrinsicTraceRootService ScopedIntrinsicTraceDuration + // not yet implemented in traceql and may never be. these exist so that we can retrieve // these fields from the fetch layer @@ -170,10 +171,10 @@ func (i Intrinsic) String() string { return "span:kind" case ScopedIntrinsicTraceRootName: return "trace:rootName" - case ScopedIntrinsicTraceRootServiceName: - return "trace:rootServiceName" + case ScopedIntrinsicTraceRootService: + return "trace:rootService" case ScopedIntrinsicTraceDuration: - return "trace:traceDuration" + return "trace:duration" case IntrinsicSpanID: return "span:id" // below is unimplemented @@ -226,21 +227,21 @@ func intrinsicFromString(s string) Intrinsic { case "span:id": return IntrinsicSpanID case "span:status": - return ScopedIntrinsicSpanStatus + return IntrinsicStatus case "span:statusMessage": - return ScopedIntrinsicSpanStatusMessage + return IntrinsicStatusMessage case "span:duration": - return ScopedIntrinsicSpanDuration + return IntrinsicDuration case "span:name": - return ScopedIntrinsicSpanName + return IntrinsicName case "span:kind": - return ScopedIntrinsicSpanKind + return IntrinsicKind case "trace:rootName": - return ScopedIntrinsicTraceRootName - case "trace:rootServiceName": - return ScopedIntrinsicTraceRootServiceName - case "trace:traceDuration": - return ScopedIntrinsicTraceDuration + return IntrinsicTraceRootSpan + case "trace:rootService": + return IntrinsicTraceRootService + case "trace:duration": + return IntrinsicTraceDuration // unimplemented case "spanStartTime": return IntrinsicSpanStartTime