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

[pkg/ottl] Change OTTL contexts to handle paths with context #36820

Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove top-level context access tests
edmocosta committed Dec 18, 2024

Verified

This commit was signed with the committer’s verified signature.
ararslan Alex Arslan
commit 53242ec8b92253c730839d68bac7e7754e834adf
13 changes: 1 addition & 12 deletions pkg/ottl/contexts/internal/scope_test.go
Original file line number Diff line number Diff line change
@@ -335,18 +335,7 @@ func TestScopePathGetSetter(t *testing.T) {
},
},
{
name: "scope",
path: &TestPath[*instrumentationScopeContext]{
C: "scope",
},
orig: refIS,
newVal: pcommon.NewInstrumentationScope(),
modified: func(is pcommon.InstrumentationScope) {
pcommon.NewInstrumentationScope().CopyTo(is)
},
},
{
name: "scope field",
name: "scope with context",
path: &TestPath[*instrumentationScopeContext]{
C: "scope",
N: "name",
38 changes: 4 additions & 34 deletions pkg/ottl/contexts/ottldatapoint/datapoint_test.go
Original file line number Diff line number Diff line change
@@ -2232,12 +2232,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
@@ -2249,12 +2244,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "bar",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("foo"),
@@ -2264,41 +2254,21 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
},
{
name: "metric",
path: &internal.TestPath[TransformContext]{N: "metric"},
expected: metric,
},
{
name: "metric field",
path: &internal.TestPath[TransformContext]{N: "metric", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: metric.Name(),
},
{
name: "metric context",
path: &internal.TestPath[TransformContext]{C: "metric"},
expected: metric,
},
{
name: "metric field with context",
name: "metric with context",
path: &internal.TestPath[TransformContext]{C: "metric", N: "name"},
expected: metric.Name(),
},
{
name: "instrumentation_scope",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: instrumentationScope.Name(),
},
{
name: "instrumentation_scope context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field with context",
name: "instrumentation_scope with context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope", N: "name"},
expected: instrumentationScope.Name(),
},
26 changes: 3 additions & 23 deletions pkg/ottl/contexts/ottllog/log_test.go
Original file line number Diff line number Diff line change
@@ -649,12 +649,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
@@ -666,12 +661,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "val",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("str"),
@@ -681,21 +671,11 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
},
{
name: "instrumentation_scope",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: instrumentationScope.Name(),
},
{
name: "instrumentation_scope context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field with context",
name: "instrumentation_scope with context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope", N: "name"},
expected: instrumentationScope.Name(),
},
26 changes: 3 additions & 23 deletions pkg/ottl/contexts/ottlmetric/metrics_test.go
Original file line number Diff line number Diff line change
@@ -194,12 +194,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
@@ -211,12 +206,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "bar",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("foo"),
@@ -226,21 +216,11 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
},
{
name: "instrumentation_scope",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: instrumentationScope.Name(),
},
{
name: "instrumentation_scope context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field with context",
name: "instrumentation_scope with context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope", N: "name"},
expected: instrumentationScope.Name(),
},
14 changes: 2 additions & 12 deletions pkg/ottl/contexts/ottlscope/scope_test.go
Original file line number Diff line number Diff line change
@@ -433,12 +433,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
@@ -450,12 +445,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "bar",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("foo"),
26 changes: 3 additions & 23 deletions pkg/ottl/contexts/ottlspan/span_test.go
Original file line number Diff line number Diff line change
@@ -706,12 +706,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
@@ -723,12 +718,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "bar",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("foo"),
@@ -738,21 +728,11 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
},
{
name: "instrumentation_scope",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: instrumentationScope.Name(),
},
{
name: "instrumentation_scope context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field with context",
name: "instrumentation_scope with context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope", N: "name"},
expected: instrumentationScope.Name(),
},
38 changes: 4 additions & 34 deletions pkg/ottl/contexts/ottlspanevent/span_events_test.go
Original file line number Diff line number Diff line change
@@ -465,12 +465,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
@@ -482,12 +477,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "bar",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("foo"),
@@ -497,41 +487,21 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
},
{
name: "instrumentation_scope",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: instrumentationScope.Name(),
},
{
name: "instrumentation_scope context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field with context",
name: "instrumentation_scope with context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope", N: "name"},
expected: instrumentationScope.Name(),
},
{
name: "span",
path: &internal.TestPath[TransformContext]{N: "span"},
expected: span,
},
{
name: "span field",
path: &internal.TestPath[TransformContext]{N: "span", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: span.Name(),
},
{
name: "span context",
path: &internal.TestPath[TransformContext]{C: "span"},
expected: span,
},
{
name: "span field with context",
name: "span with context",
path: &internal.TestPath[TransformContext]{C: "span", N: "name"},
expected: span.Name(),
},