Skip to content

profiles: use single Profile.sample_type #649

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
54 changes: 26 additions & 28 deletions opentelemetry/proto/profiles/v1development/profiles.proto
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ message ScopeProfiles {
// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
// This schema_url applies to all profiles in the "profiles" field.
string schema_url = 3;

// The preferred type and unit of Samples in at least one Profile.
// See Profile.sample_type for possible values.
ValueType default_sample_type = 4;
Copy link

Choose a reason for hiding this comment

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

Does it need to be a dedicated field? Could it be a scope attribute?

Copy link
Member

Choose a reason for hiding this comment

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

We could use an attribute (it was the other option here) but then we'd need to ensure key uniqueness and possibly introduce a new semantic convention.

Given that all fields are optional in proto3, and that this specific attribute seems only relevant to profiling, it's simpler I think to have this field here? We could also update the field documentation to mention that it's optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Profiling SIG discussed this topic and agreed to prefer a dedicated field over some other mechanism.

}

// Profile is a common stacktrace profile format.
Expand Down Expand Up @@ -210,15 +214,12 @@ message ScopeProfiles {
// for ease of understanding data migration, it is not intended that pprof:Profile and
// OpenTelemetry:Profile encoding be wire compatible.
message Profile {
// A description of the samples associated with each Sample.value.
// For a cpu profile this might be:
// [["cpu","nanoseconds"]] or [["wall","seconds"]] or [["syscall","count"]]
// The type and unit of all Sample.values in this profile.
// For a cpu or off-cpu profile this might be:
// ["cpu","nanoseconds"] or ["off_cpu","nanoseconds"]
// For a heap profile, this might be:
// [["allocations","count"], ["space","bytes"]],
// If one of the values represents the number of events represented
// by the sample, by convention it should be at index 0 and use
// sample_type.unit == "count".
repeated ValueType sample_type = 1;
// ["allocated_objects","count"] or ["allocated_space","bytes"],
ValueType sample_type = 1;
// The set of samples recorded in this profile.
repeated Sample sample = 2;

Expand All @@ -243,30 +244,28 @@ message Profile {
// for human-friendly content. The profile must stay functional if this field
// is cleaned.
repeated int32 comment_strindices = 8; // Indices into ProfilesDictionary.string_table.
// Index into the sample_type array to the default sample type.
int32 default_sample_type_index = 9;

// A globally unique identifier for a profile. The ID is a 16-byte array. An ID with
// all zeroes is considered invalid.
//
// This field is required.
bytes profile_id = 10;
bytes profile_id = 9;

// dropped_attributes_count is the number of attributes that were discarded. Attributes
// can be discarded because their keys are too long or because there are too many
// attributes. If this value is 0, then no attributes were dropped.
uint32 dropped_attributes_count = 11;
uint32 dropped_attributes_count = 10;

// Specifies format of the original payload. Common values are defined in semantic conventions. [required if original_payload is present]
string original_payload_format = 12;
string original_payload_format = 11;

// Original payload can be stored in this field. This can be useful for users who want to get the original payload.
// Formats such as JFR are highly extensible and can contain more information than what is defined in this spec.
// Inclusion of original payload should be configurable by the user. Default behavior should be to not include the original payload.
// If the original payload is in pprof format, it SHOULD not be included in this field.
// The field is optional, however if it is present then equivalent converted data should be populated in other fields
// of this message as far as is practicable.
bytes original_payload = 13;
bytes original_payload = 12;

// References to attributes in attribute_table. [optional]
// It is a collection of key/value pairs. Note, global attributes
Expand All @@ -281,7 +280,7 @@ message Profile {
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute
// Attribute keys MUST be unique (it is not allowed to have more than one
// attribute with the same key).
repeated int32 attribute_indices = 14;
repeated int32 attribute_indices = 13;
}

// Represents a mapping between Attribute Keys and Units.
Expand Down Expand Up @@ -379,31 +378,30 @@ message ValueType {
AggregationTemporality aggregation_temporality = 3;
}

// Each Sample records values encountered in some program
// context. The program context is typically a stack trace, perhaps
// augmented with auxiliary information like the thread-id, some
// indicator of a higher level request being handled etc.
// Each Sample records values encountered in some program context. The program
// context is typically a stack trace, perhaps augmented with auxiliary
// information like the thread-id, some indicator of a higher level request
// being handled etc.
//
// A Sample MUST have have at least one values or timestamps_unix_nano entry. If
// both fields are populated, they MUST contain the same number of elements, and
// the elements at the same index MUST refer to the same event.
message Sample {
// locations_start_index along with locations_length refers to to a slice of locations in Profile.location_indices.
int32 locations_start_index = 1;
// locations_length along with locations_start_index refers to a slice of locations in Profile.location_indices.
// Supersedes location_index.
int32 locations_length = 2;
// The type and unit of each value is defined by the corresponding
// entry in Profile.sample_type. All samples must have the same
// number of values, the same as the length of Profile.sample_type.
// When aggregating multiple samples into a single sample, the
// result has a list of values that is the element-wise sum of the
// lists of the originals.
repeated int64 value = 3;
// The type and unit of each value is defined by Profile.sample_type.
repeated int64 values = 3;
// References to attributes in ProfilesDictionary.attribute_table. [optional]
repeated int32 attribute_indices = 4;

// Reference to link in ProfilesDictionary.link_table. [optional]
optional int32 link_index = 5;

// Timestamps associated with Sample represented in nanoseconds. These timestamps are expected
// to fall within the Profile's time range. [optional]
// Timestamps associated with Sample represented in nanoseconds. These
// timestamps should fall within the Profile's time range.
repeated uint64 timestamps_unix_nano = 6;
}

Expand Down
Loading