diff --git a/.chloggen/remove-ottl-profiles-lookup-tables.yaml b/.chloggen/remove-ottl-profiles-lookup-tables.yaml new file mode 100644 index 0000000000000..d1d171f2cd638 --- /dev/null +++ b/.chloggen/remove-ottl-profiles-lookup-tables.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: pkg/ottl + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove access to the profile lookup tables + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [40227] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +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. + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/pkg/ottl/contexts/internal/ctxprofile/profile.go b/pkg/ottl/contexts/internal/ctxprofile/profile.go index 50dba0dcfd1d0..ca812056e81c8 100644 --- a/pkg/ottl/contexts/internal/ctxprofile/profile.go +++ b/pkg/ottl/contexts/internal/ctxprofile/profile.go @@ -31,22 +31,8 @@ func PathGetSetter[K ProfileContext](path ottl.Path[K]) (ottl.GetSetter[K], erro return accessSampleType[K](), nil case "sample": return accessSample[K](), nil - case "mapping_table": - return accessMappingTable[K](), nil - case "location_table": - return accessLocationTable[K](), nil case "location_indices": return accessLocationIndices[K](), nil - case "function_table": - return accessFunctionTable[K](), nil - case "attribute_table": - return accessAttributeTable[K](), nil - case "attribute_units": - return accessAttributeUnits[K](), nil - case "link_table": - return accessLinkTable[K](), nil - case "string_table": - return accessStringTable[K](), nil case "time_unix_nano": return accessTimeUnixNano[K](), nil case "time": @@ -113,34 +99,6 @@ func accessSample[K ProfileContext]() ottl.StandardGetSetter[K] { } } -func accessMappingTable[K ProfileContext]() ottl.StandardGetSetter[K] { - return ottl.StandardGetSetter[K]{ - Getter: func(_ context.Context, tCtx K) (any, error) { - return tCtx.GetProfile().MappingTable(), nil - }, - Setter: func(_ context.Context, tCtx K, val any) error { - if v, ok := val.(pprofile.MappingSlice); ok { - v.CopyTo(tCtx.GetProfile().MappingTable()) - } - return nil - }, - } -} - -func accessLocationTable[K ProfileContext]() ottl.StandardGetSetter[K] { - return ottl.StandardGetSetter[K]{ - Getter: func(_ context.Context, tCtx K) (any, error) { - return tCtx.GetProfile().LocationTable(), nil - }, - Setter: func(_ context.Context, tCtx K, val any) error { - if v, ok := val.(pprofile.LocationSlice); ok { - v.CopyTo(tCtx.GetProfile().LocationTable()) - } - return nil - }, - } -} - func accessLocationIndices[K ProfileContext]() ottl.StandardGetSetter[K] { return ottl.StandardGetSetter[K]{ Getter: func(_ context.Context, tCtx K) (any, error) { @@ -152,73 +110,6 @@ func accessLocationIndices[K ProfileContext]() ottl.StandardGetSetter[K] { } } -func accessFunctionTable[K ProfileContext]() ottl.StandardGetSetter[K] { - return ottl.StandardGetSetter[K]{ - Getter: func(_ context.Context, tCtx K) (any, error) { - return tCtx.GetProfile().FunctionTable(), nil - }, - Setter: func(_ context.Context, tCtx K, val any) error { - if v, ok := val.(pprofile.FunctionSlice); ok { - v.CopyTo(tCtx.GetProfile().FunctionTable()) - } - return nil - }, - } -} - -func accessAttributeTable[K ProfileContext]() ottl.StandardGetSetter[K] { - return ottl.StandardGetSetter[K]{ - Getter: func(_ context.Context, tCtx K) (any, error) { - return tCtx.GetProfile().AttributeTable(), nil - }, - Setter: func(_ context.Context, tCtx K, val any) error { - if v, ok := val.(pprofile.AttributeTableSlice); ok { - v.CopyTo(tCtx.GetProfile().AttributeTable()) - } - return nil - }, - } -} - -func accessAttributeUnits[K ProfileContext]() ottl.StandardGetSetter[K] { - return ottl.StandardGetSetter[K]{ - Getter: func(_ context.Context, tCtx K) (any, error) { - return tCtx.GetProfile().AttributeUnits(), nil - }, - Setter: func(_ context.Context, tCtx K, val any) error { - if v, ok := val.(pprofile.AttributeUnitSlice); ok { - v.CopyTo(tCtx.GetProfile().AttributeUnits()) - } - return nil - }, - } -} - -func accessLinkTable[K ProfileContext]() ottl.StandardGetSetter[K] { - return ottl.StandardGetSetter[K]{ - Getter: func(_ context.Context, tCtx K) (any, error) { - return tCtx.GetProfile().LinkTable(), nil - }, - Setter: func(_ context.Context, tCtx K, val any) error { - if v, ok := val.(pprofile.LinkSlice); ok { - v.CopyTo(tCtx.GetProfile().LinkTable()) - } - return nil - }, - } -} - -func accessStringTable[K ProfileContext]() ottl.StandardGetSetter[K] { - return ottl.StandardGetSetter[K]{ - Getter: func(_ context.Context, tCtx K) (any, error) { - return tCtx.GetProfile().StringTable().AsRaw(), nil - }, - Setter: func(_ context.Context, tCtx K, val any) error { - return ctxutil.SetCommonTypedSliceValues[string](tCtx.GetProfile().StringTable(), val) - }, - } -} - func accessTimeUnixNano[K ProfileContext]() ottl.StandardGetSetter[K] { return ottl.StandardGetSetter[K]{ Getter: func(_ context.Context, tCtx K) (any, error) { diff --git a/pkg/ottl/contexts/internal/ctxprofile/profile_test.go b/pkg/ottl/contexts/internal/ctxprofile/profile_test.go index a03208ef41ddc..8f4a5dd5fb460 100644 --- a/pkg/ottl/contexts/internal/ctxprofile/profile_test.go +++ b/pkg/ottl/contexts/internal/ctxprofile/profile_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/pprofile" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal/pathtest" @@ -32,14 +31,6 @@ func TestPathGetSetter(t *testing.T) { path: "sample", val: createSampleSlice(), }, - { - path: "mapping_table", - val: createMappingSlice(), - }, - { - path: "location_table", - val: createLocationSlice(), - }, { path: "location_indices", val: []int64{5}, @@ -49,26 +40,6 @@ func TestPathGetSetter(t *testing.T) { val: []string{"x"}, setFails: true, }, - { - path: "function_table", - val: createFunctionSlice(), - }, - { - path: "attribute_table", - val: createAttributeTableSlice(), - }, - { - path: "attribute_units", - val: createAttributeUnitSlice(), - }, - { - path: "link_table", - val: createLinkSlice(), - }, - { - path: "string_table", - val: []string{"", "string"}, - }, { path: "time_unix_nano", val: int64(123), @@ -202,99 +173,6 @@ func createSampleSlice() pprofile.SampleSlice { return sl } -func createMappingSlice() pprofile.MappingSlice { - sl := pprofile.NewMappingSlice() - mapping := sl.AppendEmpty() - mapping.CopyTo(createMapping()) - return sl -} - -func createMapping() pprofile.Mapping { - mapping := pprofile.NewMapping() - mapping.SetFilenameStrindex(2) - mapping.SetFileOffset(1) - mapping.SetHasFilenames(true) - mapping.SetHasFunctions(true) - mapping.SetHasInlineFrames(true) - mapping.SetHasLineNumbers(true) - mapping.SetMemoryLimit(3) - mapping.SetMemoryStart(4) - return mapping -} - -func createLocationSlice() pprofile.LocationSlice { - sl := pprofile.NewLocationSlice() - location := sl.AppendEmpty() - location.CopyTo(createLocation()) - return sl -} - -func createLocation() pprofile.Location { - location := pprofile.NewLocation() - location.SetAddress(1) - location.SetIsFolded(true) - location.SetMappingIndex(2) - return location -} - -func createFunctionSlice() pprofile.FunctionSlice { - sl := pprofile.NewFunctionSlice() - function := sl.AppendEmpty() - function.CopyTo(createFunction()) - return sl -} - -func createFunction() pprofile.Function { - function := pprofile.NewFunction() - function.SetFilenameStrindex(1) - function.SetNameStrindex(2) - function.SetStartLine(3) - function.SetSystemNameStrindex(4) - return function -} - -func createAttributeTableSlice() pprofile.AttributeTableSlice { - sl := pprofile.NewAttributeTableSlice() - attribute := sl.AppendEmpty() - attribute.CopyTo(createAttributeTable()) - return sl -} - -func createAttributeTable() pprofile.Attribute { - attribute := pprofile.NewAttribute() - attribute.SetKey("key") - attribute.Value().SetStr("value") - return attribute -} - -func createAttributeUnitSlice() pprofile.AttributeUnitSlice { - sl := pprofile.NewAttributeUnitSlice() - attributeUnit := sl.AppendEmpty() - attributeUnit.CopyTo(createAttributeUnit()) - return sl -} - -func createAttributeUnit() pprofile.AttributeUnit { - attributeUnit := pprofile.NewAttributeUnit() - attributeUnit.SetUnitStrindex(1) - attributeUnit.SetAttributeKeyStrindex(2) - return attributeUnit -} - -func createLinkSlice() pprofile.LinkSlice { - sl := pprofile.NewLinkSlice() - link := sl.AppendEmpty() - link.CopyTo(createLink()) - return sl -} - -func createLink() pprofile.Link { - link := pprofile.NewLink() - link.SetSpanID(pcommon.SpanID([]byte{1, 2, 3, 4, 5, 6, 7, 8})) - link.SetTraceID(pcommon.TraceID([]byte{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1})) - return link -} - func createProfileID() pprofile.ProfileID { return [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16} } diff --git a/pkg/ottl/contexts/ottlprofile/README.md b/pkg/ottl/contexts/ottlprofile/README.md index e27f531177bcd..b5caa0f0beb77 100644 --- a/pkg/ottl/contexts/ottlprofile/README.md +++ b/pkg/ottl/contexts/ottlprofile/README.md @@ -24,14 +24,7 @@ The following paths are supported. | 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 | | profile.sample_type | the sample types of the profile being processed | pprofile.ValueTypeSlice | | profile.sample | the samples of the profile being processed | pprofile.SampleSlice | -| profile.mapping_table | the mapping table of the profile being processed | pprofile.MappingSlice | -| profile.location_table | the location table of the profile being processed | pprofile.LocationSlice | | profile.location_indices | the location indices of the profile being processed | []int64 | -| profile.function_table | the function table of the profile being processed | pprofile.FunctionSlice | -| profile.attribute_table | the attribute table of the profile being processed | pprofile.AttributeTableSlice | -| profile.attribute_units | the attribute units of the profile being processed | pprofile.AttributeUnitSlice | -| profile.link_table | the link table of the profile being processed | pprofile.LinkSlice | -| profile.string_table | the string table of the profile being processed | []string | | profile.time_unix_nano | the time in unix nano of the profile being processed | int64 | | profile.time | the time in `time.Time` of the profile being processed | time.Time | | profile.duration_unix_nano | the duration in unix nano of the profile being processed | int64 |