Skip to content

Commit 3ea23e4

Browse files
committed
[chore][pkg/ottl] Add profile to the infer priorities
1 parent bcb78f7 commit 3ea23e4

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

pkg/ottl/context_inferrer.go

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var defaultContextInferPriority = []string{
2121
"metric",
2222
"spanevent",
2323
"span",
24+
"profile",
2425
"scope",
2526
"instrumentation_scope",
2627
"resource",

pkg/ottl/context_inferrer_test.go

+23
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ func Test_NewPriorityContextInferrer_DefaultPriorityList(t *testing.T) {
296296
"metric",
297297
"spanevent",
298298
"span",
299+
"profile",
299300
"scope",
300301
"instrumentation_scope",
301302
"resource",
@@ -316,6 +317,7 @@ func Test_NewPriorityContextInferrer_InferStatements_DefaultContextsOrder(t *tes
316317
"datapoint": newDummyPriorityContextInferrerCandidate(true, true, []string{"scope", "instrumentation_scope", "resource"}),
317318
"span": newDummyPriorityContextInferrerCandidate(true, true, []string{"spanevent", "scope", "instrumentation_scope", "resource"}),
318319
"spanevent": newDummyPriorityContextInferrerCandidate(true, true, []string{"scope", "instrumentation_scope", "resource"}),
320+
"profile": newDummyPriorityContextInferrerCandidate(true, true, []string{"profile", "scope", "instrumentation_scope", "resource"}),
319321
"scope": newDummyPriorityContextInferrerCandidate(true, true, []string{"resource"}),
320322
"instrumentation_scope": newDummyPriorityContextInferrerCandidate(true, true, []string{"resource"}),
321323
"resource": newDummyPriorityContextInferrerCandidate(true, true, []string{}),
@@ -386,6 +388,16 @@ func Test_NewPriorityContextInferrer_InferStatements_DefaultContextsOrder(t *tes
386388
statement: `set(span.name, "foo") where spanevent.name != nil and scope.name != nil and resource.attributes["foo"] != nil`,
387389
expected: "spanevent",
388390
},
391+
{
392+
name: "profile,instrumentation_scope,resource",
393+
statement: `set(profile.name, "foo") where profile.name != nil and instrumentation_scope.name != nil and resource.attributes["foo"] != nil`,
394+
expected: "profile",
395+
},
396+
{
397+
name: "profile,scope,resource",
398+
statement: `set(profile.name, "foo") where profile.name != nil and scope.name != nil and resource.attributes["foo"] != nil`,
399+
expected: "profile",
400+
},
389401
{
390402
name: "resource",
391403
statement: `set(resource.attributes["bar"], "foo") where dummy.attributes["foo"] != nil`,
@@ -409,6 +421,7 @@ func Test_NewPriorityContextInferrer_InferConditions_DefaultContextsOrder(t *tes
409421
"datapoint": newDummyPriorityContextInferrerCandidate(true, true, []string{"scope", "instrumentation_scope", "resource"}),
410422
"span": newDummyPriorityContextInferrerCandidate(true, true, []string{"spanevent", "scope", "instrumentation_scope", "resource"}),
411423
"spanevent": newDummyPriorityContextInferrerCandidate(true, true, []string{"scope", "instrumentation_scope", "resource"}),
424+
"profile": newDummyPriorityContextInferrerCandidate(true, true, []string{"profile", "scope", "instrumentation_scope", "resource"}),
412425
"scope": newDummyPriorityContextInferrerCandidate(true, true, []string{"resource"}),
413426
"instrumentation_scope": newDummyPriorityContextInferrerCandidate(true, true, []string{"resource"}),
414427
"resource": newDummyPriorityContextInferrerCandidate(true, true, []string{}),
@@ -479,6 +492,16 @@ func Test_NewPriorityContextInferrer_InferConditions_DefaultContextsOrder(t *tes
479492
condition: `span.name != nil and spanevent.name != nil and scope.name != nil and resource.attributes["foo"] != nil`,
480493
expected: "spanevent",
481494
},
495+
{
496+
name: "profile,instrumentation_scope,resource",
497+
condition: `profile.name != nil and profile.name != nil and instrumentation_scope.name != nil and resource.attributes["foo"] != nil`,
498+
expected: "profile",
499+
},
500+
{
501+
name: "profile,scope,resource",
502+
condition: `profile.name != nil and profile.name != nil and scope.name != nil and resource.attributes["foo"] != nil`,
503+
expected: "profile",
504+
},
482505
{
483506
name: "resource",
484507
condition: `resource.attributes["bar"] != nil and dummy.attributes["foo"] != nil`,

0 commit comments

Comments
 (0)