Skip to content

Commit d5d4b2e

Browse files
authored
[pkg/ottl] Remove experimental transform context option WithCache from all OTTL contexts (open-telemetry#39338)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This PR removes the experimental transform context option `WithCache` from all OTTL contexts, since they're not used/needed anymore (see open-telemetry#39290).
1 parent be72f9c commit d5d4b2e

File tree

15 files changed

+37
-186
lines changed

15 files changed

+37
-186
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: pkg/ottl
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remove experimental transform context option `WithCache` from all OTTL contexts.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [39338]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]

pkg/ottl/contexts/ottldatapoint/datapoint.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ func NewTransformContext(dataPoint any, metric pmetric.Metric, metrics pmetric.M
8282
return tc
8383
}
8484

85-
// Experimental: *NOTE* this option is subject to change or removal in the future.
86-
func WithCache(cache *pcommon.Map) TransformContextOption {
87-
return func(p *TransformContext) {
88-
if cache != nil {
89-
p.cache = *cache
90-
}
91-
}
92-
}
93-
9485
func (tCtx TransformContext) GetDataPoint() any {
9586
return tCtx.dataPoint
9687
}

pkg/ottl/contexts/ottldatapoint/datapoint_test.go

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func Test_newPathGetSetter_Cache(t *testing.T) {
8181

8282
numberDataPoint := createNumberDataPointTelemetry(tt.valueType)
8383

84-
ctx := NewTransformContext(numberDataPoint, pmetric.NewMetric(), pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource(), pmetric.NewScopeMetrics(), pmetric.NewResourceMetrics(), WithCache(&testCache))
84+
ctx := NewTransformContext(numberDataPoint, pmetric.NewMetric(), pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource(), pmetric.NewScopeMetrics(), pmetric.NewResourceMetrics())
8585

8686
got, err := accessor.Get(context.Background(), ctx)
8787
assert.NoError(t, err)
@@ -98,24 +98,6 @@ func Test_newPathGetSetter_Cache(t *testing.T) {
9898
}
9999
}
100100

