Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 25 additions & 0 deletions .chloggen/profile-duration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a breaking change anymore. There should be 2 changelog entries.
An enhancement for the new method, and a deprecation.


# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
component: pkg/pdata

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: fix pprofile DurationNano to be a TypeUint64

# One or more tracking issues or pull requests related to the change
issues: [14188]

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

# 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: [api]
2 changes: 1 addition & 1 deletion exporter/debugexporter/internal/otlptext/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (textProfilesMarshaler) MarshalProfiles(pd pprofile.Profiles) ([]byte, erro
profile := profiles.At(k)
buf.logAttr("Profile ID", profile.ProfileID())
buf.logAttr("Start time", profile.Time().String())
buf.logAttr("Duration", profile.Duration().String())
buf.logAttr("DurationNano", strconv.FormatUint(profile.DurationNano(), 10))
buf.logAttr("Dropped attributes count", strconv.FormatUint(uint64(profile.DroppedAttributesCount()), 10))

buf.logProfileSamples(profile.Samples(), dic)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ InstrumentationScope test-scope
Profile #0
Profile ID :
Start time : 1970-01-01 00:00:00 +0000 UTC
Duration : 1970-01-01 00:00:00 +0000 UTC
DurationNano : 0
Dropped attributes count: 0
Sample #0
Values: [100]
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ InstrumentationScope
Profile #0
Profile ID : 0102030405060708090a0b0c0d0e0f10
Start time : 2020-02-11 20:26:12.000000321 +0000 UTC
Duration : 2020-02-11 20:26:13.000000789 +0000 UTC
DurationNano : 1000000000
Dropped attributes count: 1
Sample #0
Values: [4]
Expand All @@ -56,7 +56,7 @@ Profile #0
Profile #1
Profile ID : 0202030405060708090a0b0c0d0e0f10
Start time : 2020-02-11 20:26:12.000000321 +0000 UTC
Duration : 2020-02-11 20:26:13.000000789 +0000 UTC
DurationNano : 1000000000
Dropped attributes count: 0
Sample #0
Values: [9]
Expand Down
15 changes: 4 additions & 11 deletions internal/cmd/pdatagen/internal/pdata/pprofile_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,10 @@ var profile = &messageStruct{
protoID: 3,
returnType: timestampType,
},
&TypedField{
fieldName: "Duration",
originFieldName: "DurationNano",
protoID: 4,
returnType: &TypedType{
structName: "Timestamp",
packageName: "pcommon",
protoType: proto.TypeUint64,
defaultVal: "0",
testVal: "1234567890",
},
&PrimitiveField{
fieldName: "DurationNano",
protoID: 4,
protoType: proto.TypeUint64,
},
&MessageField{
fieldName: "PeriodType",
Expand Down
12 changes: 6 additions & 6 deletions pdata/pprofile/generated_profile.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions pdata/pprofile/generated_profile_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion pdata/pprofile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

package pprofile // import "go.opentelemetry.io/collector/pdata/pprofile"

import "fmt"
import (
"fmt"

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

// switchDictionary updates the Profile, switching its indices from one
// dictionary to another.
Expand Down Expand Up @@ -43,3 +47,16 @@

return nil
}

// Duration returns the duration associated with this Profile.
//
// Deprecated: Use Profile.DurationNano instead.
func (ms Profile) Duration() pcommon.Timestamp {
return pcommon.Timestamp(0)
}

// SetDuration replaces the duration associated with this Profile.
//
// Deprecated: Use Profile.SetDurationNano instead.
func (ms Profile) SetDuration(v pcommon.Timestamp) {

Check failure on line 61 in pdata/pprofile/profile.go

View workflow job for this annotation

GitHub Actions / CodeQL-Build

unused-parameter: parameter 'v' seems to be unused, consider removing or renaming it as _ (revive)

Check failure on line 61 in pdata/pprofile/profile.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'v' seems to be unused, consider removing or renaming it as _ (revive)
}
5 changes: 2 additions & 3 deletions pdata/testdata/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

var (
profileStartTimestamp = pcommon.NewTimestampFromTime(time.Date(2020, 2, 11, 20, 26, 12, 321, time.UTC))
profileEndTimestamp = pcommon.NewTimestampFromTime(time.Date(2020, 2, 11, 20, 26, 13, 789, time.UTC))
)

// GenerateProfiles generates dummy profiling data for tests
Expand Down Expand Up @@ -48,7 +47,7 @@ func GenerateProfiles(profilesCount int) pprofile.Profiles {
func fillProfileOne(dic pprofile.ProfilesDictionary, profile pprofile.Profile) {
profile.SetProfileID([16]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10})
profile.SetTime(profileStartTimestamp)
profile.SetDuration(profileEndTimestamp)
profile.SetDurationNano(uint64(time.Second.Nanoseconds()))
profile.SetDroppedAttributesCount(1)

loc := pprofile.NewLocation()
Expand All @@ -66,7 +65,7 @@ func fillProfileOne(dic pprofile.ProfilesDictionary, profile pprofile.Profile) {
func fillProfileTwo(dic pprofile.ProfilesDictionary, profile pprofile.Profile) {
profile.SetProfileID([16]byte{0x02, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10})
profile.SetTime(profileStartTimestamp)
profile.SetDuration(profileEndTimestamp)
profile.SetDurationNano(uint64(time.Second.Nanoseconds()))

loc := pprofile.NewLocation()
loc.SetAddress(2)
Expand Down
Loading