Skip to content

Commit b481209

Browse files
dmathieuedmocosta
authored andcommitted
Remove lookup table access from profiles in ottl (open-telemetry#40227)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Access to these lookup tables isn't really useful, as they only provide a slice of values, and we can't check which one is being used by the current profile. Also, with open-telemetry/opentelemetry-collector#13075, the lookup tables are moving out of the profile and into a new dictionary object. So as a first step to the proto migration, this removes access to the lookup tables for a profile. The replacement for this is open-telemetry#39681, which will give acces to the profile attributes, as we do with other signals and abstract away the lookup tables. --------- Co-authored-by: Edmo Vamerlatti Costa <[email protected]>
1 parent 6e65bac commit b481209

File tree

4 files changed

+27
-238
lines changed

4 files changed

+27
-238
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 access to the profile lookup tables
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: [40227]
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: the mapping_table, location_table, function_table, attribute_table, attribute_units, link_table, string_stable have been moved to a root dictionary attribute and are not part of profile anymore.
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: [user]

pkg/ottl/contexts/internal/ctxprofile/profile.go

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,8 @@ func PathGetSetter[K ProfileContext](path ottl.Path[K]) (ottl.GetSetter[K], erro
3131
return accessSampleType[K](), nil
3232
case "sample":
3333
return accessSample[K](), nil
34-
case "mapping_table":
35-
return accessMappingTable[K](), nil
36-
case "location_table":
37-
return accessLocationTable[K](), nil
3834
case "location_indices":
3935
return accessLocationIndices[K](), nil
40-
case "function_table":
41-
return accessFunctionTable[K](), nil
42-
case "attribute_table":
43-
return accessAttributeTable[K](), nil
44-
case "attribute_units":
45-
return accessAttributeUnits[K](), nil
46-
case "link_table":
47-
return accessLinkTable[K](), nil
48-
case "string_table":
49-
return accessStringTable[K](), nil
5036
case "time_unix_nano":
5137
return accessTimeUnixNano[K](), nil
5238
case "time":
@@ -113,34 +99,6 @@ func accessSample[K ProfileContext]() ottl.StandardGetSetter[K] {
11399
}
114100
}
115101

116-
func accessMappingTable[K ProfileContext]() ottl.StandardGetSetter[K] {
117-
return ottl.StandardGetSetter[K]{
118-
Getter: func(_ context.Context, tCtx K) (any, error) {
119-
return tCtx.GetProfile().MappingTable(), nil
120-
},
121-
Setter: func(_ context.Context, tCtx K, val any) error {
122-
if v, ok := val.(pprofile.MappingSlice); ok {
123-
v.CopyTo(tCtx.GetProfile().MappingTable())
124-
}
125-
return nil
126-
},
127-
}
128-
}
129-
130-
func accessLocationTable[K ProfileContext]() ottl.StandardGetSetter[K] {
131-
return ottl.StandardGetSetter[K]{
132-
Getter: func(_ context.Context, tCtx K) (any, error) {
133-
return tCtx.GetProfile().LocationTable(), nil
134-
},
135-
Setter: func(_ context.Context, tCtx K, val any) error {
136-
if v, ok := val.(pprofile.LocationSlice); ok {
137-
v.CopyTo(tCtx.GetProfile().LocationTable())
138-
}
139-
return nil
140-
},
141-
}
142-
}
143-
144102
func accessLocationIndices[K ProfileContext]() ottl.StandardGetSetter[K] {
145103
return ottl.StandardGetSetter[K]{
146104
Getter: func(_ context.Context, tCtx K) (any, error) {
@@ -152,73 +110,6 @@ func accessLocationIndices[K ProfileContext]() ottl.StandardGetSetter[K] {
152110
}
153111
}
154112

155-
func accessFunctionTable[K ProfileContext]() ottl.StandardGetSetter[K] {
156-
return ottl.StandardGetSetter[K]{
157-
Getter: func(_ context.Context, tCtx K) (any, error) {
158-
return tCtx.GetProfile().FunctionTable(), nil
159-
},
160-
Setter: func(_ context.Context, tCtx K, val any) error {
161-
if v, ok := val.(pprofile.FunctionSlice); ok {
162-
v.CopyTo(tCtx.GetProfile().FunctionTable())
163-
}
164-
return nil
165-
},
166-
}
167-
}
168-
169-
func accessAttributeTable[K ProfileContext]() ottl.StandardGetSetter[K] {
170-
return ottl.StandardGetSetter[K]{
171-
Getter: func(_ context.Context, tCtx K) (any, error) {
172-
return tCtx.GetProfile().AttributeTable(), nil
173-
},
174-
Setter: func(_ context.Context, tCtx K, val any) error {
175-
if v, ok := val.(pprofile.AttributeTableSlice); ok {
176-
v.CopyTo(tCtx.GetProfile().AttributeTable())
177-
}
178-
return nil
179-
},
180-
}
181-
}
182-
183-
func accessAttributeUnits[K ProfileContext]() ottl.StandardGetSetter[K] {
184-
return ottl.StandardGetSetter[K]{
185-
Getter: func(_ context.Context, tCtx K) (any, error) {
186-
return tCtx.GetProfile().AttributeUnits(), nil
187-
},
188-
Setter: func(_ context.Context, tCtx K, val any) error {
189-
if v, ok := val.(pprofile.AttributeUnitSlice); ok {
190-
v.CopyTo(tCtx.GetProfile().AttributeUnits())
191-
}
192-
return nil
193-
},
194-
}
195-
}
196-
197-
func accessLinkTable[K ProfileContext]() ottl.StandardGetSetter[K] {
198-
return ottl.StandardGetSetter[K]{
199-
Getter: func(_ context.Context, tCtx K) (any, error) {
200-
return tCtx.GetProfile().LinkTable(), nil
201-
},
202-
Setter: func(_ context.Context, tCtx K, val any) error {
203-
if v, ok := val.(pprofile.LinkSlice); ok {
204-
v.CopyTo(tCtx.GetProfile().LinkTable())
205-
}
206-
return nil
207-
},
208-
}
209-
}
210-
211-
func accessStringTable[K ProfileContext]() ottl.StandardGetSetter[K] {
212-
return ottl.StandardGetSetter[K]{
213-
Getter: func(_ context.Context, tCtx K) (any, error) {
214-
return tCtx.GetProfile().StringTable().AsRaw(), nil
215-
},
216-
Setter: func(_ context.Context, tCtx K, val any) error {
217-
return ctxutil.SetCommonTypedSliceValues[string](tCtx.GetProfile().StringTable(), val)
218-
},
219-
}
220-
}
221-
222113
func accessTimeUnixNano[K ProfileContext]() ottl.StandardGetSetter[K] {
223114
return ottl.StandardGetSetter[K]{
224115
Getter: func(_ context.Context, tCtx K) (any, error) {

pkg/ottl/contexts/internal/ctxprofile/profile_test.go

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
"github.com/stretchr/testify/assert"
1313
"github.com/stretchr/testify/require"
14-
"go.opentelemetry.io/collector/pdata/pcommon"
1514
"go.opentelemetry.io/collector/pdata/pprofile"
1615

1716
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal/pathtest"
@@ -32,14 +31,6 @@ func TestPathGetSetter(t *testing.T) {
3231
path: "sample",
3332
val: createSampleSlice(),
3433
},
35-
{
36-
path: "mapping_table",
37-
val: createMappingSlice(),
38-
},
39-
{
40-
path: "location_table",
41-
val: createLocationSlice(),
42-
},
4334
{
4435
path: "location_indices",
4536
val: []int64{5},
@@ -49,26 +40,6 @@ func TestPathGetSetter(t *testing.T) {
4940
val: []string{"x"},
5041
setFails: true,
5142
},
52-
{
53-
path: "function_table",
54-
val: createFunctionSlice(),
55-
},
56-
{
57-
path: "attribute_table",
58-
val: createAttributeTableSlice(),
59-
},
60-
{
61-
path: "attribute_units",
62-
val: createAttributeUnitSlice(),
63-
},
64-
{
65-
path: "link_table",
66-
val: createLinkSlice(),
67-
},
68-
{
69-
path: "string_table",
70-
val: []string{"", "string"},
71-
},
7243
{
7344
path: "time_unix_nano",
7445
val: int64(123),
@@ -202,99 +173,6 @@ func createSampleSlice() pprofile.SampleSlice {
202173
return sl
203174
}
204175

205-
func createMappingSlice() pprofile.MappingSlice {
206-
sl := pprofile.NewMappingSlice()
207-
mapping := sl.AppendEmpty()
208-
mapping.CopyTo(createMapping())
209-
return sl
210-
}
211-
212-
func createMapping() pprofile.Mapping {
213-
mapping := pprofile.NewMapping()
214-
mapping.SetFilenameStrindex(2)
215-
mapping.SetFileOffset(1)
216-
mapping.SetHasFilenames(true)
217-
mapping.SetHasFunctions(true)
218-
mapping.SetHasInlineFrames(true)
219-
mapping.SetHasLineNumbers(true)
220-
mapping.SetMemoryLimit(3)
221-
mapping.SetMemoryStart(4)
222-
return mapping
223-
}
224-
225-
func createLocationSlice() pprofile.LocationSlice {
226-
sl := pprofile.NewLocationSlice()
227-
location := sl.AppendEmpty()
228-
location.CopyTo(createLocation())
229-
return sl
230-
}
231-
232-
func createLocation() pprofile.Location {
233-
location := pprofile.NewLocation()
234-
location.SetAddress(1)
235-
location.SetIsFolded(true)
236-
location.SetMappingIndex(2)
237-
return location
238-
}
239-
240-
func createFunctionSlice() pprofile.FunctionSlice {
241-
sl := pprofile.NewFunctionSlice()
242-
function := sl.AppendEmpty()
243-
function.CopyTo(createFunction())
244-
return sl
245-
}
246-
247-
func createFunction() pprofile.Function {
248-
function := pprofile.NewFunction()
249-
function.SetFilenameStrindex(1)
250-
function.SetNameStrindex(2)
251-
function.SetStartLine(3)
252-
function.SetSystemNameStrindex(4)
253-
return function
254-
}
255-
256-
func createAttributeTableSlice() pprofile.AttributeTableSlice {
257-
sl := pprofile.NewAttributeTableSlice()
258-
attribute := sl.AppendEmpty()
259-
attribute.CopyTo(createAttributeTable())
260-
return sl
261-
}
262-
263-
func createAttributeTable() pprofile.Attribute {
264-
attribute := pprofile.NewAttribute()
265-
attribute.SetKey("key")
266-
attribute.Value().SetStr("value")
267-
return attribute
268-
}
269-
270-
func createAttributeUnitSlice() pprofile.AttributeUnitSlice {
271-
sl := pprofile.NewAttributeUnitSlice()
272-
attributeUnit := sl.AppendEmpty()
273-
attributeUnit.CopyTo(createAttributeUnit())
274-
return sl
275-
}
276-
277-
func createAttributeUnit() pprofile.AttributeUnit {
278-
attributeUnit := pprofile.NewAttributeUnit()
279-
attributeUnit.SetUnitStrindex(1)
280-
attributeUnit.SetAttributeKeyStrindex(2)
281-
return attributeUnit
282-
}
283-
284-
func createLinkSlice() pprofile.LinkSlice {
285-
sl := pprofile.NewLinkSlice()
286-
link := sl.AppendEmpty()
287-
link.CopyTo(createLink())
288-
return sl
289-
}
290-
291-
func createLink() pprofile.Link {
292-
link := pprofile.NewLink()
293-
link.SetSpanID(pcommon.SpanID([]byte{1, 2, 3, 4, 5, 6, 7, 8}))
294-
link.SetTraceID(pcommon.TraceID([]byte{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}))
295-
return link
296-
}
297-
298176
func createProfileID() pprofile.ProfileID {
299177
return [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
300178
}

pkg/ottl/contexts/ottlprofile/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,7 @@ The following paths are supported.
2424
| instrumentation_scope.attributes\[""\] | the value of the instrumentation scope attribute of the data point being processed. Supports multiple indexes to access nested fields. | string, bool, int64, float64, pcommon.Map, pcommon.Slice, []byte or nil |
2525
| profile.sample_type | the sample types of the profile being processed | pprofile.ValueTypeSlice |
2626
| profile.sample | the samples of the profile being processed | pprofile.SampleSlice |
27-
| profile.mapping_table | the mapping table of the profile being processed | pprofile.MappingSlice |
28-
| profile.location_table | the location table of the profile being processed | pprofile.LocationSlice |
2927
| profile.location_indices | the location indices of the profile being processed | []int64 |
30-
| profile.function_table | the function table of the profile being processed | pprofile.FunctionSlice |
31-
| profile.attribute_table | the attribute table of the profile being processed | pprofile.AttributeTableSlice |
32-
| profile.attribute_units | the attribute units of the profile being processed | pprofile.AttributeUnitSlice |
33-
| profile.link_table | the link table of the profile being processed | pprofile.LinkSlice |
34-
| profile.string_table | the string table of the profile being processed | []string |
3528
| profile.time_unix_nano | the time in unix nano of the profile being processed | int64 |
3629
| profile.time | the time in `time.Time` of the profile being processed | time.Time |
3730
| profile.duration_unix_nano | the duration in unix nano of the profile being processed | int64 |

0 commit comments

Comments
 (0)