101-
func Test_newPathGetSetter_WithCache(t *testing.T) {
102-
cacheValue := pcommon.NewMap()
103-
cacheValue.PutStr("test", "pass")
104-
105-
tCtx := NewTransformContext(
106-
pmetric.NewNumberDataPoint(),
107-
pmetric.NewMetric(),
108-
pmetric.NewMetricSlice(),
109-
pcommon.NewInstrumentationScope(),
110-
pcommon.NewResource(),
111-
pmetric.NewScopeMetrics(),
112-
pmetric.NewResourceMetrics(),
113-
WithCache(&cacheValue),
114-
)
115-
116-
assert.Equal(t, cacheValue, getCache(tCtx))
117-
}
118-
119101
func Test_newPathGetSetter_NumberDataPoint(t *testing.T) {
120102
refNumberDataPoint := createNumberDataPointTelemetry(pmetric.NumberDataPointValueTypeInt)
121103

@@ -530,7 +512,7 @@ func Test_newPathGetSetter_NumberDataPoint(t *testing.T) {
530512

531513
numberDataPoint := createNumberDataPointTelemetry(tt.valueType)
532514

533-
ctx := NewTransformContext(numberDataPoint, pmetric.NewMetric(), pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource(), pmetric.NewScopeMetrics(), pmetric.NewResourceMetrics(), WithCache(&testCache))
515+
ctx := NewTransformContext(numberDataPoint, pmetric.NewMetric(), pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource(), pmetric.NewScopeMetrics(), pmetric.NewResourceMetrics())
534516

535517
got, err := accessor.Get(context.Background(), ctx)
536518
assert.NoError(t, err)
@@ -977,7 +959,7 @@ func Test_newPathGetSetter_HistogramDataPoint(t *testing.T) {
977959

978960
histogramDataPoint := createHistogramDataPointTelemetry()
979961

980-
ctx := NewTransformContext(histogramDataPoint, pmetric.NewMetric(), pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource(), pmetric.NewScopeMetrics(), pmetric.NewResourceMetrics(), WithCache(&testCache))
962+
ctx := NewTransformContext(histogramDataPoint, pmetric.NewMetric(), pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource(), pmetric.NewScopeMetrics(), pmetric.NewResourceMetrics())
981963

982964
got, err := accessor.Get(context.Background(), ctx)
983965
assert.NoError(t, err)
@@ -1508,7 +1490,7 @@ func Test_newPathGetSetter_ExpoHistogramDataPoint(t *testing.T) {
15081490

15091491
expoHistogramDataPoint := createExpoHistogramDataPointTelemetry()
15101492

1511-
ctx := NewTransformContext(expoHistogramDataPoint, pmetric.NewMetric(), pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource(), pmetric.NewScopeMetrics(), pmetric.NewResourceMetrics(), WithCache(&testCache))
1493+
ctx := NewTransformContext(expoHistogramDataPoint, pmetric.NewMetric(), pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource(), pmetric.NewScopeMetrics(), pmetric.NewResourceMetrics())
15121494

15131495
got, err := accessor.Get(context.Background(), ctx)
15141496
assert.NoError(t, err)
@@ -1940,7 +1922,7 @@ func Test_newPathGetSetter_SummaryDataPoint(t *testing.T) {
19401922

19411923
summaryDataPoint := createSummaryDataPointTelemetry()
19421924

1943-
ctx := NewTransformContext(summaryDataPoint, pmetric.NewMetric(), pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource(), pmetric.NewScopeMetrics(), pmetric.NewResourceMetrics(), WithCache(&testCache))
1925+
ctx := NewTransformContext(summaryDataPoint, pmetric.NewMetric(), pmetric.NewMetricSlice(), pcommon.NewInstrumentationScope(), pcommon.NewResource(), pmetric.NewScopeMetrics(), pmetric.NewResourceMetrics())
19441926

19451927
got, err := accessor.Get(context.Background(), ctx)
19461928
assert.NoError(t, err)

pkg/ottl/contexts/ottllog/log.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,6 @@ func NewTransformContext(logRecord plog.LogRecord, instrumentationScope pcommon.
8484
return tc
8585
}
8686

87-
// Experimental: *NOTE* this option is subject to change or removal in the future.
88-
func WithCache(cache *pcommon.Map) TransformContextOption {
89-
return func(p *TransformContext) {
90-
if cache != nil {
91-
p.cache = *cache
92-
}
93-
}
94-
}
95-
9687
func (tCtx TransformContext) GetLogRecord() plog.LogRecord {
9788
return tCtx.logRecord
9889
}

pkg/ottl/contexts/ottllog/log_test.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -619,12 +619,12 @@ func Test_newPathGetSetter(t *testing.T) {
619619

620620
log, il, resource := createTelemetry(tt.bodyType)
621621

622-
tCtx := NewTransformContext(log, il, resource, plog.NewScopeLogs(), plog.NewResourceLogs(), WithCache(&testCache))
622+
tCtx := NewTransformContext(log, il, resource, plog.NewScopeLogs(), plog.NewResourceLogs())
623623
got, err := accessor.Get(context.Background(), tCtx)
624624
assert.NoError(t, err)
625625
assert.Equal(t, tt.orig, got)
626626

627-
tCtx = NewTransformContext(log, il, resource, plog.NewScopeLogs(), plog.NewResourceLogs(), WithCache(&testCache))
627+
tCtx = NewTransformContext(log, il, resource, plog.NewScopeLogs(), plog.NewResourceLogs())
628628
err = accessor.Set(context.Background(), tCtx, tt.newVal)
629629
assert.NoError(t, err)
630630

@@ -694,22 +694,6 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
694694
}
695695
}
696696

697-
func Test_newPathGetSetter_WithCache(t *testing.T) {
698-
cacheValue := pcommon.NewMap()
699-
cacheValue.PutStr("test", "pass")
700-
701-
tCtx := NewTransformContext(
702-
plog.NewLogRecord(),
703-
pcommon.NewInstrumentationScope(),
704-
pcommon.NewResource(),
705-
plog.NewScopeLogs(),
706-
plog.NewResourceLogs(),
707-
WithCache(&cacheValue),
708-
)
709-
710-
assert.Equal(t, cacheValue, getCache(tCtx))
711-
}
712-
713697
func createTelemetry(bodyType string) (plog.LogRecord, pcommon.InstrumentationScope, pcommon.Resource) {
714698
log := plog.NewLogRecord()
715699
log.SetTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(100)))

pkg/ottl/contexts/ottlmetric/metrics.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@ func NewTransformContext(metric pmetric.Metric, metrics pmetric.MetricSlice, ins
5656
return tc
5757
}
5858

59-
// Experimental: *NOTE* this option is subject to change or removal in the future.
60-
func WithCache(cache *pcommon.Map) TransformContextOption {
61-
return func(p *TransformContext) {
62-
if cache != nil {
63-
p.cache = *cache
64-
}
65-
}
66-
}
67-
6859
func (tCtx TransformContext) GetMetric() pmetric.Metric {
6960
return tCtx.metric
7061
}

pkg/ottl/contexts/ottlmetric/metrics_test.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -244,23 +244,6 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
244244
}
245245
}
246246

247-
func Test_newPathGetSetter_WithCache(t *testing.T) {
248-
cacheValue := pcommon.NewMap()
249-
cacheValue.PutStr("test", "pass")
250-
251-
tCtx := NewTransformContext(
252-
pmetric.NewMetric(),
253-
pmetric.NewMetricSlice(),
254-
pcommon.NewInstrumentationScope(),
255-
pcommon.NewResource(),
256-
pmetric.NewScopeMetrics(),
257-
pmetric.NewResourceMetrics(),
258-
WithCache(&cacheValue),
259-
)
260-
261-
assert.Equal(t, cacheValue, getCache(tCtx))
262-
}
263-
264247
func createTelemetry() pmetric.Metric {
265248
metric := pmetric.NewMetric()
266249
metric.SetName("name")

pkg/ottl/contexts/ottlresource/resource.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@ func NewTransformContext(resource pcommon.Resource, schemaURLItem ctxcommon.Sche
5151
return tc
5252
}
5353

54-
// Experimental: *NOTE* this option is subject to change or removal in the future.
55-
func WithCache(cache *pcommon.Map) TransformContextOption {
56-
return func(p *TransformContext) {
57-
if cache != nil {
58-
p.cache = *cache
59-
}
60-
}
61-
}
62-
6354
func (tCtx TransformContext) GetResource() pcommon.Resource {
6455
return tCtx.resource
6556
}

pkg/ottl/contexts/ottlresource/resource_test.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ func Test_newPathGetSetter(t *testing.T) {
374374
}
375375
for _, tt := range tests {
376376
t.Run(tt.name, func(t *testing.T) {
377-
testCache := pcommon.NewMap()
378377
cacheGetter := func(tCtx TransformContext) pcommon.Map {
379378
return tCtx.cache
380379
}
@@ -383,7 +382,7 @@ func Test_newPathGetSetter(t *testing.T) {
383382

384383
resource := createTelemetry()
385384

386-
tCtx := NewTransformContext(resource, pmetric.NewResourceMetrics(), WithCache(&testCache))
385+
tCtx := NewTransformContext(resource, pmetric.NewResourceMetrics())
387386
got, err := accessor.Get(context.Background(), tCtx)
388387
assert.NoError(t, err)
389388
assert.Equal(t, tt.orig, got)
@@ -396,24 +395,10 @@ func Test_newPathGetSetter(t *testing.T) {
396395
tt.modified(exRes, exCache)
397396

398397
assert.Equal(t, exRes, resource)
399-
assert.Equal(t, exCache, testCache)
400398
})
401399
}
402400
}
403401

404-
func Test_newPathGetSetter_WithCache(t *testing.T) {
405-
cacheValue := pcommon.NewMap()
406-
cacheValue.PutStr("test", "pass")
407-
408-
tCtx := NewTransformContext(
409-
pcommon.NewResource(),
410-
pmetric.NewResourceMetrics(),
411-
WithCache(&cacheValue),
412-
)
413-
414-
assert.Equal(t, cacheValue, getCache(tCtx))
415-
}
416-
417402
func createTelemetry() pcommon.Resource {
418403
resource := pcommon.NewResource()
419404

pkg/ottl/contexts/ottlscope/scope.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,6 @@ func NewTransformContext(instrumentationScope pcommon.InstrumentationScope, reso
5656
return tc
5757
}
5858

59-
// Experimental: *NOTE* this option is subject to change or removal in the future.
60-
func WithCache(cache *pcommon.Map) TransformContextOption {
61-
return func(p *TransformContext) {
62-
if cache != nil {
63-
p.cache = *cache
64-
}
65-
}
66-
}
67-
6859
func (tCtx TransformContext) GetInstrumentationScope() pcommon.InstrumentationScope {
6960
return tCtx.instrumentationScope
7061
}

0 commit comments

Comments
 (0)