From 7788ae3cca53badd1dccebeefdc084aa245526f9 Mon Sep 17 00:00:00 2001 From: Jonathan Halliday Date: Mon, 19 May 2025 12:50:05 +0100 Subject: [PATCH 1/2] profiles: avoid 'optional' keyword usage --- .../proto/profiles/v1development/profiles.proto | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/opentelemetry/proto/profiles/v1development/profiles.proto b/opentelemetry/proto/profiles/v1development/profiles.proto index ff03815f..26f45477 100644 --- a/opentelemetry/proto/profiles/v1development/profiles.proto +++ b/opentelemetry/proto/profiles/v1development/profiles.proto @@ -95,6 +95,8 @@ option go_package = "go.opentelemetry.io/proto/otlp/profiles/v1development"; message ProfilesDictionary { // Mappings from address ranges to the image/binary/library mapped // into that address range referenced by locations via Location.mapping_index. + // mapping_table[0] must always be set to an invalid default mapping, + // so that _index fields can use 0 to indicate null/unset. repeated Mapping mapping_table = 1; // Locations referenced by samples via Profile.location_indices. @@ -104,6 +106,8 @@ message ProfilesDictionary { repeated Function function_table = 3; // Links referenced by samples via Sample.link_index. + // link_table[0] must always be set to an invalid default link, + // so that _index fields can use 0 to indicate null/unset. repeated Link link_table = 4; // A common table for strings referenced by various messages. @@ -402,7 +406,8 @@ message Sample { repeated int32 attribute_indices = 4; // Reference to link in ProfilesDictionary.link_table. [optional] - optional int32 link_index = 5; + // It can be unset / set to 0 if no link exists, as link_table[0] is always a 'null' default value. + int32 link_index = 5; // Timestamps associated with Sample represented in nanoseconds. These timestamps are expected // to fall within the Profile's time range. [optional] @@ -434,9 +439,9 @@ message Mapping { // Describes function and line table debug information. message Location { // Reference to mapping in ProfilesDictionary.mapping_table. - // It can be unset if the mapping is unknown or not applicable for - // this profile type. - optional int32 mapping_index = 1; + // It can be unset / set to 0 if the mapping is unknown or not applicable for + // this profile type, as mapping_table[0] is always a 'null' default mapping. + int32 mapping_index = 1; // The instruction address for this location, if available. It // should be within [Mapping.memory_start...Mapping.memory_limit] // for the corresponding mapping. A non-leaf address may be in the From 64c0ecd4e9cc2fa01f663efbb43da4e66820a616 Mon Sep 17 00:00:00 2001 From: Jonathan Halliday Date: Tue, 3 Jun 2025 12:58:41 +0100 Subject: [PATCH 2/2] profiles: avoid 'optional' keyword usage incorporate review feedback. --- opentelemetry/proto/profiles/v1development/profiles.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opentelemetry/proto/profiles/v1development/profiles.proto b/opentelemetry/proto/profiles/v1development/profiles.proto index 26f45477..d0af1247 100644 --- a/opentelemetry/proto/profiles/v1development/profiles.proto +++ b/opentelemetry/proto/profiles/v1development/profiles.proto @@ -95,7 +95,7 @@ option go_package = "go.opentelemetry.io/proto/otlp/profiles/v1development"; message ProfilesDictionary { // Mappings from address ranges to the image/binary/library mapped // into that address range referenced by locations via Location.mapping_index. - // mapping_table[0] must always be set to an invalid default mapping, + // mapping_table[0] must always be set to a zero value default mapping, // so that _index fields can use 0 to indicate null/unset. repeated Mapping mapping_table = 1; @@ -106,7 +106,7 @@ message ProfilesDictionary { repeated Function function_table = 3; // Links referenced by samples via Sample.link_index. - // link_table[0] must always be set to an invalid default link, + // link_table[0] must always be set to a zero value default link, // so that _index fields can use 0 to indicate null/unset. repeated Link link_table = 4;