Skip to content
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

TraceQL event intrinsic event:name #3708

Merged
merged 8 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## main / unreleased

* [FEATURE] TraceQL support for event scope and event:name intrinsic [#3708](https://github.com/grafana/tempo/pull/3708) (@stoewer)

## v2.5.0-rc.1

* [CHANGE] Update Alpine image version to 3.20 [#3710](https://github.com/grafana/tempo/pull/3710) (@joe-elliott)
Expand Down
10 changes: 6 additions & 4 deletions pkg/traceql/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ type ScalarOperation struct {
RHS ScalarExpression
}

func newScalarOperation(op Operator, lhs ScalarExpression, rhs ScalarExpression) ScalarOperation {
func newScalarOperation(op Operator, lhs, rhs ScalarExpression) ScalarOperation {
return ScalarOperation{
Op: op,
LHS: lhs,
Expand Down Expand Up @@ -285,7 +285,7 @@ func (o SpansetOperation) extractConditions(request *FetchSpansRequest) {
request.AllConditions = false
}

func newSpansetOperation(op Operator, lhs SpansetExpression, rhs SpansetExpression) SpansetOperation {
func newSpansetOperation(op Operator, lhs, rhs SpansetExpression) SpansetOperation {
return SpansetOperation{
Op: op,
LHS: lhs,
Expand Down Expand Up @@ -362,7 +362,7 @@ type ScalarFilter struct {
rhs ScalarExpression
}

func newScalarFilter(op Operator, lhs ScalarExpression, rhs ScalarExpression) ScalarFilter {
func newScalarFilter(op Operator, lhs, rhs ScalarExpression) ScalarFilter {
return ScalarFilter{
op: op,
lhs: lhs,
Expand Down Expand Up @@ -402,7 +402,7 @@ type BinaryOperation struct {
compiledExpression *regexp.Regexp
}

func newBinaryOperation(op Operator, lhs FieldExpression, rhs FieldExpression) *BinaryOperation {
func newBinaryOperation(op Operator, lhs, rhs FieldExpression) *BinaryOperation {
return &BinaryOperation{
Op: op,
LHS: lhs,
Expand Down Expand Up @@ -695,6 +695,8 @@ func (a Attribute) impliedType() StaticType {
return TypeString
case IntrinsicKind:
return TypeKind
case IntrinsicEventName:
return TypeString
case IntrinsicParent:
return TypeNil
case IntrinsicTraceDuration:
Expand Down
3 changes: 2 additions & 1 deletion pkg/traceql/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ func (e *Engine) asTraceSearchMetadata(spanset *Spanset) *tempopb.TraceSearchMet
attribute.Intrinsic == IntrinsicTraceRootService ||
attribute.Intrinsic == IntrinsicTraceRootSpan ||
attribute.Intrinsic == IntrinsicTraceID ||
attribute.Intrinsic == IntrinsicSpanID {
attribute.Intrinsic == IntrinsicSpanID ||
attribute.Intrinsic == IntrinsicEventName {
continue
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/traceql/enum_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const (
AttributeScopeNone AttributeScope = iota
AttributeScopeResource
AttributeScopeSpan
AttributeScopeEvent
AttributeScopeUnknown

none = "none"
Expand All @@ -26,6 +27,8 @@ func (s AttributeScope) String() string {
return "span"
case AttributeScopeResource:
return "resource"
case AttributeScopeEvent:
return "event"
}

return fmt.Sprintf("att(%d).", s)
Expand All @@ -37,6 +40,8 @@ func AttributeScopeFromString(s string) AttributeScope {
return AttributeScopeSpan
case "resource":
return AttributeScopeResource
case "event":
return AttributeScopeEvent
case "":
fallthrough
case none:
Expand All @@ -62,6 +67,7 @@ const (
IntrinsicNestedSetLeft
IntrinsicNestedSetRight
IntrinsicNestedSetParent
IntrinsicEventName

// not yet implemented in traceql but will be
IntrinsicParent
Expand Down Expand Up @@ -120,6 +126,8 @@ func (i Intrinsic) String() string {
return "kind"
case IntrinsicChildCount:
return "childCount"
case IntrinsicEventName:
return "event:name"
case IntrinsicParent:
return "parent"
case IntrinsicTraceRootService:
Expand Down Expand Up @@ -163,6 +171,8 @@ func intrinsicFromString(s string) Intrinsic {
return IntrinsicKind
case "childCount":
return IntrinsicChildCount
case "event:name":
return IntrinsicEventName
case "parent":
return IntrinsicParent
case "rootServiceName":
Expand Down
4 changes: 3 additions & 1 deletion pkg/traceql/expr.y
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import (
KIND_UNSPECIFIED KIND_INTERNAL KIND_SERVER KIND_CLIENT KIND_PRODUCER KIND_CONSUMER
IDURATION CHILDCOUNT NAME STATUS STATUS_MESSAGE PARENT KIND ROOTNAME ROOTSERVICENAME
ROOTSERVICE TRACEDURATION NESTEDSETLEFT NESTEDSETRIGHT NESTEDSETPARENT ID
PARENT_DOT RESOURCE_DOT SPAN_DOT TRACE_COLON SPAN_COLON
PARENT_DOT RESOURCE_DOT SPAN_DOT TRACE_COLON SPAN_COLON EVENT_COLON
COUNT AVG MAX MIN SUM
BY COALESCE SELECT
END_ATTRIBUTE
Expand Down Expand Up @@ -401,6 +401,8 @@ scopedIntrinsicField:
| SPAN_COLON STATUS { $$ = NewIntrinsic(IntrinsicStatus) }
| SPAN_COLON STATUS_MESSAGE { $$ = NewIntrinsic(IntrinsicStatusMessage) }
| SPAN_COLON ID { $$ = NewIntrinsic(IntrinsicSpanID) }
// event:
| EVENT_COLON NAME { $$ = NewIntrinsic(IntrinsicEventName) }

attributeField:
DOT IDENTIFIER END_ATTRIBUTE { $$ = NewAttribute($2) }
Expand Down
Loading
Loading