Skip to content
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
1 change: 1 addition & 0 deletions pkg/ottl/context_inferrer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var defaultContextInferPriority = []string{
"metric",
"spanevent",
"span",
"profile",
"scope",
"instrumentation_scope",
"resource",
Expand Down
23 changes: 23 additions & 0 deletions pkg/ottl/context_inferrer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ func Test_NewPriorityContextInferrer_DefaultPriorityList(t *testing.T) {
"metric",
"spanevent",
"span",
"profile",
"scope",
"instrumentation_scope",
"resource",
Expand All @@ -316,6 +317,7 @@ func Test_NewPriorityContextInferrer_InferStatements_DefaultContextsOrder(t *tes
"datapoint": newDummyPriorityContextInferrerCandidate(true, true, []string{"scope", "instrumentation_scope", "resource"}),
"span": newDummyPriorityContextInferrerCandidate(true, true, []string{"spanevent", "scope", "instrumentation_scope", "resource"}),
"spanevent": newDummyPriorityContextInferrerCandidate(true, true, []string{"scope", "instrumentation_scope", "resource"}),
"profile": newDummyPriorityContextInferrerCandidate(true, true, []string{"profile", "scope", "instrumentation_scope", "resource"}),
"scope": newDummyPriorityContextInferrerCandidate(true, true, []string{"resource"}),
"instrumentation_scope": newDummyPriorityContextInferrerCandidate(true, true, []string{"resource"}),
"resource": newDummyPriorityContextInferrerCandidate(true, true, []string{}),
Expand Down Expand Up @@ -386,6 +388,16 @@ func Test_NewPriorityContextInferrer_InferStatements_DefaultContextsOrder(t *tes
statement: `set(span.name, "foo") where spanevent.name != nil and scope.name != nil and resource.attributes["foo"] != nil`,
expected: "spanevent",
},
{
name: "profile,instrumentation_scope,resource",
statement: `set(profile.name, "foo") where profile.name != nil and instrumentation_scope.name != nil and resource.attributes["foo"] != nil`,
expected: "profile",
},
{
name: "profile,scope,resource",
statement: `set(profile.name, "foo") where profile.name != nil and scope.name != nil and resource.attributes["foo"] != nil`,
expected: "profile",
},
{
name: "resource",
statement: `set(resource.attributes["bar"], "foo") where dummy.attributes["foo"] != nil`,
Expand All @@ -409,6 +421,7 @@ func Test_NewPriorityContextInferrer_InferConditions_DefaultContextsOrder(t *tes
"datapoint": newDummyPriorityContextInferrerCandidate(true, true, []string{"scope", "instrumentation_scope", "resource"}),
"span": newDummyPriorityContextInferrerCandidate(true, true, []string{"spanevent", "scope", "instrumentation_scope", "resource"}),
"spanevent": newDummyPriorityContextInferrerCandidate(true, true, []string{"scope", "instrumentation_scope", "resource"}),
"profile": newDummyPriorityContextInferrerCandidate(true, true, []string{"profile", "scope", "instrumentation_scope", "resource"}),
"scope": newDummyPriorityContextInferrerCandidate(true, true, []string{"resource"}),
"instrumentation_scope": newDummyPriorityContextInferrerCandidate(true, true, []string{"resource"}),
"resource": newDummyPriorityContextInferrerCandidate(true, true, []string{}),
Expand Down Expand Up @@ -479,6 +492,16 @@ func Test_NewPriorityContextInferrer_InferConditions_DefaultContextsOrder(t *tes
condition: `span.name != nil and spanevent.name != nil and scope.name != nil and resource.attributes["foo"] != nil`,
expected: "spanevent",
},
{
name: "profile,instrumentation_scope,resource",
condition: `profile.name != nil and profile.name != nil and instrumentation_scope.name != nil and resource.attributes["foo"] != nil`,
expected: "profile",
},
{
name: "profile,scope,resource",
condition: `profile.name != nil and profile.name != nil and scope.name != nil and resource.attributes["foo"] != nil`,
expected: "profile",
},
{
name: "resource",
condition: `resource.attributes["bar"] != nil and dummy.attributes["foo"] != nil`,
Expand Down