Skip to content

Commit

Permalink
Event intrinsics tag (#3788)
Browse files Browse the repository at this point in the history
* add event name to search tags

* do i know my abc?

* lint
  • Loading branch information
ie-pham authored Jun 21, 2024
1 parent 6b2c0b1 commit 047f7d5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
11 changes: 7 additions & 4 deletions docs/sources/tempo/traceql/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}}
Expand Down
6 changes: 5 additions & 1 deletion modules/ingester/instance_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/search/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 15 additions & 14 deletions pkg/traceql/enum_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 047f7d5

Please sign in to comment.