Skip to content

[pkg/ottl] Add OTTL support for profiles #37574

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

Merged
merged 47 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7a05b41
Add OTTL support for profiles
rockdaboot Jan 29, 2025
8e38cb0
Drop parseEnum()
rockdaboot Feb 23, 2025
f55b2e2
Experimental ottlprofile context marshaller
rockdaboot Feb 25, 2025
0a7cd61
Merge remote-tracking branch 'upstream/main' into ottl-profile
rockdaboot Feb 25, 2025
d09fa0c
Update code
rockdaboot Feb 25, 2025
4d8eb1b
More ottlprofile context marshaller
rockdaboot Feb 27, 2025
5d4a271
Merge remote-tracking branch 'upstream/main' into ottl-profile
rockdaboot Feb 27, 2025
9a1352a
Fix merge conflicts
rockdaboot Feb 28, 2025
36807be
Add marshaller for ottlprofile TransformContext
rockdaboot Feb 28, 2025
4681525
Merge remote-tracking branch 'upstream/main' into ottl-profile
rockdaboot Feb 28, 2025
c23ad4d
Update deps for sample.LinkIndex()
rockdaboot Feb 28, 2025
52de3eb
Use hex.EncodeToString() for spanID, traceID, profileID
rockdaboot Feb 28, 2025
731e407
Revert "Update deps for sample.LinkIndex()"
rockdaboot Feb 28, 2025
f3c93a9
Remove ProfileContextName
rockdaboot Feb 28, 2025
3f5a883
Make logging / marshalling code internal
rockdaboot Feb 28, 2025
e26fc84
Merge remote-tracking branch 'upstream/main' into ottl-profile
rockdaboot Mar 10, 2025
9eefcf9
Fix goporto
rockdaboot Mar 10, 2025
f573a2d
ctxutil.SchemaURLItem -> ctxcommon.SchemaURLItem
rockdaboot Mar 10, 2025
f3ce63e
Refactor the cache stuff
rockdaboot Mar 10, 2025
6945b52
Merge branch 'main' into ottl-profile
rockdaboot Mar 10, 2025
eb452a7
Amend for new cache patterns
rockdaboot Mar 10, 2025
d653f9c
Merge branch 'main' into ottl-profile
rockdaboot Mar 12, 2025
4109f16
Merge remote-tracking branch 'upstream/main' into ottl-profile
rockdaboot Mar 14, 2025
4b5ddd6
Amend code after merging upstream
rockdaboot Mar 14, 2025
293cf04
Add accessStringProfileID()
rockdaboot Mar 14, 2025
bb1082d
Fix README.md
rockdaboot Mar 14, 2025
b0ce131
Fix int32 -> int64
rockdaboot Mar 14, 2025
931b735
Use time.Time instead of pcommon.Timestamp
rockdaboot Mar 14, 2025
25b43b1
Rename attribut to attribute
rockdaboot Mar 14, 2025
49a3a67
Uncomment link
rockdaboot Mar 14, 2025
98c94b5
Merge remote-tracking branch 'upstream/main' into ottl-profile
rockdaboot Mar 19, 2025
2a3be83
Add accessor for duration in unix nanos
rockdaboot Mar 19, 2025
117098b
Use basic Go array types in accessors
rockdaboot Mar 19, 2025
4721fd6
Use Go byte array for original_payload
rockdaboot Mar 19, 2025
1c47588
Use []int64 instead of []int32 in accessors
rockdaboot Mar 20, 2025
4954acc
Fix merge conflicts
rockdaboot Mar 20, 2025
0c2e2c0
Add test for ParseProfileID()
rockdaboot Mar 20, 2025
d113c96
Use pprofile.AggregationTemporalityDelta in test
rockdaboot Mar 20, 2025
478bfbc
Remove not yet implemented enums from README.md
rockdaboot Mar 20, 2025
b84ab88
Add TestProfile_MarshalLogObject() in internal/logprofiles
rockdaboot Mar 20, 2025
34dfcbc
Remove ottlprofile/logging_test.go
rockdaboot Mar 20, 2025
5409060
Add license header and appease linter
rockdaboot Mar 20, 2025
ba915e2
Add helpers AsIntegerRawSlice() and AsRawSlice()
rockdaboot Mar 21, 2025
13da60f
Change Option to ottl.Option[TransformContext
rockdaboot Mar 28, 2025
84c1de5
Merge remote-tracking branch 'upstream/main' into ottl-profile
rockdaboot Mar 28, 2025
391b10f
Merge remote-tracking branch 'upstream/main' into ottl-profile
rockdaboot Apr 13, 2025
53b3cf8
Use new slice functions
rockdaboot Apr 13, 2025
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
27 changes: 27 additions & 0 deletions .chloggen/ottl-profile.yaml
Original file line number Diff line number Diff line change
@@ -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: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: ottlprofile

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add OTTL support for profiles.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [36104]

# (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:

# 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: []
13 changes: 13 additions & 0 deletions pkg/ottl/contexts/internal/ctxcommon/ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"

"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pprofile"
)

func ParseSpanID(spanIDStr string) (pcommon.SpanID, error) {
Expand All @@ -33,3 +34,15 @@ func ParseTraceID(traceIDStr string) (pcommon.TraceID, error) {
}
return id, nil
}

func ParseProfileID(profileIDStr string) (pprofile.ProfileID, error) {
var id pprofile.ProfileID
if hex.DecodedLen(len(profileIDStr)) != len(id) {
return pprofile.ProfileID{}, errors.New("profile ids must be 32 hex characters")
}
_, err := hex.Decode(id[:], []byte(profileIDStr))
if err != nil {
return pprofile.ProfileID{}, err
}
return id, nil
}
25 changes: 25 additions & 0 deletions pkg/ottl/contexts/internal/ctxcommon/ids_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,28 @@ func TestParseTraceIDError(t *testing.T) {
})
}
}

func TestParseProfileIDError(t *testing.T) {
tests := []struct {
name string
input string
wantErr string
}{
{
name: "incorrect size",
input: "0123456789abcdef0123456789abcde",
wantErr: "profile ids must be 32 hex characters",
},
{
name: "incorrect characters",
input: "0123456789Xbcdef0123456789abcdef",
wantErr: "encoding/hex: invalid byte: U+0058 'X'",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := ctxcommon.ParseProfileID(tt.input)
assert.EqualError(t, err, tt.wantErr)
})
}
}
16 changes: 16 additions & 0 deletions pkg/ottl/contexts/internal/ctxprofile/context.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package ctxprofile // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/internal/ctxprofile"
import (
"go.opentelemetry.io/collector/pdata/pprofile"
)

const (
Name = "profile"
DocRef = "https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/contexts/ottlprofile"
)

type Context interface {
GetProfile() pprofile.Profile
}
Loading