-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package testdata | ||
|
||
import ( | ||
"time" | ||
|
||
"go.opentelemetry.io/collector/pdata/pcommon" | ||
"go.opentelemetry.io/collector/pdata/pprofile" | ||
) | ||
|
||
var ( | ||
TestProfileStartTime = time.Date(2020, 2, 11, 20, 26, 13, 789, time.UTC) | ||
TestProfileEndTime = time.Date(2020, 2, 11, 20, 28, 13, 789, time.UTC) | ||
TestProfileStartTimestamp = pcommon.NewTimestampFromTime(TestProfileStartTime) | ||
TestProfileEndTimestamp = pcommon.NewTimestampFromTime(TestProfileEndTime) | ||
) | ||
|
||
func GenerateProfilesOneEmptyResourceProfiles() pprofile.Profiles { | ||
pd := pprofile.NewProfiles() | ||
pd.ResourceProfiles().AppendEmpty() | ||
return pd | ||
} | ||
|
||
func GenerateProfilesNoProfileContainers() pprofile.Profiles { | ||
pd := GenerateProfilesOneEmptyResourceProfiles() | ||
initResource1(pd.ResourceProfiles().At(0).Resource()) | ||
return pd | ||
} | ||
|
||
func GenerateProfilesOneEmptyProfileContainer() pprofile.Profiles { | ||
pd := GenerateProfilesNoProfileContainers() | ||
rs0 := pd.ResourceProfiles().At(0) | ||
rs0.ScopeProfiles().AppendEmpty().Profiles().AppendEmpty() | ||
return pd | ||
} | ||
|
||
func GenerateProfilesOneProfileContainer() pprofile.Profiles { | ||
pd := GenerateProfilesOneEmptyProfileContainer() | ||
fillProfileOne(pd.ResourceProfiles().At(0).ScopeProfiles().At(0).Profiles().At(0)) | ||
return pd | ||
} | ||
|
||
func GenerateProfilesTwoProfileContainersSameResource() pprofile.Profiles { | ||
pd := GenerateProfilesOneEmptyProfileContainer() | ||
profiles := pd.ResourceProfiles().At(0).ScopeProfiles().At(0).Profiles() | ||
fillProfileOne(profiles.At(0)) | ||
fillProfileTwo(profiles.AppendEmpty()) | ||
return pd | ||
} | ||
|
||
func fillProfileOne(profile pprofile.ProfileContainer) { | ||
profile.SetStartTime(TestProfileStartTimestamp) | ||
profile.SetEndTime(TestProfileEndTimestamp) | ||
profile.SetProfileID([16]byte{0x01, 0x02, 0x03, 0x04}) | ||
|
||
attrs := profile.Attributes() | ||
attrs.PutStr("app", "server") | ||
attrs.PutInt("instance_num", 1) | ||
} | ||
|
||
func fillProfileTwo(profile pprofile.ProfileContainer) { | ||
profile.SetStartTime(TestProfileStartTimestamp) | ||
profile.SetEndTime(TestProfileEndTimestamp) | ||
profile.SetProfileID([16]byte{0x05, 0x06, 0x07, 0x08}) | ||
|
||
attrs := profile.Attributes() | ||
attrs.PutStr("customer", "acme") | ||
attrs.PutStr("env", "dev") | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.