diff --git a/lib/cmetrics/CMakeLists.txt b/lib/cmetrics/CMakeLists.txt index a5572c3048d..c5253f665e9 100644 --- a/lib/cmetrics/CMakeLists.txt +++ b/lib/cmetrics/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # CMetrics Version set(CMT_VERSION_MAJOR 1) set(CMT_VERSION_MINOR 0) -set(CMT_VERSION_PATCH 6) +set(CMT_VERSION_PATCH 7) set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}") # Include helpers diff --git a/lib/cmetrics/src/cmt_encode_opentelemetry.c b/lib/cmetrics/src/cmt_encode_opentelemetry.c index 3e23176f5c7..f192b76f8ae 100644 --- a/lib/cmetrics/src/cmt_encode_opentelemetry.c +++ b/lib/cmetrics/src/cmt_encode_opentelemetry.c @@ -1598,27 +1598,11 @@ static Opentelemetry__Proto__Metrics__V1__HistogramDataPoint * /* * In the OpenTelemetry Metrics protobuf definition, the `sum` field in HistogramDataPoint is - * marked as `optional`: - * - * https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/metrics/v1/metrics.proto#L456 - * - * While `optional` is supported in proto3, the `protobuf-c` project does not handle proto3 - * optional scalar fields using `has_*` booleans like the main protobuf implementations. - * - * Instead, `protobuf-c` represents optional fields internally using a synthetic `oneof`. - * This means that in the generated C code, the optional `sum` field is placed inside a union, - * and its presence is tracked using a corresponding `_sum_case` enum field. - * - * To correctly serialize the `sum` field, both the `sum` value and its `_sum_case` must be set: - * - * data_point->sum = some_value; - * data_point->_sum_case = OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___SUM_SUM; - * - * Failing to set `_sum_case` will result in the `sum` field being silently omitted from the - * serialized output. + * marked as `optional`. The generated C code uses a `has_sum` boolean to indicate presence. + * Set both so the sum is included in the serialized output. */ data_point->sum = sum; - data_point->_sum_case = OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___SUM_SUM; + data_point->has_sum = 1; if (bucket_count > 0) { diff --git a/lib/cprofiles/.github/workflows/build.yaml b/lib/cprofiles/.github/workflows/build.yaml index 6ec128e2a53..710f1fab612 100644 --- a/lib/cprofiles/.github/workflows/build.yaml +++ b/lib/cprofiles/.github/workflows/build.yaml @@ -18,7 +18,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -85,7 +85,7 @@ jobs: apt-get install -y build-essential cmake make git shell: bash - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -108,12 +108,12 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true - name: Build on ${{ matrix.os }} with ${{ matrix.compiler }} - uses: uraimo/run-on-arch-action@v3.0.0 + uses: uraimo/run-on-arch-action@v3.0.1 with: arch: aarch64 distro: ubuntu20.04 @@ -143,7 +143,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -174,7 +174,7 @@ jobs: contents: read runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true diff --git a/lib/cprofiles/.github/workflows/lint.yaml b/lib/cprofiles/.github/workflows/lint.yaml index 4dfa445899e..68d8949d756 100644 --- a/lib/cprofiles/.github/workflows/lint.yaml +++ b/lib/cprofiles/.github/workflows/lint.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest name: PR - Shellcheck steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: ludeeus/action-shellcheck@master with: ignore_paths: cmake/** @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest name: PR - Actionlint steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - run: | echo "::add-matcher::.github/actionlint-matcher.json" bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) @@ -29,6 +29,6 @@ jobs: runs-on: ubuntu-latest name: PR - Markdownlint steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Run markdownlint uses: actionshub/markdownlint@v3.1.4 diff --git a/lib/cprofiles/.github/workflows/packages.yaml b/lib/cprofiles/.github/workflows/packages.yaml index fa2db17722a..c423590747a 100644 --- a/lib/cprofiles/.github/workflows/packages.yaml +++ b/lib/cprofiles/.github/workflows/packages.yaml @@ -18,11 +18,11 @@ jobs: matrix: format: [ rpm, deb ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true - - uses: uraimo/run-on-arch-action@v3.0.0 + - uses: uraimo/run-on-arch-action@v3.0.1 name: Build the ${{matrix.format}} packages with: arch: aarch64 @@ -39,7 +39,7 @@ jobs: echo ${{ matrix.format }} | awk '{print toupper($0)}' | xargs -I{} cpack -G {} - name: Store the master package artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: ${{ matrix.format }}-arm64 path: | @@ -53,7 +53,7 @@ jobs: format: [ rpm, deb ] runs-on: [ ubuntu-latest ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -63,7 +63,7 @@ jobs: echo ${{ matrix.format }} | awk '{print toupper($0)}' | xargs -I{} cpack -G {} - name: Store the master package artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: ${{ matrix.format }}-amd64 path: | @@ -80,7 +80,7 @@ jobs: ext: pkg runs-on: macos-14 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -90,7 +90,7 @@ jobs: echo ${{ matrix.config.format }} | xargs -I{} cpack -G {} - name: Store the master package artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: ${{ matrix.config.format }}-${{matrix.config.arch}} path: | @@ -107,7 +107,7 @@ jobs: contents: write steps: - name: Download all artefacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: path: artifacts/ diff --git a/lib/cprofiles/CMakeLists.txt b/lib/cprofiles/CMakeLists.txt index c60146d205c..3f2fa83663c 100644 --- a/lib/cprofiles/CMakeLists.txt +++ b/lib/cprofiles/CMakeLists.txt @@ -5,8 +5,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # CMetrics Version set(CPROF_VERSION_MAJOR 0) -set(CPROF_VERSION_MINOR 1) -set(CPROF_VERSION_PATCH 1) +set(CPROF_VERSION_MINOR 2) +set(CPROF_VERSION_PATCH 0) set(CPROF_VERSION_STR "${CPROF_VERSION_MAJOR}.${CPROF_VERSION_MINOR}.${CPROF_VERSION_PATCH}") # Include helpers diff --git a/lib/cprofiles/include/cprofiles/cprof_encode_text.h b/lib/cprofiles/include/cprofiles/cprof_encode_text.h index 4cf12f5132f..f6dea8ba872 100644 --- a/lib/cprofiles/include/cprofiles/cprof_encode_text.h +++ b/lib/cprofiles/include/cprofiles/cprof_encode_text.h @@ -27,16 +27,21 @@ #define CPROF_ENCODE_TEXT_ALLOCATION_ERROR 1 #define CPROF_ENCODE_TEXT_INVALID_ARGUMENT_ERROR 2 +#define CPROF_ENCODE_TEXT_RENDER_DICTIONARIES_AND_INDEXES 0 +#define CPROF_ENCODE_TEXT_RENDER_RESOLVED 1 + struct cprof_text_encoding_context { cfl_sds_t output_buffer; size_t indentation_level; cfl_sds_t indentation_buffer; size_t indentation_level_size; char indentation_character; + int render_mode; }; int cprof_encode_text_create(cfl_sds_t *result_buffer, - struct cprof *profile); + struct cprof *profile, + int render_mode); void cprof_encode_text_destroy(cfl_sds_t instance); diff --git a/lib/cprofiles/src/cprof_decode_opentelemetry.c b/lib/cprofiles/src/cprof_decode_opentelemetry.c index 14038a77ab6..c2407eeaf56 100644 --- a/lib/cprofiles/src/cprof_decode_opentelemetry.c +++ b/lib/cprofiles/src/cprof_decode_opentelemetry.c @@ -40,6 +40,14 @@ static struct cprof_resource * struct cfl_kvlist *attributes; int result; + if (input_resource == NULL) { + output_resource = cprof_resource_create(NULL); + if (output_resource != NULL) { + output_resource->dropped_attributes_count = 0; + } + return output_resource; + } + attributes = cfl_kvlist_create(); if (attributes == NULL) { @@ -103,58 +111,62 @@ static struct cprof_instrumentation_scope *decode_instrumentation_scope( static int decode_profile_sample_entry(struct cprof_sample *sample, - Opentelemetry__Proto__Profiles__V1development__Sample *input_sample) + Opentelemetry__Proto__Profiles__V1development__Sample *input_sample, + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dictionary) { + int32_t location_index; int result; size_t index; - - for (index = 0 ; - index < input_sample->n_location_index; - index++) { - - result = cprof_sample_add_location_index(sample, input_sample->location_index[index]); - - if (result != 0) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + Opentelemetry__Proto__Profiles__V1development__Stack *stack; + + /* Resolve stack_index to location indices from dictionary.stack_table */ + if (dictionary != NULL && dictionary->stack_table != NULL && + input_sample->stack_index >= 0 && + (size_t)input_sample->stack_index < dictionary->n_stack_table) { + stack = dictionary->stack_table[input_sample->stack_index]; + if (stack != NULL && stack->location_indices != NULL) { + for (index = 0; index < stack->n_location_indices; index++) { + location_index = stack->location_indices[index]; + + if (location_index < 0 || + (dictionary->location_table != NULL && + (size_t) location_index >= dictionary->n_location_table)) { + return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + } + + result = cprof_sample_add_location_index(sample, + (uint64_t) location_index); + if (result != 0) { + return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + } + } } } - for (index = 0 ; - index < input_sample->n_value; - index++) { - - result = cprof_sample_add_value(sample, input_sample->value[index]); - + for (index = 0; index < input_sample->n_values; index++) { + result = cprof_sample_add_value(sample, input_sample->values[index]); if (result != 0) { return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; } } - for (index = 0 ; - index < input_sample->n_attributes; - index++) { - - result = cprof_sample_add_attribute(sample, input_sample->attributes[index]); - + for (index = 0; index < input_sample->n_attribute_indices; index++) { + result = cprof_sample_add_attribute(sample, + (uint64_t)input_sample->attribute_indices[index]); if (result != 0) { return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; } } - for (index = 0 ; - index < input_sample->n_timestamps_unix_nano; - index++) { - - result = cprof_sample_add_timestamp(sample, input_sample->timestamps_unix_nano[index]); - + for (index = 0; index < input_sample->n_timestamps_unix_nano; index++) { + result = cprof_sample_add_timestamp(sample, + input_sample->timestamps_unix_nano[index]); if (result != 0) { return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; } } - sample->locations_start_index = input_sample->locations_start_index; - sample->locations_length = input_sample->locations_length; - sample->link = input_sample->link; + sample->link = (uint64_t)(input_sample->link_index >= 0 ? input_sample->link_index : 0); return CPROF_DECODE_OPENTELEMETRY_SUCCESS; } @@ -168,35 +180,39 @@ static int decode_mapping_entry(struct cprof_mapping *mapping, int result; size_t index; - for (index = 0 ; - index < input_mapping->n_attributes; - index++) { - - result = cprof_mapping_add_attribute(mapping, input_mapping->attributes[index]); - + mapping->id = 0; + mapping->memory_start = input_mapping->memory_start; + mapping->memory_limit = input_mapping->memory_limit; + mapping->file_offset = input_mapping->file_offset; + mapping->filename = (int64_t)input_mapping->filename_strindex; + mapping->has_functions = 0; + mapping->has_filenames = 0; + mapping->has_line_numbers = 0; + mapping->has_inline_frames = 0; + + for (index = 0; index < input_mapping->n_attribute_indices; index++) { + result = cprof_mapping_add_attribute(mapping, + (uint64_t)input_mapping->attribute_indices[index]); if (result != 0) { return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; } } - mapping->id = input_mapping->id; - mapping->memory_start = input_mapping->memory_start; - mapping->memory_limit = input_mapping->memory_limit; - mapping->file_offset = input_mapping->file_offset; - mapping->filename = input_mapping->filename; - - mapping->has_functions = input_mapping->has_functions; - mapping->has_filenames = input_mapping->has_filenames; - mapping->has_line_numbers = input_mapping->has_line_numbers; - mapping->has_inline_frames = input_mapping->has_inline_frames; - return CPROF_DECODE_OPENTELEMETRY_SUCCESS; } static int decode_line_entry(struct cprof_line *line, - Opentelemetry__Proto__Profiles__V1development__Line *input_line) + Opentelemetry__Proto__Profiles__V1development__Line *input_line, + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dictionary) { - line->function_index = input_line->function_index; + if (input_line->function_index < 0 || + (dictionary != NULL && + dictionary->function_table != NULL && + (size_t) input_line->function_index >= dictionary->n_function_table)) { + return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + } + + line->function_index = (uint64_t)input_line->function_index; line->line = input_line->line; line->column = input_line->column; @@ -204,42 +220,39 @@ static int decode_line_entry(struct cprof_line *line, } static int decode_location_entry(struct cprof_location *location, - Opentelemetry__Proto__Profiles__V1development__Location *input_location) - + Opentelemetry__Proto__Profiles__V1development__Location *input_location, + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dictionary) { int result; size_t index; struct cprof_line *line; - location->id = input_location->id; - location->mapping_index = input_location->mapping_index; + if (input_location->mapping_index < 0 || + (dictionary != NULL && + dictionary->mapping_table != NULL && + (size_t) input_location->mapping_index >= dictionary->n_mapping_table)) { + return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + } + + location->id = 0; + location->mapping_index = (uint64_t)input_location->mapping_index; location->address = input_location->address; + location->is_folded = 0; - for (index = 0 ; - index < input_location->n_line ; - index++) { + for (index = 0; index < input_location->n_lines; index++) { line = cprof_line_create(location); - if (line == NULL) { return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; } - - result = decode_line_entry(line, - input_location->line[index]); - + result = decode_line_entry(line, input_location->lines[index], dictionary); if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; } } - location->is_folded = input_location->is_folded; - - for (index = 0 ; - index < input_location->n_attributes; - index++) { - - result = cprof_location_add_attribute(location, input_location->attributes[index]); - + for (index = 0; index < input_location->n_attribute_indices; index++) { + result = cprof_location_add_attribute(location, + (uint64_t)input_location->attribute_indices[index]); if (result != 0) { return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; } @@ -251,20 +264,20 @@ static int decode_location_entry(struct cprof_location *location, static int decode_function_entry(struct cprof_function *function, Opentelemetry__Proto__Profiles__V1development__Function *input_function) { - function->id = input_function->id; - function->name = input_function->name; - function->system_name = input_function->system_name; - function->filename = input_function->filename; + function->id = 0; + function->name = (int64_t)input_function->name_strindex; + function->system_name = (int64_t)input_function->system_name_strindex; + function->filename = (int64_t)input_function->filename_strindex; function->start_line = input_function->start_line; return CPROF_DECODE_OPENTELEMETRY_SUCCESS; } -static int decode_attribute_unit_entry(struct cprof_attribute_unit *attribute_unit, - Opentelemetry__Proto__Profiles__V1development__AttributeUnit *input_attribute_unit) +static int decode_keyvalueandunit_entry(struct cprof_attribute_unit *attribute_unit, + Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *input_kv) { - attribute_unit->attribute_key = input_attribute_unit->attribute_key; - attribute_unit->unit = input_attribute_unit->unit; + attribute_unit->attribute_key = (int64_t)input_kv->key_strindex; + attribute_unit->unit = (int64_t)input_kv->unit_strindex; return CPROF_DECODE_OPENTELEMETRY_SUCCESS; } @@ -299,322 +312,334 @@ static int decode_link_table_entry(struct cprof_link *link, static int decode_profile_entry(struct cprof_profile *profile, - Opentelemetry__Proto__Profiles__V1development__Profile *input_profile) + Opentelemetry__Proto__Profiles__V1development__Profile *input_profile, + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dictionary) { - size_t string_table_add_result; + Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *indexed_attribute_entry; struct cprof_attribute_unit *attribute_unit; struct cprof_value_type *sample_type; struct cprof_location *location; struct cprof_function *function; struct cprof_mapping *mapping; struct cprof_sample *sample; + struct cprof_link *link; + struct cfl_variant *indexed_attribute_value; + int32_t indexed_attribute_key_index; + int32_t indexed_attribute_table_index; + char *indexed_attribute_key; int result; size_t index; - struct cprof_link *link; - for (index = 0 ; - index < input_profile->n_sample_type ; - index++) { - sample_type = cprof_sample_type_create( - profile, - input_profile->sample_type[index]->type, - input_profile->sample_type[index]->unit, - input_profile->sample_type[index]->aggregation_temporality); - - if (sample_type == NULL) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; - } - } + /* Copy dictionary tables into profile when dictionary is present */ + if (dictionary != NULL) { + /* String table */ + if (dictionary->string_table != NULL) { + size_t table_size; - for (index = 0 ; - index < input_profile->n_sample ; - index++) { - sample = cprof_sample_create(profile); + table_size = dictionary->n_string_table; - if (sample == NULL) { - return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - result = decode_profile_sample_entry(sample, - input_profile->sample[index]); + if (table_size == 0) { + table_size = 1; + } - if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; - } - } + profile->string_table = calloc(table_size, sizeof(cfl_sds_t)); + if (profile->string_table == NULL) { + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } - for (index = 0 ; - index < input_profile->n_mapping; - index++) { - mapping = cprof_mapping_create(profile); + profile->string_table_size = table_size; + profile->string_table_count = table_size; - if (mapping == NULL) { - return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; - } + for (index = 0; index < table_size; index++) { + const char *s; - result = decode_mapping_entry(mapping, - input_profile->mapping[index]); + if (index < dictionary->n_string_table) { + s = dictionary->string_table[index]; + } + else { + s = ""; + } - if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + profile->string_table[index] = cfl_sds_create(s != NULL ? s : ""); + if (profile->string_table[index] == NULL) { + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + } } - } - - for (index = 0 ; - index < input_profile->n_location; - index++) { - location = cprof_location_create(profile); - if (location == NULL) { - return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + /* Mappings */ + if (dictionary->mapping_table != NULL) { + for (index = 0; index < dictionary->n_mapping_table; index++) { + mapping = cprof_mapping_create(profile); + if (mapping == NULL) { + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + result = decode_mapping_entry(mapping, dictionary->mapping_table[index]); + if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { + return result; + } + } } - result = decode_location_entry(location, - input_profile->location[index]); - - if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + /* Locations */ + if (dictionary->location_table != NULL) { + for (index = 0; index < dictionary->n_location_table; index++) { + location = cprof_location_create(profile); + if (location == NULL) { + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + result = decode_location_entry(location, + dictionary->location_table[index], + dictionary); + if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { + return result; + } + } } - } - - for (index = 0 ; - index < input_profile->n_location_indices; - index++) { - - result = cprof_profile_add_location_index(profile, input_profile->location_indices[index]); - if (result != 0) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + /* Functions */ + if (dictionary->function_table != NULL) { + for (index = 0; index < dictionary->n_function_table; index++) { + function = cprof_function_create(profile); + if (function == NULL) { + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + result = decode_function_entry(function, dictionary->function_table[index]); + if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { + return result; + } + } } - } - for (index = 0 ; - index < input_profile->n_function; - index++) { - function = cprof_function_create(profile); - - if (function == NULL) { - return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + /* Attribute table (KeyValueAndUnit) and attribute_units */ + if (dictionary->attribute_table != NULL && dictionary->n_attribute_table > 0) { + result = convert_keyvalueandunit_array_to_kvlist(profile->attribute_table, + dictionary->attribute_table, + dictionary->n_attribute_table, + dictionary->string_table, + dictionary->n_string_table); + if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { + return result; + } + for (index = 0; index < dictionary->n_attribute_table; index++) { + attribute_unit = cprof_attribute_unit_create(profile); + if (attribute_unit == NULL) { + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + result = decode_keyvalueandunit_entry(attribute_unit, + dictionary->attribute_table[index]); + if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { + return result; + } + } } - result = decode_function_entry(function, - input_profile->function[index]); - - if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + /* Link table */ + if (dictionary->link_table != NULL) { + for (index = 0; index < dictionary->n_link_table; index++) { + link = cprof_link_create(profile); + if (link == NULL) { + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + result = decode_link_table_entry(link, dictionary->link_table[index]); + if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { + return result; + } + } } - } - result = convert_kvarray_to_kvlist(profile->attribute_table, - input_profile->attribute_table, - input_profile->n_attribute_table); + /* Profile attributes reference dictionary.attribute_table by index */ + if (input_profile->attribute_indices != NULL && + input_profile->n_attribute_indices > 0) { + for (index = 0; index < input_profile->n_attribute_indices; index++) { + indexed_attribute_table_index = input_profile->attribute_indices[index]; - if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; - } + if (indexed_attribute_table_index < 0 || + (size_t) indexed_attribute_table_index >= dictionary->n_attribute_table) { + return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + } - for (index = 0 ; - index < input_profile->n_attribute_units; - index++) { - attribute_unit = cprof_attribute_unit_create(profile); + indexed_attribute_entry = dictionary->attribute_table[indexed_attribute_table_index]; - if (attribute_unit == NULL) { - return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; - } + if (indexed_attribute_entry == NULL) { + return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + } - result = decode_attribute_unit_entry(attribute_unit, - input_profile->attribute_units[index]); + indexed_attribute_key = ""; + indexed_attribute_key_index = indexed_attribute_entry->key_strindex; - if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; - } - } + if (dictionary->string_table != NULL && + indexed_attribute_key_index >= 0 && + (size_t) indexed_attribute_key_index < dictionary->n_string_table && + dictionary->string_table[indexed_attribute_key_index] != NULL) { + indexed_attribute_key = dictionary->string_table[indexed_attribute_key_index]; + } - for (index = 0 ; - index < input_profile->n_link_table; - index++) { - link = cprof_link_create(profile); + indexed_attribute_value = clone_variant(indexed_attribute_entry->value); - if (link == NULL) { - return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; - } + if (indexed_attribute_value == NULL) { + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } - result = decode_link_table_entry(link, - input_profile->link_table[index]); + if (cfl_kvlist_insert(profile->attributes, + indexed_attribute_key, + indexed_attribute_value) != 0) { + cfl_variant_destroy(indexed_attribute_value); - if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + } } } - for (index = 0 ; - index < input_profile->n_string_table; - index++) { - string_table_add_result = cprof_profile_string_add( - profile, - input_profile->string_table[index], - strlen(input_profile->string_table[index])); - - if (string_table_add_result == -1) { + /* Profile sample_type (single ValueType in new proto) */ + if (input_profile->sample_type != NULL) { + sample_type = cprof_sample_type_create(profile, + (int64_t)input_profile->sample_type->type_strindex, + (int64_t)input_profile->sample_type->unit_strindex, + 0); + if (sample_type == NULL) { return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; } } - for (index = 0 ; - index < input_profile->n_comment; - index++) { - result = cprof_profile_add_comment( - profile, - input_profile->comment[index]); - - if (result != 0) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + /* Samples */ + if (input_profile->samples != NULL) { + for (index = 0; index < input_profile->n_samples; index++) { + sample = cprof_sample_create(profile); + if (sample == NULL) { + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + result = decode_profile_sample_entry(sample, + input_profile->samples[index], dictionary); + if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { + return result; + } } } - profile->drop_frames = input_profile->drop_frames; - profile->keep_frames = input_profile->keep_frames; - - profile->time_nanos = input_profile->time_nanos; - profile->duration_nanos = input_profile->duration_nanos; + profile->time_nanos = (int64_t)input_profile->time_unix_nano; + profile->duration_nanos = (int64_t)input_profile->duration_nano; + profile->drop_frames = 0; + profile->keep_frames = 0; + profile->period = input_profile->period; if (input_profile->period_type != NULL) { - profile->period_type.type = input_profile->period_type->type; - profile->period_type.unit = input_profile->period_type->unit; - profile->period_type.aggregation_temporality = input_profile->period_type->aggregation_temporality; + profile->period_type.type = (int64_t)input_profile->period_type->type_strindex; + profile->period_type.unit = (int64_t)input_profile->period_type->unit_strindex; + profile->period_type.aggregation_temporality = 0; } - profile->period = input_profile->period; - profile->default_sample_type = input_profile->default_sample_type; + profile->default_sample_type = 0; return CPROF_DECODE_OPENTELEMETRY_SUCCESS; } -static int decode_profile_container_entry(struct cprof_scope_profiles *scope_profiles, - Opentelemetry__Proto__Profiles__V1development__ProfileContainer *input_profile_container) +static int decode_profile_into_scope(struct cprof_scope_profiles *scope_profiles, + Opentelemetry__Proto__Profiles__V1development__Profile *input_profile, + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dictionary) { - struct cprof_profile *profile; - int result; - - if (input_profile_container->profile_id.data == NULL || - input_profile_container->profile_id.len != 16) { - return CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; - } + struct cprof_profile *profile; + int result; profile = cprof_profile_create(); - if (profile == NULL) { return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; } - memcpy(profile->profile_id, - input_profile_container->profile_id.data, - sizeof(profile->profile_id)); - - profile->start_time_unix_nano = input_profile_container->start_time_unix_nano; - profile->end_time_unix_nano = input_profile_container->end_time_unix_nano; - - - result = convert_kvarray_to_kvlist(profile->attributes, - input_profile_container->attributes, - input_profile_container->n_attributes); - - if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { - cprof_profile_destroy(profile); - - return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + /* Profile-level fields (no ProfileContainer in new proto) */ + if (input_profile->profile_id.data != NULL && input_profile->profile_id.len >= 16) { + memcpy(profile->profile_id, input_profile->profile_id.data, 16); + } + else { + memset(profile->profile_id, 0, sizeof(profile->profile_id)); } - profile->dropped_attributes_count = input_profile_container->dropped_attributes_count; + profile->start_time_unix_nano = (int64_t)input_profile->time_unix_nano; + profile->end_time_unix_nano = (int64_t)input_profile->time_unix_nano + + (int64_t)input_profile->duration_nano; - if (input_profile_container->original_payload_format != NULL) { - profile->original_payload_format = cfl_sds_create(input_profile_container->original_payload_format); + profile->dropped_attributes_count = input_profile->dropped_attributes_count; + if (input_profile->original_payload_format != NULL && input_profile->original_payload_format[0] != '\0') { + profile->original_payload_format = cfl_sds_create(input_profile->original_payload_format); if (profile->original_payload_format == NULL) { cprof_profile_destroy(profile); - return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; } } - if (input_profile_container->original_payload.data != NULL && - input_profile_container->original_payload.len > 0) { - profile->original_payload = \ - cfl_sds_create_len( - (const char *) input_profile_container->original_payload.data, - input_profile_container->original_payload.len); - + if (input_profile->original_payload.data != NULL && input_profile->original_payload.len > 0) { + profile->original_payload = cfl_sds_create_len( + (const char *)input_profile->original_payload.data, + input_profile->original_payload.len); if (profile->original_payload == NULL) { cprof_profile_destroy(profile); - return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; } } - result = decode_profile_entry( - profile, - input_profile_container->profile); - + result = decode_profile_entry(profile, input_profile, dictionary); if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { + cprof_profile_destroy(profile); return result; } cfl_list_add(&profile->_head, &scope_profiles->profiles); - return CPROF_DECODE_OPENTELEMETRY_SUCCESS; } - static int decode_scope_profiles_entry(struct cprof_resource_profiles *resource_profiles, - Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *input_scope_profiles) + Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *input_scope_profiles, + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dictionary) { struct cprof_scope_profiles *profiles; int result; size_t index; profiles = cprof_scope_profiles_create( - resource_profiles, - input_scope_profiles->schema_url); + resource_profiles, + input_scope_profiles->schema_url != NULL ? input_scope_profiles->schema_url : ""); if (profiles == NULL) { return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; } - profiles->scope = decode_instrumentation_scope(input_scope_profiles->scope); + if (input_scope_profiles->scope != NULL) { + profiles->scope = decode_instrumentation_scope(input_scope_profiles->scope); + } + else { + profiles->scope = cprof_instrumentation_scope_create(NULL, NULL, NULL, 0); + } if (profiles->scope == NULL) { - cprof_scope_profiles_destroy(profiles); - return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; } - if (input_scope_profiles->n_profiles > 0) { - for (index = 0 ; - index < input_scope_profiles->n_profiles ; - index++) { - result = decode_profile_container_entry( - profiles, - input_scope_profiles->profiles[index]); - + if (input_scope_profiles->profiles != NULL && input_scope_profiles->n_profiles > 0) { + for (index = 0; index < input_scope_profiles->n_profiles; index++) { + result = decode_profile_into_scope(profiles, + input_scope_profiles->profiles[index], dictionary); if (result != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { - cprof_scope_profiles_destroy(profiles); - return result; } } } + /* cprof_scope_profiles_create already added profiles to resource_profiles */ return CPROF_DECODE_OPENTELEMETRY_SUCCESS; } static int decode_resource_profiles_entry(struct cprof *context, - Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *resource_profile) + Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *resource_profile, + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dictionary) { struct cprof_resource_profiles *profile; int result; size_t index; - profile = cprof_resource_profiles_create(resource_profile->schema_url); + profile = cprof_resource_profiles_create( + resource_profile->schema_url != NULL ? resource_profile->schema_url : ""); if (profile == NULL) { return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; @@ -630,15 +655,13 @@ static int decode_resource_profiles_entry(struct cprof *context, result = CPROF_DECODE_OPENTELEMETRY_SUCCESS; - if (resource_profile->n_scope_profiles > 0) { - for (index = 0 ; + if (resource_profile->scope_profiles != NULL && resource_profile->n_scope_profiles > 0) { + for (index = 0; result == CPROF_DECODE_OPENTELEMETRY_SUCCESS && - index < resource_profile->n_scope_profiles ; + index < resource_profile->n_scope_profiles; index++) { - - result = decode_scope_profiles_entry( - profile, - resource_profile->scope_profiles[index]); + result = decode_scope_profiles_entry(profile, + resource_profile->scope_profiles[index], dictionary); } } @@ -661,20 +684,20 @@ static int decode_resource_profiles_entry(struct cprof *context, static int decode_service_request(struct cprof *context, Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfilesServiceRequest *service_request) { - int result; - size_t index; + int result; + size_t index; + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dictionary; + dictionary = service_request->dictionary; result = CPROF_DECODE_OPENTELEMETRY_SUCCESS; - if (service_request->n_resource_profiles > 0) { - for (index = 0 ; + if (service_request->resource_profiles != NULL && service_request->n_resource_profiles > 0) { + for (index = 0; result == CPROF_DECODE_OPENTELEMETRY_SUCCESS && - index < service_request->n_resource_profiles ; + index < service_request->n_resource_profiles; index++) { - - result = decode_resource_profiles_entry( - context, - service_request->resource_profiles[index]); + result = decode_resource_profiles_entry(context, + service_request->resource_profiles[index], dictionary); } } @@ -691,6 +714,11 @@ int cprof_decode_opentelemetry_create(struct cprof **result_context, int result; result = CPROF_DECODE_OPENTELEMETRY_INVALID_ARGUMENT_ERROR; + context = NULL; + + if (result_context != NULL) { + *result_context = NULL; + } service_request = opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__unpack( NULL, @@ -713,6 +741,9 @@ int cprof_decode_opentelemetry_create(struct cprof **result_context, if (result == CPROF_DECODE_OPENTELEMETRY_SUCCESS) { *result_context = context; } + else if (context != NULL) { + cprof_destroy(context); + } return result; } @@ -722,4 +753,4 @@ void cprof_decode_opentelemetry_destroy(struct cprof *context) if (context != NULL) { cprof_destroy(context); } -} \ No newline at end of file +} diff --git a/lib/cprofiles/src/cprof_encode_opentelemetry.c b/lib/cprofiles/src/cprof_encode_opentelemetry.c index 59409c21cb7..2a86fb72096 100644 --- a/lib/cprofiles/src/cprof_encode_opentelemetry.c +++ b/lib/cprofiles/src/cprof_encode_opentelemetry.c @@ -20,6 +20,7 @@ #include #include +#include static int is_string_releaseable(char *address) { @@ -612,16 +613,12 @@ static void destroy_sample( instance) { if (instance != NULL) { - if (instance->location_index != NULL) { - free(instance->location_index); + if (instance->values != NULL) { + free(instance->values); } - if (instance->value != NULL) { - free(instance->value); - } - - if (instance->attributes != NULL) { - free(instance->attributes); + if (instance->attribute_indices != NULL) { + free(instance->attribute_indices); } if (instance->timestamps_unix_nano != NULL) { @@ -638,8 +635,8 @@ static void destroy_mapping( instance) { if (instance != NULL) { - if (instance->attributes != NULL) { - free(instance->attributes); + if (instance->attribute_indices != NULL) { + free(instance->attribute_indices); } free(instance); @@ -696,27 +693,30 @@ static void destroy_location( size_t index; if (instance != NULL) { - if (instance->line != NULL) { - for (index = 0 ; index < instance->n_line ; index++) { - destroy_line(instance->line[index]); + if (instance->lines != NULL) { + for (index = 0 ; index < instance->n_lines ; index++) { + destroy_line(instance->lines[index]); } - free(instance->line); + free(instance->lines); } - if (instance->attributes != NULL) { - free(instance->attributes); + if (instance->attribute_indices != NULL) { + free(instance->attribute_indices); } free(instance); } } -static void destroy_attribute_unit( - Opentelemetry__Proto__Profiles__V1development__AttributeUnit * +static void destroy_keyvalueandunit( + Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit * instance) { if (instance != NULL) { + if (instance->value != NULL) { + otlp_any_value_destroy(instance->value); + } free(instance); } } @@ -761,114 +761,36 @@ static void destroy_profile( if (instance != NULL) { if (instance->sample_type != NULL) { - for (index = 0 ; index < instance->n_sample_type ; index++) { - destroy_value_type(instance->sample_type[index]); - } - - free(instance->sample_type); - } - - if (instance->sample != NULL) { - for (index = 0 ; index < instance->n_sample ; index++) { - destroy_sample(instance->sample[index]); - } - - free(instance->sample); - } - - if (instance->mapping != NULL) { - for (index = 0 ; index < instance->n_mapping ; index++) { - destroy_mapping(instance->mapping[index]); - } - - free(instance->mapping); - } - - if (instance->location != NULL) { - for (index = 0 ; index < instance->n_location ; index++) { - destroy_location(instance->location[index]); - } - - free(instance->location); - } - - if (instance->location_indices != NULL) { - free(instance->location_indices); - } - - if (instance->function != NULL) { - for (index = 0 ; index < instance->n_function ; index++) { - destroy_function(instance->function[index]); - } - - free(instance->function); - } - - if (instance->attribute_table != NULL) { - destroy_attribute_list(instance->attribute_table); - } - - for (index = 0 ; index < instance->n_attribute_units ; index++) { - destroy_attribute_unit(instance->attribute_units[index]); - } - - if (instance->link_table != NULL) { - for (index = 0 ; index < instance->n_link_table ; index++) { - destroy_link(instance->link_table[index]); - } - - free(instance->link_table); + destroy_value_type(instance->sample_type); } - if (instance->string_table != NULL) { - for (index = 0 ; index < instance->n_string_table ; index++) { - if (is_string_releaseable(instance->string_table[index])) { - cfl_sds_destroy(instance->string_table[index]); - } + if (instance->samples != NULL) { + for (index = 0 ; index < instance->n_samples ; index++) { + destroy_sample(instance->samples[index]); } - - free(instance->string_table); + free(instance->samples); } if (instance->period_type != NULL) { destroy_value_type(instance->period_type); } - if (instance->comment != NULL) { - free(instance->comment); + if (instance->attribute_indices != NULL) { + free(instance->attribute_indices); } - free(instance); - } -} - -static void destroy_profile_container( - Opentelemetry__Proto__Profiles__V1development__ProfileContainer * - instance) -{ - if (instance != NULL) { - if (instance->profile_id.data != NULL) { - if (is_string_releaseable((cfl_sds_t) instance->profile_id.data)) { - cfl_sds_destroy((cfl_sds_t) instance->profile_id.data); - } + if (instance->profile_id.data != NULL && is_string_releaseable((char *)instance->profile_id.data)) { + free(instance->profile_id.data); } - destroy_attribute_list(instance->attributes); - - if (instance->original_payload_format != NULL) { - if (is_string_releaseable(instance->original_payload_format)) { - cfl_sds_destroy(instance->original_payload_format); - } + if (instance->original_payload_format != NULL && is_string_releaseable(instance->original_payload_format)) { + free(instance->original_payload_format); } - if (instance->original_payload.data != NULL) { - if (is_string_releaseable((cfl_sds_t) instance->original_payload.data)) { - cfl_sds_destroy((cfl_sds_t) instance->original_payload.data); - } + if (instance->original_payload.data != NULL && is_string_releaseable((char *)instance->original_payload.data)) { + free(instance->original_payload.data); } - destroy_profile(instance->profile); - free(instance); } } @@ -886,7 +808,7 @@ static void destroy_scope_profiles( if (instance->profiles != NULL) { for (index = 0 ; index < instance->n_profiles ; index++) { - destroy_profile_container(instance->profiles[index]); + destroy_profile(instance->profiles[index]); } free(instance->profiles); @@ -930,6 +852,71 @@ static void destroy_resource_profiles( } } +static void destroy_stack(Opentelemetry__Proto__Profiles__V1development__Stack *instance) +{ + if (instance != NULL) { + if (instance->location_indices != NULL) { + free(instance->location_indices); + } + free(instance); + } +} + +static void destroy_profiles_dictionary( + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dict) +{ + size_t index; + + if (dict == NULL) { + return; + } + if (dict->mapping_table != NULL) { + for (index = 0; index < dict->n_mapping_table; index++) { + destroy_mapping(dict->mapping_table[index]); + } + free(dict->mapping_table); + } + if (dict->location_table != NULL) { + for (index = 0; index < dict->n_location_table; index++) { + destroy_location(dict->location_table[index]); + } + free(dict->location_table); + } + if (dict->function_table != NULL) { + for (index = 0; index < dict->n_function_table; index++) { + destroy_function(dict->function_table[index]); + } + free(dict->function_table); + } + if (dict->link_table != NULL) { + for (index = 0; index < dict->n_link_table; index++) { + destroy_link(dict->link_table[index]); + } + free(dict->link_table); + } + if (dict->string_table != NULL) { + for (index = 0; index < dict->n_string_table; index++) { + if (dict->string_table[index] != NULL) { + cfl_sds_destroy((cfl_sds_t) dict->string_table[index]); + } + } + free(dict->string_table); + } + if (dict->attribute_table != NULL) { + for (index = 0; index < dict->n_attribute_table; index++) { + destroy_keyvalueandunit(dict->attribute_table[index]); + } + free(dict->attribute_table); + } + if (dict->stack_table != NULL) { + for (index = 0; index < dict->n_stack_table; index++) { + destroy_stack(dict->stack_table[index]); + } + free(dict->stack_table); + } + free(dict); +} + static void destroy_export_profiles_service_request( Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfilesServiceRequest * instance) @@ -945,276 +932,844 @@ static void destroy_export_profiles_service_request( free(instance->resource_profiles); } + if (instance->dictionary != NULL) { + destroy_profiles_dictionary(instance->dictionary); + } + free(instance); } } +/* + * Per-profile encoding state: maps profile-local indices to dictionary indices. + * Used when packing so ValueType.type_strindex, Sample.stack_index, etc. point into the dictionary. + */ +struct profile_encoding_state { + int32_t *string_map; /* profile string_table index -> dict string index */ + size_t string_map_count; + int32_t *mapping_map; /* profile mapping index -> dict mapping index */ + size_t mapping_map_count; + int32_t *function_map; + size_t function_map_count; + int32_t *location_map; + size_t location_map_count; + int32_t *link_map; + size_t link_map_count; + int32_t *stack_index_by_sample; /* sample index -> dict stack index */ + size_t sample_count; +}; + +static void free_profile_encoding_state(struct profile_encoding_state *s) +{ + if (s == NULL) { + return; + } + free(s->string_map); + free(s->mapping_map); + free(s->function_map); + free(s->location_map); + free(s->link_map); + free(s->stack_index_by_sample); +} + +/* Internal context passed through pack_* to access dictionary encoding state per profile */ +typedef struct { + struct cprof_opentelemetry_encoding_context *pub; + struct profile_encoding_state *encoding_states; + size_t encoding_states_count; + size_t current_profile_index; +} encoder_internal_ctx_t; + +/* Find or add string in dictionary; returns dict string index. */ +static int32_t dict_add_string( + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dict, + const char *str) +{ + size_t i; + char *dup; + if (str == NULL) { + str = ""; + } + for (i = 0; i < dict->n_string_table; i++) { + if (dict->string_table[i] != NULL && strcmp(dict->string_table[i], str) == 0) { + return (int32_t) i; + } + } + dup = cfl_sds_create(str); + if (dup == NULL) { + return -1; + } + dict->string_table = realloc(dict->string_table, + (dict->n_string_table + 1) * sizeof(char *)); + if (dict->string_table == NULL) { + cfl_sds_destroy(dup); + return -1; + } + dict->string_table[dict->n_string_table] = dup; + return (int32_t) dict->n_string_table++; +} +/* Find or add stack (location_indices) in dictionary; returns dict stack index. */ +static int32_t dict_add_stack( + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dict, + const int32_t *location_indices, + size_t n_location_indices) +{ + size_t i; + size_t j; + Opentelemetry__Proto__Profiles__V1development__Stack **stacks; + Opentelemetry__Proto__Profiles__V1development__Stack *stack; -static - Opentelemetry__Proto__Profiles__V1development__ValueType * - initialize_value_type() { - Opentelemetry__Proto__Profiles__V1development__ValueType *instance; + for (i = 0; i < dict->n_stack_table; i++) { + if (dict->stack_table[i]->n_location_indices != n_location_indices) { + continue; + } + for (j = 0; j < n_location_indices; j++) { + if (dict->stack_table[i]->location_indices[j] != location_indices[j]) { + break; + } + } + if (j == n_location_indices) { + return (int32_t) i; + } + } + stack = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Stack)); + if (stack == NULL) { + return -1; + } + opentelemetry__proto__profiles__v1development__stack__init(stack); + if (n_location_indices > 0) { + stack->location_indices = malloc(n_location_indices * sizeof(int32_t)); + if (stack->location_indices == NULL) { + free(stack); + return -1; + } + memcpy(stack->location_indices, location_indices, n_location_indices * sizeof(int32_t)); + stack->n_location_indices = n_location_indices; + } + stacks = realloc(dict->stack_table, + (dict->n_stack_table + 1) * sizeof(Opentelemetry__Proto__Profiles__V1development__Stack *)); + if (stacks == NULL) { + free(stack->location_indices); + free(stack); + return -1; + } + dict->stack_table = stacks; + dict->stack_table[dict->n_stack_table] = stack; + return (int32_t) dict->n_stack_table++; +} - instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__ValueType)); +/* Build OTLP Mapping from cprof_mapping; caller must destroy. Uses string_map for filename_strindex. */ +static Opentelemetry__Proto__Profiles__V1development__Mapping * +dict_build_mapping(struct cprof_mapping *m, + const int32_t *string_map, + size_t string_map_count) +{ + Opentelemetry__Proto__Profiles__V1development__Mapping *otlp; - if (instance == NULL) { + otlp = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Mapping)); + if (otlp == NULL) { return NULL; } + opentelemetry__proto__profiles__v1development__mapping__init(otlp); + otlp->memory_start = m->memory_start; + otlp->memory_limit = m->memory_limit; + otlp->file_offset = m->file_offset; + if (m->filename >= 0 && (size_t)m->filename < string_map_count) { + otlp->filename_strindex = string_map[m->filename]; + } + else { + otlp->filename_strindex = 0; + } + /* attribute_indices reference dict attribute_table; leave 0 for now */ + return otlp; +} - opentelemetry__proto__profiles__v1development__value_type__init(instance); +/* Compare two OTLP Mappings (excluding attribute_indices). */ +static int mapping_equal(const Opentelemetry__Proto__Profiles__V1development__Mapping *a, + const Opentelemetry__Proto__Profiles__V1development__Mapping *b) +{ + return a->memory_start == b->memory_start && + a->memory_limit == b->memory_limit && + a->file_offset == b->file_offset && + a->filename_strindex == b->filename_strindex; +} + +/* Find or add Mapping in dictionary; returns dict mapping index or -1 on error. */ +static int32_t dict_add_mapping( + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dict, + struct cprof_mapping *m, + const int32_t *string_map, + size_t string_map_count) +{ + Opentelemetry__Proto__Profiles__V1development__Mapping *otlp; + Opentelemetry__Proto__Profiles__V1development__Mapping **tab; + size_t i; - return instance; + otlp = dict_build_mapping(m, string_map, string_map_count); + if (otlp == NULL) { + return -1; + } + for (i = 0; i < dict->n_mapping_table; i++) { + if (mapping_equal(dict->mapping_table[i], otlp)) { + destroy_mapping(otlp); + return (int32_t) i; + } + } + tab = realloc(dict->mapping_table, + (dict->n_mapping_table + 1) * sizeof(Opentelemetry__Proto__Profiles__V1development__Mapping *)); + if (tab == NULL) { + destroy_mapping(otlp); + return -1; + } + dict->mapping_table = tab; + dict->mapping_table[dict->n_mapping_table] = otlp; + return (int32_t) dict->n_mapping_table++; } +/* Build OTLP Function from cprof_function; caller must destroy. */ +static Opentelemetry__Proto__Profiles__V1development__Function * +dict_build_function(struct cprof_function *f, + const int32_t *string_map, + size_t string_map_count) +{ + Opentelemetry__Proto__Profiles__V1development__Function *otlp; + otlp = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Function)); + if (otlp == NULL) { + return NULL; + } + opentelemetry__proto__profiles__v1development__function__init(otlp); + if (f->name >= 0 && (size_t)f->name < string_map_count) { + otlp->name_strindex = string_map[f->name]; + } + else { + otlp->name_strindex = 0; + } + if (f->system_name >= 0 && (size_t)f->system_name < string_map_count) { + otlp->system_name_strindex = string_map[f->system_name]; + } + else { + otlp->system_name_strindex = 0; + } + if (f->filename >= 0 && (size_t)f->filename < string_map_count) { + otlp->filename_strindex = string_map[f->filename]; + } + else { + otlp->filename_strindex = 0; + } + otlp->start_line = f->start_line; + return otlp; +} -static - Opentelemetry__Proto__Profiles__V1development__Sample * - initialize_sample( - size_t location_index_count, - size_t value_count, - size_t attributes_count, - size_t timestamps_count) { - Opentelemetry__Proto__Profiles__V1development__Sample *instance; +static int function_equal(const Opentelemetry__Proto__Profiles__V1development__Function *a, + const Opentelemetry__Proto__Profiles__V1development__Function *b) +{ + return a->name_strindex == b->name_strindex && + a->system_name_strindex == b->system_name_strindex && + a->filename_strindex == b->filename_strindex && + a->start_line == b->start_line; +} - instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Sample)); +static int32_t dict_add_function( + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dict, + struct cprof_function *f, + const int32_t *string_map, + size_t string_map_count) +{ + Opentelemetry__Proto__Profiles__V1development__Function *otlp; + Opentelemetry__Proto__Profiles__V1development__Function **tab; + size_t i; - if (instance == NULL) { - return NULL; + otlp = dict_build_function(f, string_map, string_map_count); + if (otlp == NULL) { + return -1; } + for (i = 0; i < dict->n_function_table; i++) { + if (function_equal(dict->function_table[i], otlp)) { + destroy_function(otlp); + return (int32_t) i; + } + } + tab = realloc(dict->function_table, + (dict->n_function_table + 1) * sizeof(Opentelemetry__Proto__Profiles__V1development__Function *)); + if (tab == NULL) { + destroy_function(otlp); + return -1; + } + dict->function_table = tab; + dict->function_table[dict->n_function_table] = otlp; + return (int32_t) dict->n_function_table++; +} - opentelemetry__proto__profiles__v1development__sample__init(instance); - - if (location_index_count > 0) { - instance->location_index = calloc(location_index_count, sizeof(uint64_t)); +static Opentelemetry__Proto__Profiles__V1development__Location *initialize_location(size_t line_count, size_t attribute_count); +static Opentelemetry__Proto__Profiles__V1development__Link *initialize_link(void); - if (instance->location_index == NULL) { - destroy_sample(instance); +/* Build OTLP Location from cprof_location; uses mapping_map and function_map for indices. Caller must destroy. */ +static Opentelemetry__Proto__Profiles__V1development__Location * +dict_build_location(struct cprof_location *loc, + const int32_t *mapping_map, + size_t mapping_map_count, + const int32_t *function_map, + size_t function_map_count) +{ + Opentelemetry__Proto__Profiles__V1development__Location *otlp; + struct cfl_list *line_iter; + struct cprof_line *line; + size_t n_lines; + size_t idx; + + n_lines = cfl_list_size(&loc->lines); + otlp = initialize_location(n_lines, 0); + if (otlp == NULL) { + return NULL; + } + if (loc->mapping_index < mapping_map_count) { + otlp->mapping_index = mapping_map[loc->mapping_index]; + } + else { + otlp->mapping_index = 0; + } + otlp->address = loc->address; + idx = 0; + cfl_list_foreach(line_iter, &loc->lines) { + line = cfl_list_entry(line_iter, struct cprof_line, _head); + otlp->lines[idx] = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Line)); + if (otlp->lines[idx] == NULL) { + destroy_location(otlp); return NULL; } - - instance->n_location_index = location_index_count; + opentelemetry__proto__profiles__v1development__line__init(otlp->lines[idx]); + if ((size_t)line->function_index < function_map_count) { + otlp->lines[idx]->function_index = function_map[line->function_index]; + } + else { + otlp->lines[idx]->function_index = 0; + } + otlp->lines[idx]->line = line->line; + otlp->lines[idx]->column = line->column; + idx++; } - if (value_count > 0) { - instance->value = calloc(value_count, sizeof(int64_t)); + return otlp; +} - if (instance->value == NULL) { - destroy_sample(instance); +static int location_equal(const Opentelemetry__Proto__Profiles__V1development__Location *a, + const Opentelemetry__Proto__Profiles__V1development__Location *b) +{ + size_t i; - return NULL; + if (a->mapping_index != b->mapping_index || a->address != b->address || a->n_lines != b->n_lines) { + return 0; + } + for (i = 0; i < a->n_lines; i++) { + if (a->lines[i]->function_index != b->lines[i]->function_index || + a->lines[i]->line != b->lines[i]->line || + a->lines[i]->column != b->lines[i]->column) { + return 0; } - - instance->n_value = value_count; } + return 1; +} - if (attributes_count > 0) { - instance->attributes = calloc(attributes_count, sizeof(uint64_t)); - - if (instance->attributes == NULL) { - destroy_sample(instance); +static int32_t dict_add_location( + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dict, + struct cprof_location *loc, + const int32_t *mapping_map, + size_t mapping_map_count, + const int32_t *function_map, + size_t function_map_count) +{ + Opentelemetry__Proto__Profiles__V1development__Location *otlp; + Opentelemetry__Proto__Profiles__V1development__Location **tab; + size_t i; - return NULL; + otlp = dict_build_location(loc, mapping_map, mapping_map_count, function_map, function_map_count); + if (otlp == NULL) { + return -1; + } + for (i = 0; i < dict->n_location_table; i++) { + if (location_equal(dict->location_table[i], otlp)) { + destroy_location(otlp); + return (int32_t) i; } + } + tab = realloc(dict->location_table, + (dict->n_location_table + 1) * sizeof(Opentelemetry__Proto__Profiles__V1development__Location *)); + if (tab == NULL) { + destroy_location(otlp); + return -1; + } + dict->location_table = tab; + dict->location_table[dict->n_location_table] = otlp; + return (int32_t) dict->n_location_table++; +} + +/* Build OTLP Link from cprof_link; caller must destroy. */ +static Opentelemetry__Proto__Profiles__V1development__Link * +dict_build_link(struct cprof_link *l) +{ + Opentelemetry__Proto__Profiles__V1development__Link *otlp; - instance->n_attributes = attributes_count; + otlp = initialize_link(); + if (otlp == NULL) { + return NULL; + } + otlp->trace_id.data = (uint8_t *) cfl_sds_create_len((const char *) l->trace_id, sizeof(l->trace_id)); + if (otlp->trace_id.data == NULL) { + destroy_link(otlp); + return NULL; } + otlp->trace_id.len = sizeof(l->trace_id); + otlp->span_id.data = (uint8_t *) cfl_sds_create_len((const char *) l->span_id, sizeof(l->span_id)); + if (otlp->span_id.data == NULL) { + destroy_link(otlp); + return NULL; + } + otlp->span_id.len = sizeof(l->span_id); + return otlp; +} - if (timestamps_count > 0) { - instance->timestamps_unix_nano = calloc(timestamps_count, sizeof(uint64_t)); +static int link_equal(const Opentelemetry__Proto__Profiles__V1development__Link *a, + const Opentelemetry__Proto__Profiles__V1development__Link *b) +{ + if (a->trace_id.len != b->trace_id.len || a->span_id.len != b->span_id.len) { + return 0; + } + return memcmp(a->trace_id.data, b->trace_id.data, a->trace_id.len) == 0 && + memcmp(a->span_id.data, b->span_id.data, a->span_id.len) == 0; +} - if (instance->timestamps_unix_nano == NULL) { - destroy_sample(instance); +static int32_t dict_add_link( + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dict, + struct cprof_link *l) +{ + Opentelemetry__Proto__Profiles__V1development__Link *otlp; + Opentelemetry__Proto__Profiles__V1development__Link **tab; + size_t i; - return NULL; + otlp = dict_build_link(l); + if (otlp == NULL) { + return -1; + } + for (i = 0; i < dict->n_link_table; i++) { + if (link_equal(dict->link_table[i], otlp)) { + destroy_link(otlp); + return (int32_t) i; } - - instance->n_timestamps_unix_nano = timestamps_count; } - - return instance; + tab = realloc(dict->link_table, + (dict->n_link_table + 1) * sizeof(Opentelemetry__Proto__Profiles__V1development__Link *)); + if (tab == NULL) { + destroy_link(otlp); + return -1; + } + dict->link_table = tab; + dict->link_table[dict->n_link_table] = otlp; + return (int32_t) dict->n_link_table++; } +/* + * Build ProfilesDictionary and per-profile encoding states from the full cprof tree. + * Caller must free encoding_states (and each state's arrays) and destroy the dictionary. + */ +static int build_profiles_dictionary( + struct cprof *cprof, + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary **out_dict, + struct profile_encoding_state **out_states, + size_t *out_state_count) +{ + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dict; + struct cfl_list *rp_iter; + struct cfl_list *sp_iter; + struct cfl_list *prof_iter; + struct cfl_list *map_iter; + struct cfl_list *func_iter; + struct cfl_list *loc_iter; + struct cfl_list *link_iter; + struct cfl_list *sample_iter; + struct cprof_resource_profiles *rp; + struct cprof_scope_profiles *sp; + struct cprof_profile *profile; + struct cprof_mapping *cprof_mapping; + struct cprof_function *cprof_func; + struct cprof_location *cprof_loc; + struct cprof_link *cprof_link; + struct cprof_sample *sample; + struct profile_encoding_state *states; + size_t state_count; + size_t state_idx; + size_t i; + size_t j; + size_t n_loc; + uint64_t loc_idx; + int32_t si; + int32_t loc_indices_buf[256]; + int32_t *loc_indices; + + state_count = 0; + cfl_list_foreach(rp_iter, &cprof->profiles) { + rp = cfl_list_entry(rp_iter, struct cprof_resource_profiles, _head); + cfl_list_foreach(sp_iter, &rp->scope_profiles) { + sp = cfl_list_entry(sp_iter, struct cprof_scope_profiles, _head); + state_count += cfl_list_size(&sp->profiles); + } + } + if (state_count == 0) { + *out_dict = NULL; + *out_states = NULL; + *out_state_count = 0; + return CPROF_ENCODE_OPENTELEMETRY_SUCCESS; + } + + dict = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary)); + if (dict == NULL) { + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + opentelemetry__proto__profiles__v1development__profiles_dictionary__init(dict); + /* string_table[0] = "" (required) */ + dict->string_table = malloc(sizeof(char *)); + if (dict->string_table == NULL) { + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + dict->string_table[0] = cfl_sds_create(""); + if (dict->string_table[0] == NULL) { + free(dict->string_table); + free(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + dict->n_string_table = 1; + /* stack_table[0] = zero Stack (required) */ + dict->stack_table = malloc(sizeof(Opentelemetry__Proto__Profiles__V1development__Stack *)); + if (dict->stack_table == NULL) { + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + dict->stack_table[0] = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Stack)); + if (dict->stack_table[0] == NULL) { + free(dict->stack_table); + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + opentelemetry__proto__profiles__v1development__stack__init(dict->stack_table[0]); + dict->n_stack_table = 1; + /* mapping_table[0] = zero Mapping (required) */ + dict->mapping_table = malloc(sizeof(Opentelemetry__Proto__Profiles__V1development__Mapping *)); + if (dict->mapping_table == NULL) { + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + dict->mapping_table[0] = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Mapping)); + if (dict->mapping_table[0] == NULL) { + free(dict->mapping_table); + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + opentelemetry__proto__profiles__v1development__mapping__init(dict->mapping_table[0]); + dict->n_mapping_table = 1; + /* location_table[0] = zero Location (required) */ + dict->location_table = malloc(sizeof(Opentelemetry__Proto__Profiles__V1development__Location *)); + if (dict->location_table == NULL) { + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + dict->location_table[0] = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Location)); + if (dict->location_table[0] == NULL) { + free(dict->location_table); + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + opentelemetry__proto__profiles__v1development__location__init(dict->location_table[0]); + dict->n_location_table = 1; -static - Opentelemetry__Proto__Resource__V1__Resource * - initialize_resource(size_t attribute_count) { - Opentelemetry__Proto__Resource__V1__Resource *instance; + /* function_table[0] = zero Function (required) */ + dict->function_table = malloc(sizeof(Opentelemetry__Proto__Profiles__V1development__Function *)); + if (dict->function_table == NULL) { + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + dict->function_table[0] = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Function)); + if (dict->function_table[0] == NULL) { + free(dict->function_table); + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + opentelemetry__proto__profiles__v1development__function__init(dict->function_table[0]); + dict->n_function_table = 1; - instance = calloc(1, sizeof(Opentelemetry__Proto__Resource__V1__Resource)); + /* link_table[0] = zero Link (required) */ + dict->link_table = malloc(sizeof(Opentelemetry__Proto__Profiles__V1development__Link *)); + if (dict->link_table == NULL) { + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + dict->link_table[0] = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Link)); + if (dict->link_table[0] == NULL) { + free(dict->link_table); + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + opentelemetry__proto__profiles__v1development__link__init(dict->link_table[0]); + dict->n_link_table = 1; - if (instance == NULL) { - return NULL; + states = calloc(state_count, sizeof(struct profile_encoding_state)); + if (states == NULL) { + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; } + state_idx = 0; + + cfl_list_foreach(rp_iter, &cprof->profiles) { + rp = cfl_list_entry(rp_iter, struct cprof_resource_profiles, _head); + cfl_list_foreach(sp_iter, &rp->scope_profiles) { + sp = cfl_list_entry(sp_iter, struct cprof_scope_profiles, _head); + cfl_list_foreach(prof_iter, &sp->profiles) { + profile = cfl_list_entry(prof_iter, struct cprof_profile, _head); + struct profile_encoding_state *st = &states[state_idx]; + + /* string_map: profile string_table index -> dict index */ + st->string_map_count = profile->string_table_count; + if (st->string_map_count > 0) { + st->string_map = malloc(st->string_map_count * sizeof(int32_t)); + if (st->string_map == NULL) { + goto fail; + } + for (i = 0; i < st->string_map_count; i++) { + si = dict_add_string(dict, + profile->string_table[i] ? profile->string_table[i] : ""); + if (si < 0) { + goto fail; + } + st->string_map[i] = si; + } + } - opentelemetry__proto__resource__v1__resource__init(instance); + /* stack_index_by_sample: for each sample, resolve location_index[] to dict stack */ + st->sample_count = cfl_list_size(&profile->samples); + if (st->sample_count > 0) { + st->stack_index_by_sample = malloc(st->sample_count * sizeof(int32_t)); + if (st->stack_index_by_sample == NULL) { + goto fail; + } + } - if (attribute_count > 0) { - instance->attributes = initialize_attribute_list(attribute_count); + /* Build mapping_table, function_table, location_table, link_table entries and + * per-profile maps (profile index -> dict index) so stacks reference real locations. */ + st->location_map_count = cfl_list_size(&profile->locations); + st->mapping_map_count = cfl_list_size(&profile->mappings); + st->function_map_count = cfl_list_size(&profile->functions); + st->link_map_count = cfl_list_size(&profile->link_table); + + if (st->mapping_map_count > 0) { + st->mapping_map = malloc(st->mapping_map_count * sizeof(int32_t)); + if (st->mapping_map == NULL) { + goto fail; + } + i = 0; + cfl_list_foreach(map_iter, &profile->mappings) { + cprof_mapping = cfl_list_entry(map_iter, struct cprof_mapping, _head); + si = dict_add_mapping(dict, cprof_mapping, st->string_map, st->string_map_count); + if (si < 0) { + goto fail; + } + st->mapping_map[i++] = si; + } + } + if (st->function_map_count > 0) { + st->function_map = malloc(st->function_map_count * sizeof(int32_t)); + if (st->function_map == NULL) { + goto fail; + } + i = 0; + cfl_list_foreach(func_iter, &profile->functions) { + cprof_func = cfl_list_entry(func_iter, struct cprof_function, _head); + si = dict_add_function(dict, cprof_func, st->string_map, st->string_map_count); + if (si < 0) { + goto fail; + } + st->function_map[i++] = si; + } + } + if (st->location_map_count > 0) { + st->location_map = malloc(st->location_map_count * sizeof(int32_t)); + if (st->location_map == NULL) { + goto fail; + } + i = 0; + cfl_list_foreach(loc_iter, &profile->locations) { + cprof_loc = cfl_list_entry(loc_iter, struct cprof_location, _head); + si = dict_add_location(dict, cprof_loc, + st->mapping_map, st->mapping_map_count, + st->function_map, st->function_map_count); + if (si < 0) { + goto fail; + } + st->location_map[i++] = si; + } + } + if (st->link_map_count > 0) { + st->link_map = malloc(st->link_map_count * sizeof(int32_t)); + if (st->link_map == NULL) { + goto fail; + } + i = 0; + cfl_list_foreach(link_iter, &profile->link_table) { + cprof_link = cfl_list_entry(link_iter, struct cprof_link, _head); + si = dict_add_link(dict, cprof_link); + if (si < 0) { + goto fail; + } + st->link_map[i++] = si; + } + } - if (instance->attributes == NULL) { - free(instance); + /* Build stack_index_by_sample: map each sample's location_index[] to dict stack */ + j = 0; + cfl_list_foreach(sample_iter, &profile->samples) { + loc_indices = loc_indices_buf; + sample = cfl_list_entry(sample_iter, struct cprof_sample, _head); + n_loc = sample->location_index_count; + if (n_loc == 0) { + si = 0; /* zero stack */ + } + else { + if (n_loc > 256) { + loc_indices = malloc(n_loc * sizeof(int32_t)); + if (loc_indices == NULL) { + goto fail; + } + } + for (i = 0; i < n_loc; i++) { + loc_idx = sample->location_index[i]; + loc_indices[i] = (loc_idx < st->location_map_count) + ? st->location_map[loc_idx] : 0; + } + si = dict_add_stack(dict, loc_indices, n_loc); + if (n_loc > 256) { + free(loc_indices); + } + if (si < 0) { + goto fail; + } + } + st->stack_index_by_sample[j++] = si; + } - return NULL; + state_idx++; + } } } - instance->n_attributes = attribute_count; - - return instance; -} - -static - Opentelemetry__Proto__Profiles__V1development__AttributeUnit * - initialize_attribute_unit() { - Opentelemetry__Proto__Profiles__V1development__AttributeUnit *instance; - - instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__AttributeUnit)); - - if (instance == NULL) { - return NULL; + *out_dict = dict; + *out_states = states; + *out_state_count = state_count; + return CPROF_ENCODE_OPENTELEMETRY_SUCCESS; +fail: + for (i = 0; i < state_idx; i++) { + free_profile_encoding_state(&states[i]); } - - opentelemetry__proto__profiles__v1development__attribute_unit__init(instance); - - return instance; + free(states); + destroy_profiles_dictionary(dict); + return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; } static - Opentelemetry__Proto__Profiles__V1development__Line * - initialize_line() { - Opentelemetry__Proto__Profiles__V1development__Line *instance; + Opentelemetry__Proto__Profiles__V1development__ValueType * + initialize_value_type() { + Opentelemetry__Proto__Profiles__V1development__ValueType *instance; - instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Line)); + instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__ValueType)); if (instance == NULL) { return NULL; } - opentelemetry__proto__profiles__v1development__line__init(instance); + opentelemetry__proto__profiles__v1development__value_type__init(instance); return instance; } -static - Opentelemetry__Proto__Profiles__V1development__Link * - initialize_link() { - Opentelemetry__Proto__Profiles__V1development__Link *instance; - - instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Link)); - - if (instance == NULL) { - return NULL; - } - - opentelemetry__proto__profiles__v1development__link__init(instance); - return instance; -} static - Opentelemetry__Proto__Profiles__V1development__Location * - initialize_location(size_t line_count, size_t attribute_count) { - Opentelemetry__Proto__Profiles__V1development__Location *instance; + Opentelemetry__Proto__Profiles__V1development__Sample * + initialize_sample( + size_t value_count, + size_t attributes_count, + size_t timestamps_count) { + Opentelemetry__Proto__Profiles__V1development__Sample *instance; - instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Location)); + instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Sample)); if (instance == NULL) { return NULL; } - opentelemetry__proto__profiles__v1development__location__init(instance); + opentelemetry__proto__profiles__v1development__sample__init(instance); - if (line_count > 0) { - instance->line = calloc(line_count, sizeof(void *)); + if (value_count > 0) { + instance->values = calloc(value_count, sizeof(int64_t)); - if (instance->line == NULL) { - destroy_location(instance); + if (instance->values == NULL) { + destroy_sample(instance); return NULL; } - instance->n_line = line_count; + instance->n_values = value_count; } - if (attribute_count > 0) { - instance->attributes = calloc(attribute_count, sizeof(uint64_t)); + if (attributes_count > 0) { + instance->attribute_indices = calloc(attributes_count, sizeof(int32_t)); - if (instance->attributes == NULL) { - destroy_location(instance); + if (instance->attribute_indices == NULL) { + destroy_sample(instance); return NULL; } - instance->n_attributes = attribute_count; + instance->n_attribute_indices = attributes_count; } - return instance; -} + if (timestamps_count > 0) { + instance->timestamps_unix_nano = calloc(timestamps_count, sizeof(uint64_t)); -static - Opentelemetry__Proto__Profiles__V1development__Function * - initialize_function() { - Opentelemetry__Proto__Profiles__V1development__Function *instance; + if (instance->timestamps_unix_nano == NULL) { + destroy_sample(instance); - instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Function)); + return NULL; + } - if (instance == NULL) { - return NULL; + instance->n_timestamps_unix_nano = timestamps_count; } - opentelemetry__proto__profiles__v1development__function__init(instance); - return instance; } -static - Opentelemetry__Proto__Profiles__V1development__Mapping * - initialize_mapping(size_t attribute_count) { - Opentelemetry__Proto__Profiles__V1development__Mapping *instance; - - instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Mapping)); - - if (instance == NULL) { - return NULL; - } - - opentelemetry__proto__profiles__v1development__mapping__init(instance); - - if (attribute_count > 0) { - instance->attributes = calloc(attribute_count, sizeof(uint64_t)); - if (instance->attributes == NULL) { - destroy_mapping(instance); - return NULL; - } - instance->n_attributes = attribute_count; - } - return instance; -} static - Opentelemetry__Proto__Common__V1__InstrumentationScope * - initialize_instrumentation_scope(size_t attribute_count) { - Opentelemetry__Proto__Common__V1__InstrumentationScope *instance; + Opentelemetry__Proto__Resource__V1__Resource * + initialize_resource(size_t attribute_count) { + Opentelemetry__Proto__Resource__V1__Resource *instance; - instance = calloc(1, sizeof(Opentelemetry__Proto__Common__V1__InstrumentationScope)); + instance = calloc(1, sizeof(Opentelemetry__Proto__Resource__V1__Resource)); if (instance == NULL) { return NULL; } - opentelemetry__proto__common__v1__instrumentation_scope__init(instance); + opentelemetry__proto__resource__v1__resource__init(instance); if (attribute_count > 0) { instance->attributes = initialize_attribute_list(attribute_count); @@ -1232,193 +1787,130 @@ static } static - Opentelemetry__Proto__Profiles__V1development__Profile * - initialize_profile( - size_t sample_type_count, - size_t sample_count, - size_t mapping_count, - size_t location_count, - size_t location_index_count, - size_t function_count, - size_t attribute_count, - size_t attribute_unit_count, - size_t link_count, - size_t string_count, - size_t comment_count) { - Opentelemetry__Proto__Profiles__V1development__Profile *instance; + Opentelemetry__Proto__Profiles__V1development__Link * + initialize_link() { + Opentelemetry__Proto__Profiles__V1development__Link *instance; - instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Profile)); + instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Link)); if (instance == NULL) { return NULL; } - opentelemetry__proto__profiles__v1development__profile__init(instance); + opentelemetry__proto__profiles__v1development__link__init(instance); - if (sample_type_count > 0) { - instance->sample_type = calloc(sample_type_count, sizeof(void *)); + return instance; +} - if (instance->sample_type == NULL) { - destroy_profile(instance); +static + Opentelemetry__Proto__Profiles__V1development__Location * + initialize_location(size_t line_count, size_t attribute_count) { + Opentelemetry__Proto__Profiles__V1development__Location *instance; - return NULL; - } + instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Location)); - instance->n_sample_type = sample_type_count; + if (instance == NULL) { + return NULL; } - if (sample_count > 0) { - instance->sample = calloc(sample_count, sizeof(void *)); - - if (instance->sample == NULL) { - destroy_profile(instance); - - return NULL; - } - - instance->n_sample = sample_count; - } + opentelemetry__proto__profiles__v1development__location__init(instance); - if (mapping_count > 0) { - instance->mapping = calloc(mapping_count, sizeof(void *)); + if (line_count > 0) { + instance->lines = calloc(line_count, sizeof(void *)); - if (instance->mapping == NULL) { - destroy_profile(instance); + if (instance->lines == NULL) { + destroy_location(instance); return NULL; } - instance->n_mapping = mapping_count; + instance->n_lines = line_count; } - if (location_count > 0) { - instance->location = calloc(location_count, sizeof(void *)); + if (attribute_count > 0) { + instance->attribute_indices = calloc(attribute_count, sizeof(int32_t)); - if (instance->location == NULL) { - destroy_profile(instance); + if (instance->attribute_indices == NULL) { + destroy_location(instance); return NULL; } - instance->n_location = location_count; + instance->n_attribute_indices = attribute_count; } - if (location_index_count > 0) { - instance->location_indices = calloc(location_index_count, sizeof(uint64_t)); + return instance; +} - if (instance->location_indices == NULL) { - destroy_profile(instance); +static + Opentelemetry__Proto__Common__V1__InstrumentationScope * + initialize_instrumentation_scope(size_t attribute_count) { + Opentelemetry__Proto__Common__V1__InstrumentationScope *instance; - return NULL; - } + instance = calloc(1, sizeof(Opentelemetry__Proto__Common__V1__InstrumentationScope)); - instance->n_location_indices = location_index_count; + if (instance == NULL) { + return NULL; } - if (function_count > 0) { - instance->function = calloc(function_count, sizeof(void *)); - - if (instance->function == NULL) { - destroy_profile(instance); - - return NULL; - } - - instance->n_function = function_count; - } + opentelemetry__proto__common__v1__instrumentation_scope__init(instance); if (attribute_count > 0) { - instance->attribute_table = calloc(attribute_count, sizeof(void *)); + instance->attributes = initialize_attribute_list(attribute_count); - if (instance->attribute_table == NULL) { - destroy_profile(instance); + if (instance->attributes == NULL) { + free(instance); return NULL; } - - instance->n_attribute_table = attribute_count; } - if (attribute_unit_count > 0) { - instance->attribute_units = calloc(attribute_unit_count, sizeof(void *)); - - if (instance->attribute_units == NULL) { - destroy_profile(instance); - - return NULL; - } - - instance->n_attribute_units = attribute_unit_count; - } + instance->n_attributes = attribute_count; - if (link_count > 0) { - instance->link_table = calloc(link_count, sizeof(void *)); + return instance; +} - if (instance->link_table == NULL) { - destroy_profile(instance); +static + Opentelemetry__Proto__Profiles__V1development__Profile * + initialize_profile(size_t sample_count, size_t attribute_index_count) { + Opentelemetry__Proto__Profiles__V1development__Profile *instance; - return NULL; - } + instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__Profile)); - instance->n_link_table = link_count; + if (instance == NULL) { + return NULL; } - if (string_count > 0) { - instance->string_table = calloc(string_count, sizeof(void *)); + opentelemetry__proto__profiles__v1development__profile__init(instance); - if (instance->string_table == NULL) { + if (sample_count > 0) { + instance->samples = calloc(sample_count, sizeof(void *)); + + if (instance->samples == NULL) { destroy_profile(instance); return NULL; } - instance->n_string_table = string_count; + instance->n_samples = sample_count; } - if (comment_count > 0) { - instance->comment = calloc(comment_count, sizeof(void *)); + if (attribute_index_count > 0) { + instance->attribute_indices = calloc(attribute_index_count, sizeof(int32_t)); - if (instance->comment == NULL) { + if (instance->attribute_indices == NULL) { destroy_profile(instance); return NULL; } - instance->n_comment = comment_count; + instance->n_attribute_indices = attribute_index_count; } return instance; } -static - Opentelemetry__Proto__Profiles__V1development__ProfileContainer * - initialize_profile_container(size_t attribute_count) { - Opentelemetry__Proto__Profiles__V1development__ProfileContainer *instance; - - instance = calloc(1, sizeof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer)); - - if (instance == NULL) { - return NULL; - } - - opentelemetry__proto__profiles__v1development__profile_container__init(instance); - - if (attribute_count > 0) { - instance->attributes = initialize_attribute_list(attribute_count); - - if (instance->attributes == NULL) { - free(instance); - - return NULL; - } - } - - instance->n_attributes = attribute_count; - - return instance; -} - static Opentelemetry__Proto__Profiles__V1development__ScopeProfiles * initialize_scope_profiles(size_t profiles_count) { @@ -1588,7 +2080,8 @@ static int pack_cprof_instrumentation_scope( static int pack_cprof_value_type( Opentelemetry__Proto__Profiles__V1development__ValueType **output_instance, - struct cprof_value_type *input_instance) + struct cprof_value_type *input_instance, + struct profile_encoding_state *encoding_state) { Opentelemetry__Proto__Profiles__V1development__ValueType *otlp_value_type; @@ -1598,9 +2091,24 @@ static int pack_cprof_value_type( return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; } - otlp_value_type->type = input_instance->type; - otlp_value_type->unit = input_instance->unit; - otlp_value_type->aggregation_temporality = input_instance->aggregation_temporality; + if (encoding_state != NULL && encoding_state->string_map != NULL) { + if ((size_t)input_instance->type < encoding_state->string_map_count) { + otlp_value_type->type_strindex = encoding_state->string_map[input_instance->type]; + } + else { + otlp_value_type->type_strindex = 0; + } + if ((size_t)input_instance->unit < encoding_state->string_map_count) { + otlp_value_type->unit_strindex = encoding_state->string_map[input_instance->unit]; + } + else { + otlp_value_type->unit_strindex = 0; + } + } + else { + otlp_value_type->type_strindex = 0; + otlp_value_type->unit_strindex = 0; + } *output_instance = otlp_value_type; @@ -1609,13 +2117,14 @@ static int pack_cprof_value_type( static int pack_cprof_sample( Opentelemetry__Proto__Profiles__V1development__Sample **output_instance, - struct cprof_sample *input_instance) + struct cprof_sample *input_instance, + struct profile_encoding_state *encoding_state, + size_t sample_index) { Opentelemetry__Proto__Profiles__V1development__Sample *otlp_sample; size_t index; - otlp_sample = initialize_sample(input_instance->location_index_count, - input_instance->value_count, + otlp_sample = initialize_sample(input_instance->value_count, input_instance->attributes_count, input_instance->timestamps_count); @@ -1623,28 +2132,33 @@ static int pack_cprof_sample( return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; } - for (index = 0 ; - index < input_instance->location_index_count ; - index++) { - otlp_sample->location_index[index] = input_instance->location_index[index]; + if (encoding_state != NULL && encoding_state->stack_index_by_sample != NULL && + sample_index < encoding_state->sample_count) { + otlp_sample->stack_index = encoding_state->stack_index_by_sample[sample_index]; + } + else { + otlp_sample->stack_index = 0; } - - otlp_sample->locations_start_index = input_instance->locations_start_index; - otlp_sample->locations_length = input_instance->locations_length; for (index = 0 ; index < input_instance->value_count ; index++) { - otlp_sample->value[index] = input_instance->values[index]; + otlp_sample->values[index] = input_instance->values[index]; } for (index = 0 ; index < input_instance->attributes_count ; index++) { - otlp_sample->attributes[index] = input_instance->attributes[index]; + otlp_sample->attribute_indices[index] = (int32_t) input_instance->attributes[index]; } - otlp_sample->link = input_instance->link; + if (encoding_state != NULL && encoding_state->link_map != NULL && + (size_t)input_instance->link < encoding_state->link_map_count) { + otlp_sample->link_index = encoding_state->link_map[input_instance->link]; + } + else { + otlp_sample->link_index = 0; /* no link or link_table[0] sentinel */ + } for (index = 0 ; index < input_instance->timestamps_count ; @@ -1658,523 +2172,83 @@ static int pack_cprof_sample( } -static int pack_cprof_mapping( - Opentelemetry__Proto__Profiles__V1development__Mapping **output_instance, - struct cprof_mapping *input_instance) -{ - Opentelemetry__Proto__Profiles__V1development__Mapping *otlp_mapping; - size_t index; - - otlp_mapping = initialize_mapping(input_instance->attributes_count); - - if (otlp_mapping == NULL) { - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_mapping->id = input_instance->id; - otlp_mapping->memory_start = input_instance->memory_start; - otlp_mapping->memory_limit = input_instance->memory_limit; - otlp_mapping->file_offset = input_instance->file_offset; - otlp_mapping->filename = input_instance->filename; - - for (index = 0 ; - index < input_instance->attributes_count ; - index++) { - otlp_mapping->attributes[index] = input_instance->attributes[index]; - } - - otlp_mapping->has_functions = input_instance->has_functions; - otlp_mapping->has_filenames = input_instance->has_filenames; - otlp_mapping->has_line_numbers = input_instance->has_line_numbers; - otlp_mapping->has_inline_frames = input_instance->has_inline_frames; - - *output_instance = otlp_mapping; - - return CPROF_ENCODE_OPENTELEMETRY_SUCCESS; -} - - - -static int pack_cprof_line( - Opentelemetry__Proto__Profiles__V1development__Line **output_instance, - struct cprof_line *input_instance) -{ - Opentelemetry__Proto__Profiles__V1development__Line *otlp_line; - - otlp_line = initialize_line(); - - if (otlp_line == NULL) { - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_line->function_index = input_instance->function_index; - otlp_line->line = input_instance->line; - otlp_line->column = input_instance->column; - - *output_instance = otlp_line; - - return CPROF_ENCODE_OPENTELEMETRY_SUCCESS; -} - -static int pack_cprof_location( - Opentelemetry__Proto__Profiles__V1development__Location **output_instance, - struct cprof_location *input_instance) -{ - Opentelemetry__Proto__Profiles__V1development__Location *otlp_location; - struct cfl_list *iterator; - int result; - struct cprof_line *line; - size_t index; - - otlp_location = initialize_location(cfl_list_size(&input_instance->lines), - input_instance->attributes_count); - - if (otlp_location == NULL) { - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_location->id = input_instance->id; - otlp_location->mapping_index = input_instance->mapping_index; - otlp_location->address = input_instance->address; - - - index = 0; - cfl_list_foreach(iterator, - &input_instance->lines) { - line = cfl_list_entry( - iterator, - struct cprof_line, _head); - - result = pack_cprof_line( - &otlp_location->line[index], - line); - - if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { - destroy_location(otlp_location); - - return result; - } - - index++; - } - - otlp_location->is_folded = input_instance->is_folded; - - for (index = 0 ; - index < input_instance->attributes_count ; - index++) { - otlp_location->attributes[index] = input_instance->attributes[index]; - } - - *output_instance = otlp_location; - - return CPROF_ENCODE_OPENTELEMETRY_SUCCESS; -} - -static int pack_cprof_function( - Opentelemetry__Proto__Profiles__V1development__Function **output_instance, - struct cprof_function *input_instance) -{ - Opentelemetry__Proto__Profiles__V1development__Function *otlp_function; - - otlp_function = initialize_function(); - - if (otlp_function == NULL) { - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_function->id = input_instance->id; - otlp_function->name = input_instance->name; - otlp_function->system_name = input_instance->system_name; - otlp_function->filename = input_instance->filename; - otlp_function->start_line = input_instance->start_line; - - *output_instance = otlp_function; - - return CPROF_ENCODE_OPENTELEMETRY_SUCCESS; -} - -static int pack_cprof_attribute_unit( - Opentelemetry__Proto__Profiles__V1development__AttributeUnit **output_instance, - struct cprof_attribute_unit *input_instance) -{ - Opentelemetry__Proto__Profiles__V1development__AttributeUnit *otlp_attribute_unit; - - otlp_attribute_unit = initialize_attribute_unit(); - - if (otlp_attribute_unit == NULL) { - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_attribute_unit->attribute_key = input_instance->attribute_key; - otlp_attribute_unit->unit = input_instance->unit; - - *output_instance = otlp_attribute_unit; - - return CPROF_ENCODE_OPENTELEMETRY_SUCCESS; -} - -static int pack_cprof_link( - Opentelemetry__Proto__Profiles__V1development__Link **output_instance, - struct cprof_link *input_instance) -{ - Opentelemetry__Proto__Profiles__V1development__Link *otlp_link; - - otlp_link = initialize_link(); - - if (otlp_link == NULL) { - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_link->trace_id.data = \ - (uint8_t *) cfl_sds_create_len((const char *) input_instance->trace_id, - sizeof(input_instance->trace_id)); - - if (otlp_link->trace_id.data == NULL) { - destroy_link(otlp_link); - - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_link->trace_id.len = sizeof(input_instance->trace_id); - - - otlp_link->span_id.data = \ - (uint8_t *) cfl_sds_create_len((const char *) input_instance->span_id, - sizeof(input_instance->span_id)); - - if (otlp_link->span_id.data == NULL) { - destroy_link(otlp_link); - - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_link->span_id.len = sizeof(input_instance->span_id); - - - *output_instance = otlp_link; +static int pack_cprof_value_type( + Opentelemetry__Proto__Profiles__V1development__ValueType **output_instance, + struct cprof_value_type *input_instance, + struct profile_encoding_state *encoding_state); - return CPROF_ENCODE_OPENTELEMETRY_SUCCESS; -} +static int pack_cprof_sample( + Opentelemetry__Proto__Profiles__V1development__Sample **output_instance, + struct cprof_sample *input_instance, + struct profile_encoding_state *encoding_state, + size_t sample_index); static int pack_cprof_profile( Opentelemetry__Proto__Profiles__V1development__Profile **output_instance, - struct cprof_profile *input_instance) + struct cprof_profile *input_instance, + struct profile_encoding_state *encoding_state) { Opentelemetry__Proto__Profiles__V1development__Profile *otlp_profile; struct cfl_list *iterator; struct cprof_sample *sample; - struct cprof_link *link; - struct cprof_mapping *mapping; - struct cprof_location *location; - struct cprof_function *function; struct cprof_value_type *sample_type; - struct cprof_attribute_unit *attribute_unit; int result; size_t index; - otlp_profile = initialize_profile(cfl_list_size(&input_instance->sample_type), - cfl_list_size(&input_instance->samples), - cfl_list_size(&input_instance->mappings), - cfl_list_size(&input_instance->locations), - input_instance->location_indices_count, - cfl_list_size(&input_instance->functions), - 0, - cfl_list_size(&input_instance->attribute_units), - cfl_list_size(&input_instance->link_table), - input_instance->string_table_count, - input_instance->comments_count); + otlp_profile = initialize_profile(cfl_list_size(&input_instance->samples), 0); if (otlp_profile == NULL) { return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; } - index = 0; - cfl_list_foreach(iterator, - &input_instance->sample_type) { - sample_type = cfl_list_entry( - iterator, - struct cprof_value_type, _head); - - result = pack_cprof_value_type( - &otlp_profile->sample_type[index], - sample_type); - + /* New Profile has single sample_type; use first from list if any */ + if (!cfl_list_is_empty(&input_instance->sample_type)) { + sample_type = cfl_list_entry_first(&input_instance->sample_type, + struct cprof_value_type, _head); + result = pack_cprof_value_type(&otlp_profile->sample_type, sample_type, encoding_state); if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { destroy_profile(otlp_profile); - return result; } - - index++; } index = 0; - cfl_list_foreach(iterator, - &input_instance->samples) { - sample = cfl_list_entry( - iterator, - struct cprof_sample, _head); - - result = pack_cprof_sample( - &otlp_profile->sample[index], - sample); + cfl_list_foreach(iterator, &input_instance->samples) { + sample = cfl_list_entry(iterator, struct cprof_sample, _head); + result = pack_cprof_sample(&otlp_profile->samples[index], sample, encoding_state, index); if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { destroy_profile(otlp_profile); - return result; } - index++; } - index = 0; - cfl_list_foreach(iterator, - &input_instance->mappings) { - mapping = cfl_list_entry( - iterator, - struct cprof_mapping, _head); - - result = pack_cprof_mapping( - &otlp_profile->mapping[index], - mapping); - - if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { - destroy_profile(otlp_profile); - - return result; - } - - index++; - } - - index = 0; - cfl_list_foreach(iterator, - &input_instance->locations) { - location = cfl_list_entry( - iterator, - struct cprof_location, _head); - - result = pack_cprof_location( - &otlp_profile->location[index], - location); - - if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { - destroy_profile(otlp_profile); - - return result; - } - - index++; - } - - for (index = 0 ; - index < input_instance->location_indices_count ; - index++) { - otlp_profile->location_indices[index] = input_instance->location_indices[index]; - } - - index = 0; - cfl_list_foreach(iterator, - &input_instance->functions) { - function = cfl_list_entry( - iterator, - struct cprof_function, _head); - - result = pack_cprof_function( - &otlp_profile->function[index], - function); - - if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { - destroy_profile(otlp_profile); - - return result; - } - - index++; - } - - if (input_instance->attribute_table != NULL) { - otlp_profile->attribute_table = cfl_kvlist_to_otlp_kvpair_list(input_instance->attribute_table); - - if (otlp_profile->attribute_table == NULL) { - destroy_profile(otlp_profile); - - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_profile->n_attribute_table = cfl_kvlist_count(input_instance->attribute_table); - } - - index = 0; - cfl_list_foreach(iterator, - &input_instance->attribute_units) { - attribute_unit = cfl_list_entry( - iterator, - struct cprof_attribute_unit, _head); - - result = pack_cprof_attribute_unit( - &otlp_profile->attribute_units[index], - attribute_unit); - - if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { - destroy_profile(otlp_profile); - - return result; - } - - index++; - } - - index = 0; - cfl_list_foreach(iterator, - &input_instance->link_table) { - link = cfl_list_entry( - iterator, - struct cprof_link, _head); - - result = pack_cprof_link( - &otlp_profile->link_table[index], - link); - - if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { - destroy_profile(otlp_profile); - - return result; - } - - index++; - } - - for (index = 0 ; - index < input_instance->string_table_count ; - index++) { - otlp_profile->string_table[index] = cfl_sds_create(input_instance->string_table[index]); - - if (otlp_profile->string_table[index] == NULL) { - destroy_profile(otlp_profile); - - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - } - - otlp_profile->drop_frames = input_instance->drop_frames; - otlp_profile->keep_frames = input_instance->keep_frames; - otlp_profile->time_nanos = input_instance->time_nanos; - otlp_profile->duration_nanos = input_instance->duration_nanos; - - result = pack_cprof_value_type( - &otlp_profile->period_type, - &input_instance->period_type); + otlp_profile->time_unix_nano = input_instance->time_nanos; + otlp_profile->duration_nano = input_instance->duration_nanos; + result = pack_cprof_value_type(&otlp_profile->period_type, &input_instance->period_type, encoding_state); if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { destroy_profile(otlp_profile); - return result; } otlp_profile->period = input_instance->period; - for (index = 0 ; - index < input_instance->comments_count ; - index++) { - otlp_profile->comment[index] = input_instance->comments[index]; - } - - otlp_profile->default_sample_type = input_instance->default_sample_type; - - *output_instance = otlp_profile; - - return CPROF_ENCODE_OPENTELEMETRY_SUCCESS; -} - -static int pack_cprof_profile_container( - Opentelemetry__Proto__Profiles__V1development__ProfileContainer **output_instance, - struct cprof_profile *input_instance) -{ - Opentelemetry__Proto__Profiles__V1development__ProfileContainer *otlp_profile_container; - int result; - - otlp_profile_container = initialize_profile_container(0); - - if (otlp_profile_container == NULL) { - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_profile_container->profile_id.data = \ - (uint8_t *) cfl_sds_create_len((const char *) input_instance->profile_id, - sizeof(input_instance->profile_id)); - - if (otlp_profile_container->profile_id.data == NULL) { - destroy_profile_container(otlp_profile_container); - - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_profile_container->profile_id.len = sizeof(input_instance->profile_id); - - otlp_profile_container->start_time_unix_nano = (uint64_t) input_instance->start_time_unix_nano; - otlp_profile_container->end_time_unix_nano = (uint64_t) input_instance->end_time_unix_nano; - - otlp_profile_container->attributes = cfl_kvlist_to_otlp_kvpair_list(input_instance->attributes); - - if (otlp_profile_container->attributes == NULL) { - destroy_profile_container(otlp_profile_container); - - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_profile_container->n_attributes = cfl_kvlist_count(input_instance->attributes); - - otlp_profile_container->dropped_attributes_count = input_instance->dropped_attributes_count; - - if (input_instance->original_payload_format != NULL) { - otlp_profile_container->original_payload_format = \ - cfl_sds_create(input_instance->original_payload_format); - - if (otlp_profile_container->original_payload_format == NULL) { - destroy_profile_container(otlp_profile_container); - - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - } - - if (input_instance->original_payload != NULL) { - otlp_profile_container->original_payload.data = \ - (uint8_t *) cfl_sds_create_len(input_instance->original_payload, - cfl_sds_len(input_instance->original_payload)); - - if (otlp_profile_container->original_payload.data == NULL) { - destroy_profile_container(otlp_profile_container); - - return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; - } - - otlp_profile_container->original_payload.len = cfl_sds_len(input_instance->original_payload); - } - - result = pack_cprof_profile(&otlp_profile_container->profile, input_instance); - - if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { - destroy_profile_container(otlp_profile_container); - - return result; - } - - *output_instance = otlp_profile_container; + *output_instance = otlp_profile; return CPROF_ENCODE_OPENTELEMETRY_SUCCESS; } - static int pack_cprof_scope_profiles( Opentelemetry__Proto__Profiles__V1development__ScopeProfiles **output_instance, - struct cprof_scope_profiles *input_instance) + struct cprof_scope_profiles *input_instance, + encoder_internal_ctx_t *internal_ctx) { Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *otlp_scope_profiles; struct cfl_list *iterator; struct cprof_profile *profile; + struct profile_encoding_state *encoding_state; int result; size_t index; @@ -2199,9 +2273,13 @@ static int pack_cprof_scope_profiles( iterator, struct cprof_profile, _head); - result = pack_cprof_profile_container( + encoding_state = (internal_ctx->current_profile_index < internal_ctx->encoding_states_count) + ? &internal_ctx->encoding_states[internal_ctx->current_profile_index++] : NULL; + + result = pack_cprof_profile( &otlp_scope_profiles->profiles[index], - profile); + profile, + encoding_state); if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { destroy_scope_profiles(otlp_scope_profiles); @@ -2229,7 +2307,8 @@ static int pack_cprof_scope_profiles( static int pack_cprof_resource_profiles( Opentelemetry__Proto__Profiles__V1development__ResourceProfiles **output_instance, - struct cprof_resource_profiles *input_instance) + struct cprof_resource_profiles *input_instance, + encoder_internal_ctx_t *internal_ctx) { Opentelemetry__Proto__Profiles__V1development__ResourceProfiles *otlp_resource_profiles; struct cprof_scope_profiles *scope_profiles; @@ -2258,7 +2337,8 @@ static int pack_cprof_resource_profiles( result = pack_cprof_scope_profiles( &otlp_resource_profiles->scope_profiles[index], - scope_profiles); + scope_profiles, + internal_ctx); if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { destroy_resource_profiles(otlp_resource_profiles); @@ -2285,8 +2365,23 @@ static int pack_cprof_resource_profiles( } +static int pack_cprof_resource_profiles( + Opentelemetry__Proto__Profiles__V1development__ResourceProfiles **output_instance, + struct cprof_resource_profiles *input_instance, + encoder_internal_ctx_t *internal_ctx); + +static int pack_cprof_scope_profiles( + Opentelemetry__Proto__Profiles__V1development__ScopeProfiles **output_instance, + struct cprof_scope_profiles *input_instance, + encoder_internal_ctx_t *internal_ctx); + +static int pack_cprof_profile( + Opentelemetry__Proto__Profiles__V1development__Profile **output_instance, + struct cprof_profile *input_instance, + struct profile_encoding_state *encoding_state); + static int pack_context_profiles( - struct cprof_opentelemetry_encoding_context *context, + encoder_internal_ctx_t *internal_ctx, struct cprof *profile) { size_t index; @@ -2294,10 +2389,10 @@ static int pack_context_profiles( struct cfl_list *iterator; struct cprof_resource_profiles *resource_profiles; - context->export_service_request = \ + internal_ctx->pub->export_service_request = \ initialize_export_profiles_service_request(cfl_list_size(&profile->profiles)); - if (context->export_service_request == NULL) { + if (internal_ctx->pub->export_service_request == NULL) { return CPROF_ENCODE_OPENTELEMETRY_ALLOCATION_ERROR; } @@ -2309,11 +2404,12 @@ static int pack_context_profiles( struct cprof_resource_profiles, _head); result = pack_cprof_resource_profiles( - &context->export_service_request->resource_profiles[index], - resource_profiles); + &internal_ctx->pub->export_service_request->resource_profiles[index], + resource_profiles, + internal_ctx); if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { - destroy_export_profiles_service_request(context->export_service_request); + destroy_export_profiles_service_request(internal_ctx->pub->export_service_request); return result; } @@ -2328,11 +2424,49 @@ static int pack_context( struct cprof_opentelemetry_encoding_context *context, struct cprof *profile) { + encoder_internal_ctx_t internal_ctx; + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dict; + struct profile_encoding_state *states; + size_t state_count; + int result; + size_t i; + memset(context, 0, sizeof(struct cprof_opentelemetry_encoding_context)); context->inner_context = profile; - return pack_context_profiles(context, profile); + result = build_profiles_dictionary(profile, &dict, &states, &state_count); + if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { + return result; + } + + internal_ctx.pub = context; + internal_ctx.encoding_states = states; + internal_ctx.encoding_states_count = state_count; + internal_ctx.current_profile_index = 0; + + result = pack_context_profiles(&internal_ctx, profile); + if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { + for (i = 0; i < state_count; i++) { + free_profile_encoding_state(&states[i]); + } + free(states); + if (dict != NULL) { + destroy_profiles_dictionary(dict); + } + return result; + } + + if (internal_ctx.pub->export_service_request != NULL && dict != NULL) { + internal_ctx.pub->export_service_request->dictionary = dict; + } + + for (i = 0; i < state_count; i++) { + free_profile_encoding_state(&states[i]); + } + free(states); + + return CPROF_ENCODE_OPENTELEMETRY_SUCCESS; } static cfl_sds_t render_opentelemetry_context_to_sds( diff --git a/lib/cprofiles/src/cprof_encode_text.c b/lib/cprofiles/src/cprof_encode_text.c index 299af8aa2e2..08203a5dbb8 100644 --- a/lib/cprofiles/src/cprof_encode_text.c +++ b/lib/cprofiles/src/cprof_encode_text.c @@ -127,26 +127,32 @@ static int encode_aggregation_temporality( static int encode_cprof_value_type( struct cprof_text_encoding_context *context, + struct cprof_profile *profile, struct cprof_value_type *instance); static int encode_cprof_sample( struct cprof_text_encoding_context *context, + struct cprof_profile *profile, struct cprof_sample *instance); static int encode_cprof_mapping( struct cprof_text_encoding_context *context, + struct cprof_profile *profile, struct cprof_mapping *instance); static int encode_cprof_line( struct cprof_text_encoding_context *context, + struct cprof_profile *profile, struct cprof_line *instance); static int encode_cprof_location( struct cprof_text_encoding_context *context, + struct cprof_profile *profile, struct cprof_location *instance); static int encode_cprof_function( struct cprof_text_encoding_context *context, + struct cprof_profile *profile, struct cprof_function *instance); static int encode_cprof_attribute_unit( @@ -318,6 +324,48 @@ static int encode_string( return CPROF_ENCODE_TEXT_SUCCESS; } +/* Section header with count for debugging (e.g. "Samples (3) :") */ +static int encode_section_header_with_count( + struct cprof_text_encoding_context *context, + const char *label, + size_t count) +{ + cfl_sds_t result; + + result = cfl_sds_printf(&context->output_buffer, + "%s%s (%zu) :\n", + context->indentation_buffer, + label, + count); + + if (result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + + return CPROF_ENCODE_TEXT_SUCCESS; +} + +/* Item subheader with index for debugging (e.g. "Sample #0 :") */ +static int encode_item_header( + struct cprof_text_encoding_context *context, + const char *label, + size_t index) +{ + cfl_sds_t result; + + result = cfl_sds_printf(&context->output_buffer, + "%s%s #%zu :\n", + context->indentation_buffer, + label, + index); + + if (result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + + return CPROF_ENCODE_TEXT_SUCCESS; +} + static int encode_double( struct cprof_text_encoding_context *context, int indent, @@ -411,6 +459,236 @@ static int encode_int64_t( return CPROF_ENCODE_TEXT_SUCCESS; } +/* Resolve string_table index; returns pointer to string or NULL if invalid. */ +static const char *resolve_string_index(struct cprof_profile *profile, int64_t index) +{ + if (profile == NULL || profile->string_table == NULL) { + return NULL; + } + if (index < 0 || (size_t)index >= profile->string_table_count) { + return NULL; + } + if (profile->string_table[index] == NULL) { + return ""; + } + return profile->string_table[index]; +} + +static struct cprof_mapping *resolve_mapping_index(struct cprof_profile *profile, uint64_t index) +{ + struct cfl_list *iterator; + struct cprof_mapping *mapping; + uint64_t current_index; + + if (profile == NULL) { + return NULL; + } + + current_index = 0; + + cfl_list_foreach(iterator, &profile->mappings) { + mapping = cfl_list_entry(iterator, struct cprof_mapping, _head); + + if (current_index == index) { + return mapping; + } + + current_index++; + } + + return NULL; +} + +static struct cprof_location *resolve_location_index(struct cprof_profile *profile, uint64_t index) +{ + struct cfl_list *iterator; + struct cprof_location *location; + uint64_t current_index; + + if (profile == NULL) { + return NULL; + } + + current_index = 0; + + cfl_list_foreach(iterator, &profile->locations) { + location = cfl_list_entry(iterator, struct cprof_location, _head); + + if (current_index == index) { + return location; + } + + current_index++; + } + + return NULL; +} + +static struct cprof_function *resolve_function_index(struct cprof_profile *profile, uint64_t index) +{ + struct cfl_list *iterator; + struct cprof_function *function; + uint64_t current_index; + + if (profile == NULL) { + return NULL; + } + + current_index = 0; + + cfl_list_foreach(iterator, &profile->functions) { + function = cfl_list_entry(iterator, struct cprof_function, _head); + + if (current_index == index) { + return function; + } + + current_index++; + } + + return NULL; +} + +static struct cfl_kvpair *resolve_attribute_index(struct cprof_profile *profile, uint64_t index) +{ + struct cfl_list *iterator; + struct cfl_kvpair *entry; + uint64_t current_index; + + if (profile == NULL || profile->attribute_table == NULL) { + return NULL; + } + + current_index = 0; + + cfl_list_foreach(iterator, &profile->attribute_table->list) { + entry = cfl_list_entry(iterator, struct cfl_kvpair, _head); + + if (current_index == index) { + return entry; + } + + current_index++; + } + + return NULL; +} + +/* Append string to buffer with double-quotes escaped as \". */ +static int append_escaped_string(cfl_sds_t *buf, const char *str) +{ + cfl_sds_t result; + const char *p; + + if (str == NULL) { + return CPROF_ENCODE_TEXT_SUCCESS; + } + for (p = str; *p != '\0'; p++) { + if (*p == '"') { + result = cfl_sds_cat(*buf, "\\\"", 2); + } + else { + result = cfl_sds_printf(buf, "%c", *p); + } + if (result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + if (*p == '"') { + *buf = result; + } + } + return CPROF_ENCODE_TEXT_SUCCESS; +} + +/* Encode int64 (string_table index) with optional resolution for debugging. */ +static int encode_int64_string_ref( + struct cprof_text_encoding_context *context, + int indent, + const char *label, + int64_t value, + struct cprof_profile *profile) +{ + const char *resolved; + char *local_indentation; + cfl_sds_t result; + int append_result; + + if (indent) { + local_indentation = (char *) context->indentation_buffer; + } + else { + local_indentation = (char *) ""; + } + + resolved = resolve_string_index(profile, value); + + if (context->render_mode == CPROF_ENCODE_TEXT_RENDER_RESOLVED && + resolved != NULL) { + result = cfl_sds_printf(&context->output_buffer, + "%s%s\"", + local_indentation, + label); + + if (result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + + context->output_buffer = result; + + append_result = append_escaped_string(&context->output_buffer, resolved); + if (append_result != CPROF_ENCODE_TEXT_SUCCESS) { + return append_result; + } + + result = cfl_sds_cat(context->output_buffer, "\"\n", 2); + if (result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + + context->output_buffer = result; + + return CPROF_ENCODE_TEXT_SUCCESS; + } + + result = cfl_sds_printf(&context->output_buffer, + "%s%s%" PRId64, + local_indentation, + label, + value); + + if (result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + + if (resolved != NULL) { + result = cfl_sds_cat(context->output_buffer, + " → \"", + strlen(" → \"")); + if (result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + context->output_buffer = result; + append_result = append_escaped_string(&context->output_buffer, resolved); + if (append_result != CPROF_ENCODE_TEXT_SUCCESS) { + return append_result; + } + result = cfl_sds_cat(context->output_buffer, "\"\n", 2); + if (result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + context->output_buffer = result; + } + else { + result = cfl_sds_cat(context->output_buffer, "\n", 1); + if (result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + context->output_buffer = result; + } + + return CPROF_ENCODE_TEXT_SUCCESS; +} + static int encode_bool( struct cprof_text_encoding_context *context, int indent, @@ -561,12 +839,212 @@ static int encode_uint64_t_array( if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; } - } + } + + sds_result = cfl_sds_printf(&context->output_buffer, + "%s", + suffix); + + if (sds_result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + + return CPROF_ENCODE_TEXT_SUCCESS; +} + +static int encode_attribute_index_array( + struct cprof_text_encoding_context *context, + int indent, + char *prefix, + char *separator, + char *suffix, + struct cprof_profile *profile, + uint64_t *data_list, + size_t data_length) +{ + char *local_indentation; + cfl_sds_t sds_result; + int result; + size_t index; + struct cfl_kvpair *attribute; + int placeholder_attribute; + + if (context->render_mode != CPROF_ENCODE_TEXT_RENDER_RESOLVED) { + return encode_uint64_t_array(context, indent, prefix, separator, suffix, + data_list, data_length); + } + + if (indent) { + local_indentation = (char *) context->indentation_buffer; + } + else { + local_indentation = (char *) ""; + } + + sds_result = cfl_sds_printf(&context->output_buffer, + "%s" "%s", + local_indentation, + prefix); + + if (sds_result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + + for (index = 0; index < data_length; index++) { + attribute = resolve_attribute_index(profile, data_list[index]); + placeholder_attribute = CFL_FALSE; + + if (attribute != NULL && + attribute->key != NULL && + attribute->key[0] == '\0' && + attribute->val != NULL && + attribute->val->type == CFL_VARIANT_STRING && + attribute->val->data.as_string != NULL && + cfl_sds_len(attribute->val->data.as_string) == 0) { + placeholder_attribute = CFL_TRUE; + } + + if (attribute == NULL || attribute->val == NULL || placeholder_attribute) { + result = encode_uint64_t(context, + CFL_FALSE, + "", + data_list[index]); + } + else { + result = encode_string(context, + CFL_FALSE, + "\"", + "\": ", + attribute->key); + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = encode_cfl_variant(context, + CFL_FALSE, + "", + "", + attribute->val); + } + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + if (index + 1 < data_length) { + result = encode_string(context, + CFL_FALSE, + "", + "", + separator); + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + } + } + + sds_result = cfl_sds_printf(&context->output_buffer, "%s", suffix); + if (sds_result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + + return CPROF_ENCODE_TEXT_SUCCESS; +} + +static int encode_location_reference_array( + struct cprof_text_encoding_context *context, + int indent, + char *prefix, + char *separator, + char *suffix, + struct cprof_profile *profile, + uint64_t *data_list, + size_t data_length) +{ + char *local_indentation; + cfl_sds_t sds_result; + int result; + size_t index; + struct cprof_location *location; + struct cprof_line *line; + struct cprof_function *function; + const char *resolved; + + if (context->render_mode != CPROF_ENCODE_TEXT_RENDER_RESOLVED) { + return encode_uint64_t_array(context, indent, prefix, separator, suffix, + data_list, data_length); + } + + if (indent) { + local_indentation = (char *) context->indentation_buffer; + } + else { + local_indentation = (char *) ""; + } + + sds_result = cfl_sds_printf(&context->output_buffer, + "%s" "%s", + local_indentation, + prefix); + if (sds_result == NULL) { + return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + } + + for (index = 0; index < data_length; index++) { + location = resolve_location_index(profile, data_list[index]); + + if (location == NULL || cfl_list_is_empty(&location->lines)) { + result = encode_uint64_t(context, + CFL_FALSE, + "", + "", + data_list[index]); + } + else { + line = cfl_list_entry_first(&location->lines, struct cprof_line, _head); + function = resolve_function_index(profile, line->function_index); + + if (function != NULL) { + resolved = resolve_string_index(profile, function->name); + } + else { + resolved = NULL; + } + + if (resolved == NULL) { + result = encode_uint64_t(context, + CFL_FALSE, + "", + "", + data_list[index]); + } + else { + result = encode_string(context, + CFL_FALSE, + "\"", + "\"", + (char *) resolved); + } + } + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } - sds_result = cfl_sds_printf(&context->output_buffer, - "%s", - suffix); + if (index + 1 < data_length) { + result = encode_string(context, + CFL_FALSE, + "", + "", + separator); + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + } + } + sds_result = cfl_sds_printf(&context->output_buffer, "%s", suffix); if (sds_result == NULL) { return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; } @@ -709,6 +1187,8 @@ static int encode_cfl_kvlist( struct cfl_kvpair *last_entry; cfl_sds_t sds_result; struct cfl_list *iterator; + char *value_prefix; + char *value_suffix; int result; struct cfl_kvpair *entry; @@ -747,10 +1227,20 @@ static int encode_cfl_kvlist( return result; } + value_prefix = ""; + value_suffix = ""; + + if (entry->val != NULL && + (entry->val->type == CFL_VARIANT_STRING || + entry->val->type == CFL_VARIANT_BYTES)) { + value_prefix = "\""; + value_suffix = "\""; + } + result = encode_cfl_variant(context, CFL_FALSE, - "\"", - "\"", + value_prefix, + value_suffix, entry->val); if (result != CPROF_ENCODE_TEXT_SUCCESS) { @@ -932,25 +1422,29 @@ static int encode_aggregation_temporality( static int encode_cprof_value_type( struct cprof_text_encoding_context *context, - struct cprof_value_type *instance) { - cfl_sds_t result; + struct cprof_profile *profile, + struct cprof_value_type *instance) +{ + int result; - result = cfl_sds_printf(&context->output_buffer, - "%s" "Type : %" PRId64 "\n", - context->indentation_buffer, - instance->type); + result = encode_int64_string_ref(context, + CFL_TRUE, + "Type : ", + instance->type, + profile); - if (result == NULL) { - return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; } - result = cfl_sds_printf(&context->output_buffer, - "%s" "Unit : %" PRId64 "\n", - context->indentation_buffer, - instance->unit); + result = encode_int64_string_ref(context, + CFL_TRUE, + "Unit : ", + instance->unit, + profile); - if (result == NULL) { - return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; } return encode_aggregation_temporality( @@ -962,16 +1456,18 @@ static int encode_cprof_value_type( static int encode_cprof_sample( struct cprof_text_encoding_context *context, + struct cprof_profile *profile, struct cprof_sample *instance) { int result; - result = encode_uint64_t_array(context, - CFL_TRUE, - "Location index : [ ", - ", ", - "]\n", - instance->location_index, - instance->location_index_count); + result = encode_location_reference_array(context, + CFL_TRUE, + "Location index : [ ", + ", ", + "]\n", + profile, + instance->location_index, + instance->location_index_count); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1009,13 +1505,14 @@ static int encode_cprof_sample( return result; } - result = encode_uint64_t_array(context, - CFL_TRUE, - "Attributes : [ ", - ", ", - "]\n", - instance->attributes, - instance->attributes_count); + result = encode_attribute_index_array(context, + CFL_TRUE, + "Attributes : [ ", + ", ", + "]\n", + profile, + instance->attributes, + instance->attributes_count); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1023,7 +1520,7 @@ static int encode_cprof_sample( result = encode_uint64_t(context, CFL_TRUE, - "Link : ", + "Link (link_table index) : ", "\n", instance->link); @@ -1056,7 +1553,9 @@ static int encode_cprof_sample( static int encode_cprof_mapping( struct cprof_text_encoding_context *context, - struct cprof_mapping *instance) { + struct cprof_profile *profile, + struct cprof_mapping *instance) +{ int result; result = encode_uint64_t(context, @@ -1100,23 +1599,24 @@ static int encode_cprof_mapping( } - result = encode_int64_t(context, - CFL_TRUE, - "Filename : ", - "\n", - instance->filename); + result = encode_int64_string_ref(context, + CFL_TRUE, + "Filename : ", + instance->filename, + profile); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; } - result = encode_uint64_t_array(context, - CFL_TRUE, - "Attributes : [ ", - ", ", - "]\n", - instance->attributes, - instance->attributes_count); + result = encode_attribute_index_array(context, + CFL_TRUE, + "Attributes : [ ", + ", ", + "]\n", + profile, + instance->attributes, + instance->attributes_count); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1171,14 +1671,45 @@ static int encode_cprof_mapping( static int encode_cprof_line( struct cprof_text_encoding_context *context, - struct cprof_line *instance) { + struct cprof_profile *profile, + struct cprof_line *instance) +{ + struct cprof_function *function; + const char *resolved; int result; - result = encode_uint64_t(context, - CFL_TRUE, - "Function index : ", - "\n", - instance->function_index); + if (context->render_mode == CPROF_ENCODE_TEXT_RENDER_RESOLVED) { + function = resolve_function_index(profile, instance->function_index); + + if (function != NULL) { + resolved = resolve_string_index(profile, function->name); + } + else { + resolved = NULL; + } + + if (resolved != NULL) { + result = encode_string(context, + CFL_TRUE, + "Function : ", + "\n", + (char *) resolved); + } + else { + result = encode_uint64_t(context, + CFL_TRUE, + "Function index : ", + "\n", + instance->function_index); + } + } + else { + result = encode_uint64_t(context, + CFL_TRUE, + "Function index : ", + "\n", + instance->function_index); + } if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1211,8 +1742,12 @@ static int encode_cprof_line( static int encode_cprof_location( struct cprof_text_encoding_context *context, - struct cprof_location *instance) { + struct cprof_profile *profile, + struct cprof_location *instance) +{ struct cfl_list *iterator; + struct cprof_mapping *mapping; + const char *resolved; int result; struct cprof_line *line; @@ -1226,11 +1761,38 @@ static int encode_cprof_location( return result; } - result = encode_uint64_t(context, - CFL_TRUE, - "Mapping index : ", - "\n", - instance->mapping_index); + if (context->render_mode == CPROF_ENCODE_TEXT_RENDER_RESOLVED) { + mapping = resolve_mapping_index(profile, instance->mapping_index); + + if (mapping != NULL) { + resolved = resolve_string_index(profile, mapping->filename); + } + else { + resolved = NULL; + } + + if (resolved != NULL) { + result = encode_string(context, + CFL_TRUE, + "Mapping : ", + "\n", + (char *) resolved); + } + else { + result = encode_uint64_t(context, + CFL_TRUE, + "Mapping index : ", + "\n", + instance->mapping_index); + } + } + else { + result = encode_uint64_t(context, + CFL_TRUE, + "Mapping index : ", + "\n", + instance->mapping_index); + } if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1268,7 +1830,7 @@ static int encode_cprof_location( line = cfl_list_entry(iterator, struct cprof_line, _head); - result = encode_cprof_line(context, line); + result = encode_cprof_line(context, profile, line); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1282,13 +1844,14 @@ static int encode_cprof_location( } } - result = encode_uint64_t_array(context, - CFL_TRUE, - "Attributes : [ ", - ", ", - "]\n", - instance->attributes, - instance->attributes_count); + result = encode_attribute_index_array(context, + CFL_TRUE, + "Attributes : [ ", + ", ", + "]\n", + profile, + instance->attributes, + instance->attributes_count); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1302,7 +1865,9 @@ static int encode_cprof_location( static int encode_cprof_function( struct cprof_text_encoding_context *context, - struct cprof_function *instance) { + struct cprof_profile *profile, + struct cprof_function *instance) +{ int result; result = encode_uint64_t(context, @@ -1315,31 +1880,31 @@ static int encode_cprof_function( return result; } - result = encode_int64_t(context, - CFL_TRUE, - "Name : ", - "\n", - instance->name); + result = encode_int64_string_ref(context, + CFL_TRUE, + "Name : ", + instance->name, + profile); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; } - result = encode_int64_t(context, - CFL_TRUE, - "System name : ", - "\n", - instance->system_name); + result = encode_int64_string_ref(context, + CFL_TRUE, + "System name : ", + instance->system_name, + profile); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; } - result = encode_int64_t(context, - CFL_TRUE, - "Filename : ", - "\n", - instance->filename); + result = encode_int64_string_ref(context, + CFL_TRUE, + "Filename : ", + instance->filename, + profile); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1490,11 +2055,9 @@ static int encode_cprof_profile( } if (!cfl_list_is_empty(&instance->sample_type)) { - result = encode_string(context, - CFL_TRUE, - "", - "\n", - "Sample types :"); + result = encode_section_header_with_count(context, + "Sample types", + cfl_list_size(&instance->sample_type)); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1512,7 +2075,7 @@ static int encode_cprof_profile( iterator, struct cprof_value_type, _head); - result = encode_cprof_value_type(context, sample_type); + result = encode_cprof_value_type(context, instance, sample_type); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1527,11 +2090,9 @@ static int encode_cprof_profile( } if (!cfl_list_is_empty(&instance->samples)) { - result = encode_string(context, - CFL_TRUE, - "", - "\n", - "Samples :"); + result = encode_section_header_with_count(context, + "Samples", + cfl_list_size(&instance->samples)); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1543,16 +2104,39 @@ static int encode_cprof_profile( return result; } - cfl_list_foreach(iterator, - &instance->samples) { - sample = cfl_list_entry( - iterator, - struct cprof_sample, _head); + { + size_t sample_index = 0; + cfl_list_foreach(iterator, + &instance->samples) { + sample = cfl_list_entry( + iterator, + struct cprof_sample, _head); - result = encode_cprof_sample(context, sample); + result = encode_item_header(context, "Sample", sample_index); - if (result != CPROF_ENCODE_TEXT_SUCCESS) { - return result; + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = increment_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = encode_cprof_sample(context, instance, sample); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = decrement_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + sample_index++; } } @@ -1564,11 +2148,9 @@ static int encode_cprof_profile( } if (!cfl_list_is_empty(&instance->mappings)) { - result = encode_string(context, - CFL_TRUE, - "", - "\n", - "Mappings :"); + result = encode_section_header_with_count(context, + "Mappings", + cfl_list_size(&instance->mappings)); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1580,16 +2162,39 @@ static int encode_cprof_profile( return result; } - cfl_list_foreach(iterator, - &instance->mappings) { - mapping = cfl_list_entry( - iterator, - struct cprof_mapping, _head); + { + size_t mapping_index = 0; + cfl_list_foreach(iterator, + &instance->mappings) { + mapping = cfl_list_entry( + iterator, + struct cprof_mapping, _head); - result = encode_cprof_mapping(context, mapping); + result = encode_item_header(context, "Mapping", mapping_index); - if (result != CPROF_ENCODE_TEXT_SUCCESS) { - return result; + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = increment_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = encode_cprof_mapping(context, instance, mapping); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = decrement_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + mapping_index++; } } @@ -1601,11 +2206,9 @@ static int encode_cprof_profile( } if (!cfl_list_is_empty(&instance->locations)) { - result = encode_string(context, - CFL_TRUE, - "", - "\n", - "Locations :"); + result = encode_section_header_with_count(context, + "Locations", + cfl_list_size(&instance->locations)); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1617,16 +2220,39 @@ static int encode_cprof_profile( return result; } - cfl_list_foreach(iterator, - &instance->locations) { - location = cfl_list_entry( - iterator, - struct cprof_location, _head); + { + size_t location_index = 0; + cfl_list_foreach(iterator, + &instance->locations) { + location = cfl_list_entry( + iterator, + struct cprof_location, _head); - result = encode_cprof_location(context, location); + result = encode_item_header(context, "Location", location_index); - if (result != CPROF_ENCODE_TEXT_SUCCESS) { - return result; + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = increment_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = encode_cprof_location(context, instance, location); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = decrement_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + location_index++; } } @@ -1637,24 +2263,24 @@ static int encode_cprof_profile( } } - result = encode_int64_t_array(context, - CFL_TRUE, - "Location indices : [ ", - ", ", - "]\n", - instance->location_indices, - instance->location_indices_count); + if (context->render_mode == CPROF_ENCODE_TEXT_RENDER_DICTIONARIES_AND_INDEXES) { + result = encode_int64_t_array(context, + CFL_TRUE, + "Location indices : [ ", + ", ", + "]\n", + instance->location_indices, + instance->location_indices_count); - if (result != CPROF_ENCODE_TEXT_SUCCESS) { - return result; + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } } if (!cfl_list_is_empty(&instance->functions)) { - result = encode_string(context, - CFL_TRUE, - "", - "\n", - "Functions :"); + result = encode_section_header_with_count(context, + "Functions", + cfl_list_size(&instance->functions)); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1666,16 +2292,39 @@ static int encode_cprof_profile( return result; } - cfl_list_foreach(iterator, - &instance->functions) { - function = cfl_list_entry( - iterator, - struct cprof_function, _head); + { + size_t function_index = 0; + cfl_list_foreach(iterator, + &instance->functions) { + function = cfl_list_entry( + iterator, + struct cprof_function, _head); - result = encode_cprof_function(context, function); + result = encode_item_header(context, "Function", function_index); - if (result != CPROF_ENCODE_TEXT_SUCCESS) { - return result; + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = increment_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = encode_cprof_function(context, instance, function); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = decrement_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + function_index++; } } @@ -1686,23 +2335,58 @@ static int encode_cprof_profile( } } - result = encode_cfl_kvlist(context, - CFL_TRUE, - "Attribute table : {", - ", ", - " }\n", - instance->attribute_table); + if (context->render_mode == CPROF_ENCODE_TEXT_RENDER_DICTIONARIES_AND_INDEXES) { + result = encode_cfl_kvlist(context, + CFL_TRUE, + "Attribute table : {", + ", ", + " }\n", + instance->attribute_table); - if (result != CPROF_ENCODE_TEXT_SUCCESS) { - return result; + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + if (!cfl_list_is_empty(&instance->attribute_units)) { + result = encode_section_header_with_count(context, + "Attribute units", + cfl_list_size(&instance->attribute_units)); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = increment_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + cfl_list_foreach(iterator, + &instance->attribute_units) { + attribute_unit = cfl_list_entry( + iterator, + struct cprof_attribute_unit, _head); + + result = encode_cprof_attribute_unit(context, attribute_unit); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + } + + result = decrement_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + } } - if (!cfl_list_is_empty(&instance->functions)) { - result = encode_string(context, - CFL_TRUE, - "", - "\n", - "Attribute units :"); + if (!cfl_list_is_empty(&instance->link_table)) { + result = encode_section_header_with_count(context, + "Links", + cfl_list_size(&instance->link_table)); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1714,16 +2398,39 @@ static int encode_cprof_profile( return result; } - cfl_list_foreach(iterator, - &instance->attribute_units) { - attribute_unit = cfl_list_entry( - iterator, - struct cprof_attribute_unit, _head); + { + size_t link_index = 0; + cfl_list_foreach(iterator, + &instance->link_table) { + link = cfl_list_entry( + iterator, + struct cprof_link, _head); - result = encode_cprof_attribute_unit(context, attribute_unit); + result = encode_item_header(context, "Link", link_index); - if (result != CPROF_ENCODE_TEXT_SUCCESS) { - return result; + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = increment_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = encode_cprof_link(context, link); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + result = decrement_indentation_level(context); + + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } + + link_index++; } } @@ -1734,12 +2441,10 @@ static int encode_cprof_profile( } } - if (!cfl_list_is_empty(&instance->link_table)) { - result = encode_string(context, - CFL_TRUE, - "", - "\n", - "Links :"); + if (context->render_mode == CPROF_ENCODE_TEXT_RENDER_DICTIONARIES_AND_INDEXES) { + result = encode_section_header_with_count(context, + "String table", + instance->string_table_count); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -1751,17 +2456,17 @@ static int encode_cprof_profile( return result; } - cfl_list_foreach(iterator, - &instance->link_table) { - link = cfl_list_entry( - iterator, - struct cprof_link, _head); - - result = encode_cprof_link(context, link); + result = encode_string_array( + context, + CFL_TRUE, + "[ ", + ", ", + " ]\n", + (char **) instance->string_table, + instance->string_table_count); - if (result != CPROF_ENCODE_TEXT_SUCCESS) { - return result; - } + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; } result = decrement_indentation_level(context); @@ -1769,19 +2474,10 @@ static int encode_cprof_profile( if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; } - } - - result = encode_string_array( - context, - CFL_TRUE, - "String table : [", - ", ", - " ]\n", - (char **) instance->string_table, - instance->string_table_count); - if (result != CPROF_ENCODE_TEXT_SUCCESS) { - return result; + if (result != CPROF_ENCODE_TEXT_SUCCESS) { + return result; + } } result = encode_int64_t(context, @@ -1840,7 +2536,7 @@ static int encode_cprof_profile( return result; } - result = encode_cprof_value_type(context, &instance->period_type); + result = encode_cprof_value_type(context, instance, &instance->period_type); if (result != CPROF_ENCODE_TEXT_SUCCESS) { return result; @@ -2193,7 +2889,8 @@ void print_profile(struct cprof_profile *profile) tmp = profile->string_table[location_idx]; if (tmp[0] == '\0') { printf(" [Empty String: No Function Name]\n"); - } else { + } + else { printf(" Function: %s\n", tmp); } } @@ -2216,7 +2913,8 @@ void print_profile(struct cprof_profile *profile) for (i = 0; i < sample->timestamps_count; ++i) { printf(" Timestamp %d: %" PRIu64 " ns\n", i, sample->timestamps_unix_nano[i]); } - } else { + } + else { printf(" [No Timestamps]\n"); } @@ -2233,7 +2931,8 @@ void print_profile(struct cprof_profile *profile) int cprof_encode_text_create(cfl_sds_t *result_buffer, - struct cprof *profile) + struct cprof *profile, + int render_mode) { int result; struct cprof_text_encoding_context context; @@ -2242,6 +2941,11 @@ int cprof_encode_text_create(cfl_sds_t *result_buffer, memset(&context, 0, sizeof(context)); + if (render_mode != CPROF_ENCODE_TEXT_RENDER_DICTIONARIES_AND_INDEXES && + render_mode != CPROF_ENCODE_TEXT_RENDER_RESOLVED) { + return CPROF_ENCODE_TEXT_INVALID_ARGUMENT_ERROR; + } + context.output_buffer = cfl_sds_create_size(128); if (context.output_buffer == NULL) { @@ -2250,7 +2954,7 @@ int cprof_encode_text_create(cfl_sds_t *result_buffer, context.indentation_buffer = cfl_sds_create_size(256); - if (context.output_buffer == NULL) { + if (context.indentation_buffer == NULL) { cfl_sds_destroy(context.output_buffer); return CPROF_ENCODE_TEXT_ALLOCATION_ERROR; @@ -2262,6 +2966,7 @@ int cprof_encode_text_create(cfl_sds_t *result_buffer, context.indentation_level_size = 4; context.indentation_character = ' '; + context.render_mode = render_mode; if (!cfl_list_is_empty(&profile->profiles)) { diff --git a/lib/cprofiles/src/cprof_opentelemetry_variant_helpers.c b/lib/cprofiles/src/cprof_opentelemetry_variant_helpers.c index d1b3070cf46..27f399054da 100644 --- a/lib/cprofiles/src/cprof_opentelemetry_variant_helpers.c +++ b/lib/cprofiles/src/cprof_opentelemetry_variant_helpers.c @@ -15,6 +15,12 @@ static int convert_kvarray_to_kvlist(struct cfl_kvlist *target, Opentelemetry__Proto__Common__V1__KeyValue **source, size_t source_length); +static int convert_keyvalueandunit_array_to_kvlist(struct cfl_kvlist *target, + Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit **source, + size_t source_length, + char **string_table, + size_t string_table_len); + static struct cfl_variant *clone_variant(Opentelemetry__Proto__Common__V1__AnyValue *source) { @@ -24,10 +30,10 @@ static struct cfl_variant *clone_variant(Opentelemetry__Proto__Common__V1__AnyVa int result; if (source == NULL) { - return NULL; + return cfl_variant_create_from_string(""); } if (source->value_case == OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE_STRING_VALUE) { - result_instance = cfl_variant_create_from_string(source->string_value); + result_instance = cfl_variant_create_from_string(source->string_value != NULL ? source->string_value : ""); } else if (source->value_case == OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE_BOOL_VALUE) { result_instance = cfl_variant_create_from_bool(source->bool_value); @@ -39,6 +45,10 @@ static struct cfl_variant *clone_variant(Opentelemetry__Proto__Common__V1__AnyVa result_instance = cfl_variant_create_from_double(source->double_value); } else if (source->value_case == OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE_KVLIST_VALUE) { + if (source->kvlist_value == NULL) { + return cfl_variant_create_from_string(""); + } + new_child_kvlist = cfl_kvlist_create(); if (new_child_kvlist == NULL) { return NULL; @@ -60,6 +70,10 @@ static struct cfl_variant *clone_variant(Opentelemetry__Proto__Common__V1__AnyVa } } else if (source->value_case == OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE_ARRAY_VALUE) { + if (source->array_value == NULL) { + return cfl_variant_create_from_string(""); + } + new_child_array = cfl_array_create(source->array_value->n_values); if (new_child_array == NULL) { @@ -84,6 +98,9 @@ static struct cfl_variant *clone_variant(Opentelemetry__Proto__Common__V1__AnyVa result_instance = cfl_variant_create_from_bytes((char *) source->bytes_value.data, source->bytes_value.len, CFL_FALSE); } + else { + result_instance = cfl_variant_create_from_string(""); + } return result_instance; } @@ -141,7 +158,7 @@ static int clone_kvlist(struct cfl_kvlist *target, result = clone_kvlist_entry(target, source->values[index]); } - return 0; + return result; } static int convert_kvarray_to_kvlist(struct cfl_kvlist *target, @@ -168,6 +185,13 @@ static int clone_kvlist_entry(struct cfl_kvlist *target, { struct cfl_variant *new_child_instance; int result; + char *key; + + if (source == NULL) { + return CPROF_DECODE_OPENTELEMETRY_SUCCESS; + } + + key = source->key != NULL ? source->key : ""; new_child_instance = clone_variant(source->value); @@ -175,7 +199,7 @@ static int clone_kvlist_entry(struct cfl_kvlist *target, return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; } - result = cfl_kvlist_insert(target, source->key, new_child_instance); + result = cfl_kvlist_insert(target, key, new_child_instance); if (result) { cfl_variant_destroy(new_child_instance); @@ -185,3 +209,51 @@ static int clone_kvlist_entry(struct cfl_kvlist *target, return CPROF_DECODE_OPENTELEMETRY_SUCCESS; } + +static int convert_keyvalueandunit_array_to_kvlist(struct cfl_kvlist *target, + Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit **source, + size_t source_length, + char **string_table, + size_t string_table_len) +{ + size_t index; + const char *key; + struct cfl_variant *val; + Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *entry; + + for (index = 0; index < source_length; index++) { + entry = source[index]; + + key = ""; + if (entry != NULL && + string_table != NULL && entry->key_strindex >= 0 && + (size_t)entry->key_strindex < string_table_len && + string_table[entry->key_strindex] != NULL) { + key = string_table[entry->key_strindex]; + } + + /* + * Preserve positional alignment with OTLP attribute table indexes. + * Even null/sentinel source entries get a placeholder null value, + * so downstream index-based resolution remains stable. + */ + if (entry == NULL || entry->value == NULL || + entry->value->value_case == OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE__NOT_SET) { + val = cfl_variant_create_from_string(""); + } + else { + val = clone_variant(entry->value); + } + + if (val == NULL) { + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + + if (cfl_kvlist_insert(target, (char *)key, val) != 0) { + cfl_variant_destroy(val); + return CPROF_DECODE_OPENTELEMETRY_ALLOCATION_ERROR; + } + } + + return CPROF_DECODE_OPENTELEMETRY_SUCCESS; +} diff --git a/lib/cprofiles/src/cprof_profile.c b/lib/cprofiles/src/cprof_profile.c index 2c833a4661a..608aedd7117 100644 --- a/lib/cprofiles/src/cprof_profile.c +++ b/lib/cprofiles/src/cprof_profile.c @@ -230,6 +230,7 @@ size_t cprof_profile_string_add(struct cprof_profile *profile, char *str, int st int alloc_size = 64; size_t id; size_t new_size; + cfl_sds_t *new_table; if (!str) { return -1; @@ -257,11 +258,12 @@ size_t cprof_profile_string_add(struct cprof_profile *profile, char *str, int st /* check there is enough room for a new entry */ if (profile->string_table_count >= profile->string_table_size) { new_size = profile->string_table_size + alloc_size; - profile->string_table = realloc(profile->string_table, new_size * sizeof(cfl_sds_t)); - if (!profile->string_table) { + new_table = realloc(profile->string_table, new_size * sizeof(cfl_sds_t)); + if (!new_table) { return -1; } - profile->string_table_size = alloc_size; + profile->string_table = new_table; + profile->string_table_size = new_size; } id = profile->string_table_count; @@ -307,4 +309,4 @@ int cprof_profile_add_comment(struct cprof_profile *profile, int64_t comment) profile->comments_count++; return 0; -} \ No newline at end of file +} diff --git a/lib/cprofiles/src/cprof_sample.c b/lib/cprofiles/src/cprof_sample.c index fb54df58a36..e066ca4671b 100644 --- a/lib/cprofiles/src/cprof_sample.c +++ b/lib/cprofiles/src/cprof_sample.c @@ -40,18 +40,13 @@ int cprof_sample_add_location_index(struct cprof_sample *sample, uint64_t locati uint64_t *reallocated_location_index; if (sample->location_index == NULL) { - /* - * if location index is NULL, assign a default location. We set an empty string to index 0 - * since that's the way for protobuf differentiate between unset or NULL - */ sample->location_index = calloc(1, alloc_slots * sizeof(uint64_t)); if (sample->location_index == NULL) { return -1; } - sample->location_index[0] = 0; /* an empty string */ - sample->location_index_count = 1; + sample->location_index_count = 0; sample->location_index_size = alloc_slots; } diff --git a/lib/cprofiles/tests/CMakeLists.txt b/lib/cprofiles/tests/CMakeLists.txt index 0da202814b1..d59f79e65c9 100644 --- a/lib/cprofiles/tests/CMakeLists.txt +++ b/lib/cprofiles/tests/CMakeLists.txt @@ -2,7 +2,7 @@ set(UNIT_TESTS_FILES profile.c msgpack_transcoder.c opentelemetry_transcoder.c - text_transcoder.c + text_encoder.c ) set(CPROF_TESTS_DATA_PATH "${CMAKE_CURRENT_SOURCE_DIR}/data") diff --git a/lib/cprofiles/tests/opentelemetry_transcoder.c b/lib/cprofiles/tests/opentelemetry_transcoder.c index 7c59e25fbd1..e6861e79cf0 100644 --- a/lib/cprofiles/tests/opentelemetry_transcoder.c +++ b/lib/cprofiles/tests/opentelemetry_transcoder.c @@ -21,10 +21,126 @@ #include "cprof_tests.h" #include #include +#include +#include #include #include #include +#include + +/* + * Build a minimal cprof (resource_profiles -> scope_profiles -> profile with one sample) + * so we can test OTLP encode then decode round-trip without depending on old wire data. + */ +static struct cprof *create_minimal_cprof(void) +{ + struct cprof *cprof; + struct cprof_resource_profiles *resource_profiles; + struct cprof_resource *resource; + struct cprof_scope_profiles *scope_profiles; + struct cprof_profile *profile; + struct cprof_sample *sample; + struct cfl_kvlist *attrs; + size_t id; + int ret; + + cprof = cprof_create(); + if (cprof == NULL) { + return NULL; + } + + resource_profiles = cprof_resource_profiles_create(""); + if (resource_profiles == NULL) { + cprof_destroy(cprof); + return NULL; + } + + attrs = cfl_kvlist_create(); + if (attrs == NULL) { + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + resource = cprof_resource_create(attrs); + if (resource == NULL) { + cfl_kvlist_destroy(attrs); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + resource_profiles->resource = resource; + + scope_profiles = cprof_scope_profiles_create(resource_profiles, ""); + if (scope_profiles == NULL) { + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + scope_profiles->scope = cprof_instrumentation_scope_create("", "", NULL, 0); + if (scope_profiles->scope == NULL) { + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + + profile = cprof_profile_create(); + if (profile == NULL) { + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + profile->time_nanos = 1000000000ULL; + profile->duration_nanos = 100000000ULL; + + cprof_sample_type_str_create(profile, "count", "", CPROF_AGGREGATION_TEMPORALITY_CUMULATIVE); + id = cprof_profile_string_add(profile, "main", -1); + if (id == 0) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + + sample = cprof_sample_create(profile); + if (sample == NULL) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + ret = cprof_sample_add_location_index(sample, id); + if (ret != 0) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + ret = cprof_sample_add_value(sample, 1); + if (ret != 0) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + + cfl_list_add(&profile->_head, &scope_profiles->profiles); + + ret = cprof_resource_profiles_add(cprof, resource_profiles); + if (ret != 0) { + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + + return cprof; +} /* unsigned char encoded_packet[] = { 0x0A, 0x9F, 0x11, 0x0A, 0x72, 0x0A, 0x0E, 0x0A, 0x07, 0x68, 0x6F, 0x73, 0x74, 0x2E, 0x69, 0x64, 0x12, 0x03, 0x0A, 0x01, 0x30, 0x0A, 0x16, 0x0A, 0x07, 0x68, 0x6F, 0x73, 0x74, 0x2E, \ @@ -104,247 +220,537 @@ unsigned char encoded_packet[] = { 0x0A, 0x9F, 0x11, 0x0A, 0x72, 0x0A, 0x0E, 0x }; */ -unsigned char serialized_data[] = { - 0x0A, 0x9F, 0x11, 0x0A, 0x72, 0x0A, 0x0E, 0x0A, 0x07, 0x68, 0x6F, 0x73, - 0x74, 0x2E, 0x69, 0x64, 0x12, 0x03, 0x0A, 0x01, 0x30, 0x0A, 0x16, 0x0A, - 0x07, 0x68, 0x6F, 0x73, 0x74, 0x2E, 0x69, 0x70, 0x12, 0x0B, 0x0A, 0x09, - 0x31, 0x32, 0x37, 0x2E, 0x30, 0x2E, 0x30, 0x2E, 0x31, 0x0A, 0x1B, 0x0A, - 0x09, 0x68, 0x6F, 0x73, 0x74, 0x2E, 0x6E, 0x61, 0x6D, 0x65, 0x12, 0x0E, - 0x0A, 0x0C, 0x6C, 0x69, 0x6D, 0x61, 0x2D, 0x64, 0x65, 0x66, 0x61, 0x75, - 0x6C, 0x74, 0x0A, 0x15, 0x0A, 0x0F, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x2E, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x12, 0x02, 0x0A, - 0x00, 0x0A, 0x14, 0x0A, 0x09, 0x6F, 0x73, 0x2E, 0x6B, 0x65, 0x72, 0x6E, - 0x65, 0x6C, 0x12, 0x07, 0x0A, 0x05, 0x36, 0x2E, 0x35, 0x2E, 0x30, 0x12, - 0xA8, 0x10, 0x0A, 0x00, 0x12, 0xA3, 0x10, 0x0A, 0x10, 0xA4, 0x58, 0x33, - 0xE6, 0x18, 0xE6, 0x34, 0x8D, 0xD6, 0xFE, 0x00, 0x58, 0x56, 0xF5, 0xA7, - 0x54, 0x11, 0x69, 0x39, 0xAC, 0x2C, 0x53, 0xC7, 0x04, 0x18, 0x19, 0x69, - 0x39, 0xAC, 0x2C, 0x53, 0xC7, 0x04, 0x18, 0x42, 0xFC, 0x0F, 0x0A, 0x04, - 0x08, 0x01, 0x10, 0x02, 0x12, 0x16, 0x12, 0x01, 0x01, 0x40, 0x05, 0x48, - 0x05, 0x52, 0x02, 0x01, 0x02, 0x6A, 0x09, 0xF6, 0xEA, 0xCA, 0xD2, 0xAC, - 0xEA, 0xB1, 0x82, 0x18, 0x12, 0x18, 0x12, 0x01, 0x01, 0x38, 0x05, 0x40, - 0x0E, 0x48, 0x07, 0x52, 0x02, 0x06, 0x07, 0x6A, 0x09, 0xA8, 0xD3, 0xE3, - 0x8E, 0xB1, 0xEA, 0xB1, 0x82, 0x18, 0x12, 0x18, 0x12, 0x01, 0x01, 0x38, - 0x13, 0x40, 0x12, 0x48, 0x09, 0x52, 0x02, 0x09, 0x0A, 0x6A, 0x09, 0xE9, - 0xF2, 0xB0, 0xE5, 0xB2, 0xEA, 0xB1, 0x82, 0x18, 0x1A, 0x04, 0x30, 0x06, - 0x58, 0x01, 0x1A, 0x10, 0x10, 0x80, 0x80, 0x80, 0x02, 0x18, 0x80, 0x80, - 0xF4, 0x08, 0x28, 0x08, 0x62, 0x02, 0x04, 0x05, 0x1A, 0x0E, 0x10, 0x80, - 0x80, 0x04, 0x18, 0x80, 0xC0, 0xFB, 0x07, 0x28, 0x0A, 0x62, 0x01, 0x08, - 0x22, 0x0B, 0x18, 0xDB, 0xC1, 0x43, 0x22, 0x02, 0x08, 0x01, 0x3A, 0x01, - 0x00, 0x22, 0x0C, 0x18, 0xC7, 0x8B, 0xD2, 0x0A, 0x22, 0x02, 0x08, 0x02, - 0x3A, 0x01, 0x00, 0x22, 0x0B, 0x18, 0xB7, 0x94, 0x3A, 0x22, 0x02, 0x08, - 0x03, 0x3A, 0x01, 0x00, 0x22, 0x0B, 0x18, 0xF7, 0x96, 0x3D, 0x22, 0x02, - 0x08, 0x04, 0x3A, 0x01, 0x00, 0x22, 0x0B, 0x18, 0x87, 0xFA, 0x01, 0x22, - 0x02, 0x08, 0x05, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, 0xC3, 0xD6, 0xA1, - 0x02, 0x22, 0x02, 0x08, 0x06, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, 0xBB, - 0xB5, 0xB3, 0x02, 0x22, 0x02, 0x08, 0x07, 0x3A, 0x01, 0x00, 0x22, 0x0C, - 0x18, 0xE7, 0xB7, 0xB3, 0x02, 0x22, 0x02, 0x08, 0x08, 0x3A, 0x01, 0x00, - 0x22, 0x0C, 0x18, 0x93, 0xD5, 0xB9, 0x01, 0x22, 0x02, 0x08, 0x09, 0x3A, - 0x01, 0x00, 0x22, 0x0C, 0x18, 0xD7, 0x8C, 0xB8, 0x01, 0x22, 0x02, 0x08, - 0x0A, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, 0x97, 0x93, 0xBA, 0x01, 0x22, - 0x02, 0x08, 0x0B, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, 0x9F, 0xA8, 0xBA, - 0x01, 0x22, 0x02, 0x08, 0x0C, 0x3A, 0x01, 0x00, 0x22, 0x0B, 0x18, 0xEB, - 0xFA, 0x08, 0x22, 0x02, 0x08, 0x0D, 0x3A, 0x01, 0x00, 0x22, 0x0B, 0x18, - 0xD3, 0xFE, 0x08, 0x22, 0x02, 0x08, 0x0E, 0x3A, 0x01, 0x00, 0x22, 0x0B, - 0x18, 0xB7, 0xFF, 0x08, 0x22, 0x02, 0x08, 0x0F, 0x3A, 0x01, 0x00, 0x22, - 0x0C, 0x18, 0xA7, 0xBD, 0xCF, 0x0A, 0x22, 0x02, 0x08, 0x10, 0x3A, 0x01, - 0x00, 0x22, 0x0C, 0x18, 0xCF, 0xCA, 0xCF, 0x0A, 0x22, 0x02, 0x08, 0x11, - 0x3A, 0x01, 0x00, 0x22, 0x0A, 0x18, 0xC7, 0x3C, 0x22, 0x02, 0x08, 0x12, - 0x3A, 0x01, 0x00, 0x22, 0x0A, 0x10, 0x01, 0x18, 0x9F, 0xA6, 0x81, 0x02, - 0x3A, 0x01, 0x03, 0x22, 0x0C, 0x18, 0x9F, 0xCD, 0xA9, 0x02, 0x22, 0x02, - 0x08, 0x13, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, 0xC3, 0xDF, 0xAC, 0x02, - 0x22, 0x02, 0x08, 0x14, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, 0xB3, 0x9F, - 0xAD, 0x02, 0x22, 0x02, 0x08, 0x15, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, - 0x9B, 0xE1, 0xA0, 0x02, 0x22, 0x02, 0x08, 0x16, 0x3A, 0x01, 0x00, 0x22, - 0x0C, 0x18, 0xCB, 0xE8, 0x86, 0x09, 0x22, 0x02, 0x08, 0x17, 0x3A, 0x01, - 0x00, 0x22, 0x0C, 0x18, 0xEB, 0xE3, 0x87, 0x09, 0x22, 0x02, 0x08, 0x18, - 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, 0xFB, 0xAE, 0xFE, 0x09, 0x22, 0x02, - 0x08, 0x19, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, 0xE7, 0xB0, 0xFE, 0x09, - 0x22, 0x02, 0x08, 0x1A, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, 0xEF, 0x90, - 0x85, 0x09, 0x22, 0x02, 0x08, 0x1B, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, - 0xF7, 0xF3, 0x85, 0x09, 0x22, 0x02, 0x08, 0x1C, 0x3A, 0x01, 0x00, 0x22, - 0x0C, 0x18, 0xCB, 0xF5, 0x85, 0x09, 0x22, 0x02, 0x08, 0x1D, 0x3A, 0x01, - 0x00, 0x22, 0x0B, 0x18, 0xEB, 0xFA, 0x08, 0x22, 0x02, 0x08, 0x0D, 0x3A, - 0x01, 0x00, 0x22, 0x0B, 0x18, 0xD3, 0xFE, 0x08, 0x22, 0x02, 0x08, 0x0E, - 0x3A, 0x01, 0x00, 0x22, 0x0B, 0x18, 0xB7, 0xFF, 0x08, 0x22, 0x02, 0x08, - 0x0F, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, 0xA7, 0xBD, 0xCF, 0x0A, 0x22, - 0x02, 0x08, 0x10, 0x3A, 0x01, 0x00, 0x22, 0x0C, 0x18, 0xCF, 0xCA, 0xCF, - 0x0A, 0x22, 0x02, 0x08, 0x11, 0x3A, 0x01, 0x00, 0x22, 0x0A, 0x18, 0xC7, - 0x3C, 0x22, 0x02, 0x08, 0x12, 0x3A, 0x01, 0x00, 0x22, 0x09, 0x10, 0x02, - 0x18, 0xAF, 0xBF, 0x05, 0x3A, 0x01, 0x03, 0x2A, 0x00, 0x2A, 0x02, 0x10, - 0x18, 0x2A, 0x02, 0x10, 0x10, 0x2A, 0x02, 0x10, 0x24, 0x2A, 0x02, 0x10, - 0x19, 0x2A, 0x02, 0x10, 0x21, 0x2A, 0x02, 0x10, 0x1A, 0x2A, 0x02, 0x10, - 0x25, 0x2A, 0x02, 0x10, 0x0B, 0x2A, 0x02, 0x10, 0x26, 0x2A, 0x02, 0x10, - 0x11, 0x2A, 0x02, 0x10, 0x14, 0x2A, 0x02, 0x10, 0x15, 0x2A, 0x02, 0x10, - 0x12, 0x2A, 0x02, 0x10, 0x22, 0x2A, 0x02, 0x10, 0x16, 0x2A, 0x02, 0x10, - 0x0E, 0x2A, 0x02, 0x10, 0x1B, 0x2A, 0x02, 0x10, 0x1E, 0x2A, 0x02, 0x10, - 0x17, 0x2A, 0x02, 0x10, 0x27, 0x2A, 0x02, 0x10, 0x0C, 0x2A, 0x02, 0x10, - 0x13, 0x2A, 0x02, 0x10, 0x1F, 0x2A, 0x02, 0x10, 0x23, 0x2A, 0x02, 0x10, - 0x0F, 0x2A, 0x02, 0x10, 0x1C, 0x2A, 0x02, 0x10, 0x0D, 0x2A, 0x02, 0x10, - 0x20, 0x2A, 0x02, 0x10, 0x1D, 0x32, 0x00, 0x32, 0x07, 0x73, 0x61, 0x6D, - 0x70, 0x6C, 0x65, 0x73, 0x32, 0x05, 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x32, - 0x03, 0x63, 0x70, 0x75, 0x32, 0x0B, 0x6E, 0x61, 0x6E, 0x6F, 0x73, 0x65, - 0x63, 0x6F, 0x6E, 0x64, 0x73, 0x32, 0x16, 0x41, 0x54, 0x73, 0x51, 0x46, - 0x31, 0x72, 0x72, 0x49, 0x63, 0x30, 0x35, 0x74, 0x65, 0x6A, 0x66, 0x79, - 0x65, 0x73, 0x5A, 0x52, 0x77, 0x32, 0x20, 0x62, 0x61, 0x31, 0x63, 0x39, - 0x61, 0x35, 0x61, 0x38, 0x32, 0x35, 0x36, 0x61, 0x36, 0x65, 0x66, 0x33, - 0x65, 0x36, 0x36, 0x33, 0x63, 0x63, 0x37, 0x33, 0x31, 0x36, 0x38, 0x30, - 0x33, 0x64, 0x39, 0x32, 0x16, 0x7A, 0x6A, 0x32, 0x51, 0x75, 0x43, 0x52, - 0x61, 0x70, 0x75, 0x6E, 0x30, 0x32, 0x73, 0x79, 0x68, 0x6C, 0x41, 0x48, - 0x71, 0x54, 0x77, 0x32, 0x0D, 0x65, 0x62, 0x70, 0x66, 0x2D, 0x70, 0x72, - 0x6F, 0x66, 0x69, 0x6C, 0x65, 0x72, 0x32, 0x16, 0x36, 0x34, 0x41, 0x49, - 0x75, 0x76, 0x39, 0x69, 0x70, 0x47, 0x42, 0x41, 0x41, 0x64, 0x30, 0x52, - 0x5A, 0x6D, 0x76, 0x4C, 0x4C, 0x77, 0x32, 0x0A, 0x63, 0x6F, 0x6E, 0x74, - 0x61, 0x69, 0x6E, 0x65, 0x72, 0x64, 0x32, 0x13, 0x5F, 0x5F, 0x63, 0x68, - 0x65, 0x63, 0x6B, 0x5F, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x5F, 0x73, - 0x69, 0x7A, 0x65, 0x32, 0x11, 0x6F, 0x62, 0x6A, 0x5F, 0x63, 0x67, 0x72, - 0x6F, 0x75, 0x70, 0x5F, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x32, 0x0D, - 0x5F, 0x5F, 0x73, 0x6F, 0x63, 0x6B, 0x5F, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x32, 0x07, 0x65, 0x6C, 0x30, 0x5F, 0x73, 0x76, 0x63, 0x32, 0x0C, - 0x75, 0x6E, 0x69, 0x78, 0x5F, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x31, - 0x32, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6C, 0x65, 0x32, 0x10, - 0x62, 0x70, 0x66, 0x5F, 0x6D, 0x61, 0x70, 0x5F, 0x64, 0x6F, 0x5F, 0x62, - 0x61, 0x74, 0x63, 0x68, 0x32, 0x0E, 0x69, 0x6E, 0x76, 0x6F, 0x6B, 0x65, - 0x5F, 0x73, 0x79, 0x73, 0x63, 0x61, 0x6C, 0x6C, 0x32, 0x10, 0x6B, 0x6D, - 0x65, 0x6D, 0x5F, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5F, 0x61, 0x6C, 0x6C, - 0x6F, 0x63, 0x32, 0x09, 0x5F, 0x5F, 0x73, 0x79, 0x73, 0x5F, 0x62, 0x70, - 0x66, 0x32, 0x0F, 0x5F, 0x5F, 0x61, 0x72, 0x6D, 0x36, 0x34, 0x5F, 0x73, - 0x79, 0x73, 0x5F, 0x62, 0x70, 0x66, 0x32, 0x0A, 0x64, 0x6F, 0x5F, 0x65, - 0x6C, 0x30, 0x5F, 0x73, 0x76, 0x63, 0x32, 0x19, 0x70, 0x72, 0x6F, 0x70, - 0x61, 0x67, 0x61, 0x74, 0x65, 0x5F, 0x70, 0x72, 0x6F, 0x74, 0x65, 0x63, - 0x74, 0x65, 0x64, 0x5F, 0x75, 0x73, 0x61, 0x67, 0x65, 0x32, 0x19, 0x66, - 0x69, 0x6E, 0x69, 0x73, 0x68, 0x5F, 0x74, 0x61, 0x73, 0x6B, 0x5F, 0x73, - 0x77, 0x69, 0x74, 0x63, 0x68, 0x2E, 0x69, 0x73, 0x72, 0x61, 0x2E, 0x30, - 0x32, 0x07, 0x6B, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x32, 0x13, 0x5F, - 0x5F, 0x63, 0x68, 0x65, 0x63, 0x6B, 0x5F, 0x68, 0x65, 0x61, 0x70, 0x5F, - 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x32, 0x14, 0x65, 0x6C, 0x30, 0x74, - 0x5F, 0x36, 0x34, 0x5F, 0x73, 0x79, 0x6E, 0x63, 0x5F, 0x68, 0x61, 0x6E, - 0x64, 0x6C, 0x65, 0x72, 0x32, 0x0B, 0x75, 0x6E, 0x69, 0x78, 0x5F, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x32, 0x12, 0x5F, 0x5F, 0x61, 0x72, 0x6D, - 0x36, 0x34, 0x5F, 0x73, 0x79, 0x73, 0x5F, 0x73, 0x6F, 0x63, 0x6B, 0x65, - 0x74, 0x32, 0x0C, 0x65, 0x6C, 0x30, 0x74, 0x5F, 0x36, 0x34, 0x5F, 0x73, - 0x79, 0x6E, 0x63, 0x32, 0x0D, 0x73, 0x6B, 0x5F, 0x70, 0x72, 0x6F, 0x74, - 0x5F, 0x61, 0x6C, 0x6C, 0x6F, 0x63, 0x32, 0x0C, 0x5F, 0x5F, 0x73, 0x79, - 0x73, 0x5F, 0x73, 0x6F, 0x63, 0x6B, 0x65, 0x74, 0x32, 0x0D, 0x72, 0x65, - 0x74, 0x5F, 0x66, 0x72, 0x6F, 0x6D, 0x5F, 0x66, 0x6F, 0x72, 0x6B, 0x32, - 0x1A, 0x65, 0x6C, 0x30, 0x5F, 0x73, 0x76, 0x63, 0x5F, 0x63, 0x6F, 0x6D, - 0x6D, 0x6F, 0x6E, 0x2E, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x70, 0x72, 0x6F, - 0x70, 0x2E, 0x30, 0x32, 0x08, 0x73, 0x6B, 0x5F, 0x61, 0x6C, 0x6C, 0x6F, - 0x63, 0x32, 0x0D, 0x77, 0x6F, 0x72, 0x6B, 0x65, 0x72, 0x5F, 0x74, 0x68, - 0x72, 0x65, 0x61, 0x64, 0x32, 0x1A, 0x5F, 0x5F, 0x63, 0x68, 0x65, 0x63, - 0x6B, 0x5F, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x5F, 0x73, 0x69, 0x7A, - 0x65, 0x2E, 0x70, 0x61, 0x72, 0x74, 0x2E, 0x30, 0x32, 0x18, 0x67, 0x65, - 0x6E, 0x65, 0x72, 0x69, 0x63, 0x5F, 0x6D, 0x61, 0x70, 0x5F, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x5F, 0x62, 0x61, 0x74, 0x63, 0x68, 0x32, 0x10, - 0x74, 0x72, 0x79, 0x5F, 0x63, 0x68, 0x61, 0x72, 0x67, 0x65, 0x5F, 0x6D, - 0x65, 0x6D, 0x63, 0x67, 0x48, 0xE9, 0xF2, 0xB0, 0xE5, 0xB2, 0xEA, 0xB1, - 0x82, 0x18, 0x5A, 0x04, 0x08, 0x03, 0x10, 0x04, 0x60, 0x80, 0xE1, 0xEB, - 0x17, 0x7A, 0x25, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, - 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x82, 0x01, 0x1E, 0x0A, 0x12, 0x70, 0x72, 0x6F, - 0x66, 0x69, 0x6C, 0x65, 0x2E, 0x66, 0x72, 0x61, 0x6D, 0x65, 0x2E, 0x74, - 0x79, 0x70, 0x65, 0x12, 0x08, 0x0A, 0x06, 0x6B, 0x65, 0x72, 0x6E, 0x65, - 0x6C, 0x82, 0x01, 0x13, 0x0A, 0x0C, 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, - 0x6E, 0x65, 0x72, 0x2E, 0x69, 0x64, 0x12, 0x03, 0x0A, 0x01, 0x2F, 0x82, - 0x01, 0x1C, 0x0A, 0x0B, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x2E, 0x6E, - 0x61, 0x6D, 0x65, 0x12, 0x0D, 0x0A, 0x0B, 0x6B, 0x77, 0x6F, 0x72, 0x6B, - 0x65, 0x72, 0x2F, 0x36, 0x3A, 0x31, 0x82, 0x01, 0x1E, 0x0A, 0x12, 0x70, - 0x72, 0x6F, 0x66, 0x69, 0x6C, 0x65, 0x2E, 0x66, 0x72, 0x61, 0x6D, 0x65, - 0x2E, 0x74, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0A, 0x06, 0x6E, 0x61, 0x74, - 0x69, 0x76, 0x65, 0x82, 0x01, 0x4D, 0x0A, 0x1F, 0x70, 0x72, 0x6F, 0x63, - 0x65, 0x73, 0x73, 0x2E, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, - 0x6C, 0x65, 0x2E, 0x62, 0x75, 0x69, 0x6C, 0x64, 0x5F, 0x69, 0x64, 0x2E, - 0x67, 0x6E, 0x75, 0x12, 0x2A, 0x0A, 0x28, 0x33, 0x34, 0x31, 0x39, 0x61, - 0x33, 0x65, 0x66, 0x30, 0x30, 0x31, 0x35, 0x34, 0x35, 0x64, 0x38, 0x65, - 0x65, 0x39, 0x66, 0x63, 0x64, 0x34, 0x62, 0x31, 0x38, 0x64, 0x34, 0x63, - 0x65, 0x31, 0x37, 0x32, 0x30, 0x35, 0x37, 0x65, 0x33, 0x33, 0x39, 0x82, - 0x01, 0x4B, 0x0A, 0x25, 0x70, 0x72, 0x6F, 0x63, 0x65, 0x73, 0x73, 0x2E, - 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x61, 0x62, 0x6C, 0x65, 0x2E, 0x62, - 0x75, 0x69, 0x6C, 0x64, 0x5F, 0x69, 0x64, 0x2E, 0x70, 0x72, 0x6F, 0x66, - 0x69, 0x6C, 0x69, 0x6E, 0x67, 0x12, 0x22, 0x0A, 0x20, 0x37, 0x30, 0x35, - 0x62, 0x64, 0x66, 0x31, 0x34, 0x39, 0x38, 0x30, 0x66, 0x32, 0x63, 0x32, - 0x32, 0x64, 0x63, 0x34, 0x64, 0x65, 0x32, 0x65, 0x36, 0x35, 0x37, 0x36, - 0x65, 0x64, 0x66, 0x66, 0x38, 0x82, 0x01, 0x3C, 0x0A, 0x0C, 0x63, 0x6F, - 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x65, 0x72, 0x2E, 0x69, 0x64, 0x12, 0x2C, - 0x0A, 0x2A, 0x2F, 0x75, 0x73, 0x65, 0x72, 0x2E, 0x73, 0x6C, 0x69, 0x63, - 0x65, 0x2F, 0x75, 0x73, 0x65, 0x72, 0x2D, 0x35, 0x30, 0x31, 0x2E, 0x73, - 0x6C, 0x69, 0x63, 0x65, 0x2F, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6F, 0x6E, - 0x2D, 0x32, 0x2E, 0x73, 0x63, 0x6F, 0x70, 0x65, 0x82, 0x01, 0x1E, 0x0A, - 0x0B, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x2E, 0x6E, 0x61, 0x6D, 0x65, - 0x12, 0x0F, 0x0A, 0x0D, 0x65, 0x62, 0x70, 0x66, 0x2D, 0x70, 0x72, 0x6F, - 0x66, 0x69, 0x6C, 0x65, 0x72, 0x82, 0x01, 0x4B, 0x0A, 0x25, 0x70, 0x72, - 0x6F, 0x63, 0x65, 0x73, 0x73, 0x2E, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, - 0x61, 0x62, 0x6C, 0x65, 0x2E, 0x62, 0x75, 0x69, 0x6C, 0x64, 0x5F, 0x69, - 0x64, 0x2E, 0x70, 0x72, 0x6F, 0x66, 0x69, 0x6C, 0x69, 0x6E, 0x67, 0x12, - 0x22, 0x0A, 0x20, 0x64, 0x37, 0x38, 0x30, 0x31, 0x36, 0x30, 0x34, 0x65, - 0x38, 0x62, 0x38, 0x39, 0x64, 0x64, 0x61, 0x63, 0x66, 0x65, 0x31, 0x39, - 0x38, 0x39, 0x39, 0x64, 0x36, 0x62, 0x61, 0x33, 0x35, 0x36, 0x34, 0x82, - 0x01, 0x5A, 0x0A, 0x0C, 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x65, - 0x72, 0x2E, 0x69, 0x64, 0x12, 0x4A, 0x0A, 0x48, 0x2F, 0x75, 0x73, 0x65, - 0x72, 0x2E, 0x73, 0x6C, 0x69, 0x63, 0x65, 0x2F, 0x75, 0x73, 0x65, 0x72, - 0x2D, 0x35, 0x30, 0x31, 0x2E, 0x73, 0x6C, 0x69, 0x63, 0x65, 0x2F, 0x75, - 0x73, 0x65, 0x72, 0x40, 0x35, 0x30, 0x31, 0x2E, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x2F, 0x61, 0x70, 0x70, 0x2E, 0x73, 0x6C, 0x69, 0x63, - 0x65, 0x2F, 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x65, 0x72, 0x64, - 0x2E, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x82, 0x01, 0x1B, 0x0A, - 0x0B, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x2E, 0x6E, 0x61, 0x6D, 0x65, - 0x12, 0x0C, 0x0A, 0x0A, 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x65, - 0x72, 0x64 -}; +/* Encode minimal cprof to OTLP and check success. */ static void test_encoder() { - cfl_sds_t otlp_encoder_result; + cfl_sds_t otlp_result; struct cprof *context; int result; + + context = create_minimal_cprof(); + TEST_CHECK(context != NULL); + if (context == NULL) { + return; + } + + result = cprof_encode_opentelemetry_create(&otlp_result, context); + TEST_CHECK(result == CPROF_ENCODE_OPENTELEMETRY_SUCCESS); + + if (result == CPROF_ENCODE_OPENTELEMETRY_SUCCESS && otlp_result != NULL) { + cprof_encode_opentelemetry_destroy(otlp_result); + } + cprof_destroy(context); +} + +/* Round-trip: encode minimal cprof to OTLP, decode it back, assert decode success. */ +static void test_decoder() +{ + cfl_sds_t otlp_result; + struct cprof *encoded_context; + struct cprof *decoded_context; + int result; size_t offset; - offset = 0; - context = NULL; + encoded_context = create_minimal_cprof(); + TEST_CHECK(encoded_context != NULL); + if (encoded_context == NULL) { + return; + } - result = cprof_decode_opentelemetry_create(&context, - serialized_data, - sizeof(serialized_data), - &offset); + result = cprof_encode_opentelemetry_create(&otlp_result, encoded_context); + TEST_CHECK(result == CPROF_ENCODE_OPENTELEMETRY_SUCCESS); + cprof_destroy(encoded_context); + if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS || otlp_result == NULL) { + return; + } + offset = 0; + decoded_context = NULL; + result = cprof_decode_opentelemetry_create(&decoded_context, + (unsigned char *) otlp_result, + cfl_sds_len(otlp_result), + &offset); TEST_CHECK(result == CPROF_DECODE_OPENTELEMETRY_SUCCESS); - if (result == CPROF_DECODE_OPENTELEMETRY_SUCCESS) { - result = cprof_encode_opentelemetry_create(&otlp_encoder_result, context); + if (result == CPROF_DECODE_OPENTELEMETRY_SUCCESS && decoded_context != NULL) { + cprof_decode_opentelemetry_destroy(decoded_context); + } + cprof_encode_opentelemetry_destroy(otlp_result); +} + +/* + * Build a cprof with dictionary tables populated: one mapping, one function, + * one location (with one line), one sample referencing that location, and + * optionally one link. Exercises mapping_table, function_table, location_table, + * stack_table (with real location indices), and link_table. + */ +static struct cprof *create_cprof_with_dictionary_tables(void) +{ + struct cprof *cprof; + struct cprof_resource_profiles *resource_profiles; + struct cprof_resource *resource; + struct cprof_scope_profiles *scope_profiles; + struct cprof_profile *profile; + struct cprof_sample *sample; + struct cprof_mapping *mapping; + struct cprof_function *func; + struct cprof_location *loc; + struct cprof_line *line; + struct cprof_link *link; + struct cfl_kvlist *attrs; + size_t id_bin; + size_t id_foo; + int ret; - TEST_CHECK(result == CPROF_ENCODE_OPENTELEMETRY_SUCCESS); + cprof = cprof_create(); + if (cprof == NULL) { + return NULL; + } - if (result == CPROF_ENCODE_OPENTELEMETRY_SUCCESS) { - cprof_encode_opentelemetry_destroy(otlp_encoder_result); - } + resource_profiles = cprof_resource_profiles_create(""); + if (resource_profiles == NULL) { + cprof_destroy(cprof); + return NULL; + } + + attrs = cfl_kvlist_create(); + if (attrs == NULL) { + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + resource = cprof_resource_create(attrs); + if (resource == NULL) { + cfl_kvlist_destroy(attrs); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + resource_profiles->resource = resource; + + scope_profiles = cprof_scope_profiles_create(resource_profiles, ""); + if (scope_profiles == NULL) { + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + scope_profiles->scope = cprof_instrumentation_scope_create("", "", NULL, 0); + if (scope_profiles->scope == NULL) { + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + + profile = cprof_profile_create(); + if (profile == NULL) { + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + profile->time_nanos = 2000000000ULL; + profile->duration_nanos = 200000000ULL; + + cprof_sample_type_str_create(profile, "count", "", CPROF_AGGREGATION_TEMPORALITY_CUMULATIVE); + id_bin = cprof_profile_string_add(profile, "/bin/app", -1); + id_foo = cprof_profile_string_add(profile, "foo", -1); + if (id_bin == 0 || id_foo == 0) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + + /* One mapping (dict mapping_table will have zero + this). */ + mapping = cprof_mapping_create(profile); + if (mapping == NULL) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + mapping->memory_start = 0x1000ULL; + mapping->memory_limit = 0x2000ULL; + mapping->file_offset = 0; + mapping->filename = (int64_t)id_bin; + + /* One function (dict function_table will have zero + this). */ + func = cprof_function_create(profile); + if (func == NULL) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + func->name = (int64_t)id_foo; + func->system_name = (int64_t)id_foo; + func->filename = 0; + func->start_line = 10; + + /* One location with one line (dict location_table will have zero + this). */ + loc = cprof_location_create(profile); + if (loc == NULL) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + loc->mapping_index = 0; + loc->address = 0x1000ULL; + line = cprof_line_create(loc); + if (line == NULL) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + line->function_index = 0; + line->line = 10; + line->column = 0; + + /* One link (dict link_table will have zero + this). */ + link = cprof_link_create(profile); + if (link == NULL) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + link->trace_id[0] = 0x01; + link->trace_id[15] = 0x0f; + link->span_id[0] = 0xaa; + link->span_id[7] = 0xbb; - cprof_decode_opentelemetry_destroy(context); + /* Sample with location_index 0 (first location) and link 0. */ + sample = cprof_sample_create(profile); + if (sample == NULL) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; } + ret = cprof_sample_add_location_index(sample, 0); + if (ret != 0) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + ret = cprof_sample_add_value(sample, 42); + if (ret != 0) { + cprof_profile_destroy(profile); + cprof_scope_profiles_destroy(scope_profiles); + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + sample->link = 0; /* index into profile->link_table (first link). */ + + cfl_list_add(&profile->_head, &scope_profiles->profiles); + + ret = cprof_resource_profiles_add(cprof, resource_profiles); + if (ret != 0) { + cprof_resource_profiles_destroy(resource_profiles); + cprof_destroy(cprof); + return NULL; + } + + return cprof; } -static void test_decoder() +/* Encode cprof with full dictionary (mappings, functions, locations, links) and check success. */ +static void test_encoder_dictionary_tables() { + cfl_sds_t otlp_result; struct cprof *context; int result; + + context = create_cprof_with_dictionary_tables(); + TEST_CHECK(context != NULL); + if (context == NULL) { + return; + } + + result = cprof_encode_opentelemetry_create(&otlp_result, context); + TEST_CHECK(result == CPROF_ENCODE_OPENTELEMETRY_SUCCESS); + + if (result == CPROF_ENCODE_OPENTELEMETRY_SUCCESS && otlp_result != NULL) { + cprof_encode_opentelemetry_destroy(otlp_result); + } + cprof_destroy(context); +} + +/* + * Verify decoded cprof matches the structure produced by create_cprof_with_dictionary_tables. + * Decoder may emit dictionary sentinel at index 0 plus our entry, so we require at least 1 + * and find the entry matching our data. This guards against breaking changes in encode/decode. + */ +static void verify_decoded_cprof_dictionary_tables(struct cprof *decoded) +{ + struct cprof_resource_profiles *rp; + struct cprof_scope_profiles *sp; + struct cprof_profile *profile; + struct cprof_mapping *mapping; + struct cprof_function *func; + struct cprof_location *loc; + struct cprof_line *line; + struct cprof_link *link; + struct cprof_sample *sample; + struct cfl_list *rp_iter; + struct cfl_list *sp_iter; + struct cfl_list *prof_iter; + struct cfl_list *map_iter; + struct cfl_list *func_iter; + struct cfl_list *loc_iter; + struct cfl_list *line_iter; + struct cfl_list *link_iter; + struct cfl_list *sample_iter; + size_t i; + int found_bin_app; + int found_foo; + int found_mapping; + int found_function; + int found_location; + int found_link; + + TEST_CHECK(decoded != NULL); + if (decoded == NULL) { + return; + } + + TEST_CHECK(cfl_list_size(&decoded->profiles) == 1); + if (cfl_list_size(&decoded->profiles) != 1) { + return; + } + + rp_iter = decoded->profiles.next; + rp = cfl_list_entry(rp_iter, struct cprof_resource_profiles, _head); + TEST_CHECK(cfl_list_size(&rp->scope_profiles) == 1); + if (cfl_list_size(&rp->scope_profiles) != 1) { + return; + } + + sp_iter = rp->scope_profiles.next; + sp = cfl_list_entry(sp_iter, struct cprof_scope_profiles, _head); + TEST_CHECK(cfl_list_size(&sp->profiles) == 1); + if (cfl_list_size(&sp->profiles) != 1) { + return; + } + + prof_iter = sp->profiles.next; + profile = cfl_list_entry(prof_iter, struct cprof_profile, _head); + + /* Profile metadata */ + TEST_CHECK(profile->time_nanos == 2000000000ULL); + TEST_CHECK(profile->duration_nanos == 200000000ULL); + + /* At least one mapping; find one with memory_start=0x1000, filename "/bin/app" */ + TEST_CHECK(cfl_list_size(&profile->mappings) >= 1); + found_mapping = 0; + for (map_iter = profile->mappings.next; map_iter != &profile->mappings; map_iter = map_iter->next) { + mapping = cfl_list_entry(map_iter, struct cprof_mapping, _head); + if (mapping->memory_start == 0x1000ULL && mapping->memory_limit == 0x2000ULL && + mapping->file_offset == 0) { + if (mapping->filename >= 0 && (size_t)mapping->filename < profile->string_table_count && + profile->string_table[mapping->filename] != NULL && + strcmp(profile->string_table[mapping->filename], "/bin/app") == 0) { + found_mapping = 1; + break; + } + } + } + TEST_CHECK(found_mapping && "decoded profile must have mapping with /bin/app"); + + /* At least one function; find one with start_line=10, name "foo" */ + TEST_CHECK(cfl_list_size(&profile->functions) >= 1); + found_function = 0; + for (func_iter = profile->functions.next; func_iter != &profile->functions; func_iter = func_iter->next) { + func = cfl_list_entry(func_iter, struct cprof_function, _head); + if (func->start_line == 10) { + if (func->name >= 0 && (size_t)func->name < profile->string_table_count && + profile->string_table[func->name] != NULL && + strcmp(profile->string_table[func->name], "foo") == 0) { + found_function = 1; + break; + } + } + } + TEST_CHECK(found_function && "decoded profile must have function \"foo\" with start_line 10"); + + /* At least one location; find one with address=0x1000, one line with line=10 */ + TEST_CHECK(cfl_list_size(&profile->locations) >= 1); + found_location = 0; + for (loc_iter = profile->locations.next; loc_iter != &profile->locations; loc_iter = loc_iter->next) { + loc = cfl_list_entry(loc_iter, struct cprof_location, _head); + if (loc->address == 0x1000ULL && cfl_list_size(&loc->lines) >= 1) { + line_iter = loc->lines.next; + line = cfl_list_entry(line_iter, struct cprof_line, _head); + if (line->line == 10) { + found_location = 1; + break; + } + } + } + TEST_CHECK(found_location && "decoded profile must have location at 0x1000 with line 10"); + + /* At least one link; find one with trace_id[0]=0x01, span_id[0]=0xaa */ + TEST_CHECK(cfl_list_size(&profile->link_table) >= 1); + found_link = 0; + for (link_iter = profile->link_table.next; link_iter != &profile->link_table; link_iter = link_iter->next) { + link = cfl_list_entry(link_iter, struct cprof_link, _head); + if (link->trace_id[0] == 0x01 && link->trace_id[15] == 0x0f && + link->span_id[0] == (uint8_t)0xaa && link->span_id[7] == (uint8_t)0xbb) { + found_link = 1; + break; + } + } + TEST_CHECK(found_link && "decoded profile must have link with expected trace_id/span_id"); + + /* Exactly one sample: value 42, at least one location_index, link index 0 or matching link */ + TEST_CHECK(cfl_list_size(&profile->samples) == 1); + if (cfl_list_size(&profile->samples) == 1) { + sample_iter = profile->samples.next; + sample = cfl_list_entry(sample_iter, struct cprof_sample, _head); + TEST_CHECK(sample->value_count == 1); + if (sample->value_count >= 1 && sample->values != NULL) { + TEST_CHECK(sample->values[0] == 42); + } + TEST_CHECK(sample->location_index_count >= 1 && "sample must have at least one location_index"); + if (sample->location_index_count >= 1 && sample->location_index != NULL) { + TEST_CHECK(sample->location_index[0] == 0 && "sample must reference first location"); + } + /* sample must reference a link; decoder may use dict index 0 or 1 (sentinel vs first real link) */ + TEST_CHECK(cfl_list_size(&profile->link_table) > 0 && "profile must have links"); + if ((size_t)sample->link < cfl_list_size(&profile->link_table)) { + link_iter = profile->link_table.next; + for (i = 0; i < (size_t)sample->link && link_iter != &profile->link_table; i++) { + link_iter = link_iter->next; + } + if (link_iter != &profile->link_table) { + link = cfl_list_entry(link_iter, struct cprof_link, _head); + TEST_CHECK(link->trace_id[0] == 0x01 && link->trace_id[15] == 0x0f && + link->span_id[0] == (uint8_t)0xaa && link->span_id[7] == (uint8_t)0xbb && + "sample must reference link with expected trace_id/span_id"); + } + } + } + + /* String table must contain "/bin/app" and "foo" (decoder may reorder) */ + found_bin_app = 0; + found_foo = 0; + for (i = 0; i < profile->string_table_count && profile->string_table != NULL; i++) { + if (profile->string_table[i] != NULL) { + if (strcmp(profile->string_table[i], "/bin/app") == 0) { + found_bin_app = 1; + } + if (strcmp(profile->string_table[i], "foo") == 0) { + found_foo = 1; + } + } + } + TEST_CHECK(found_bin_app && "string_table must contain \"/bin/app\""); + TEST_CHECK(found_foo && "string_table must contain \"foo\""); +} + +/* + * Encode cprof with dictionary, unpack the wire buffer, and assert the request + * contains a non-NULL dictionary with expected table counts. Catches encoder + * regressions (e.g. dictionary no longer emitted). + */ +static void test_wire_format_dictionary_present() +{ + cfl_sds_t otlp_result; + struct cprof *context; + int result; + Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfilesServiceRequest *req; + + context = create_cprof_with_dictionary_tables(); + TEST_CHECK(context != NULL); + if (context == NULL) { + return; + } + + result = cprof_encode_opentelemetry_create(&otlp_result, context); + TEST_CHECK(result == CPROF_ENCODE_OPENTELEMETRY_SUCCESS); + cprof_destroy(context); + if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS || otlp_result == NULL) { + return; + } + + req = opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__unpack( + NULL, + cfl_sds_len(otlp_result), + (const unsigned char *) otlp_result); + + TEST_CHECK(req != NULL && "unpack of encoded buffer must succeed"); + if (req != NULL) { + TEST_CHECK(req->dictionary != NULL && "encoded request must contain dictionary"); + if (req->dictionary != NULL) { + TEST_CHECK(req->dictionary->n_string_table >= 2 && "dictionary must have string table (e.g. \"/bin/app\", \"foo\")"); + TEST_CHECK(req->dictionary->n_mapping_table >= 1 && "dictionary must have at least one mapping"); + TEST_CHECK(req->dictionary->n_function_table >= 1 && "dictionary must have at least one function"); + TEST_CHECK(req->dictionary->n_location_table >= 1 && "dictionary must have at least one location"); + TEST_CHECK(req->dictionary->n_link_table >= 1 && "dictionary must have at least one link"); + TEST_CHECK(req->dictionary->n_stack_table >= 1 && "dictionary must have at least one stack"); + } + opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__free_unpacked(req, NULL); + } + + cprof_encode_opentelemetry_destroy(otlp_result); +} + +/* Round-trip cprof with full dictionary tables; decode must succeed and match structure. */ +static void test_decoder_dictionary_tables() +{ + cfl_sds_t otlp_result; + struct cprof *encoded_context; + struct cprof *decoded_context; + int result; size_t offset; - offset = 0; - context = NULL; + encoded_context = create_cprof_with_dictionary_tables(); + TEST_CHECK(encoded_context != NULL); + if (encoded_context == NULL) { + return; + } - result = cprof_decode_opentelemetry_create(&context, - serialized_data, - sizeof(serialized_data), - &offset); + result = cprof_encode_opentelemetry_create(&otlp_result, encoded_context); + TEST_CHECK(result == CPROF_ENCODE_OPENTELEMETRY_SUCCESS); + cprof_destroy(encoded_context); + if (result != CPROF_ENCODE_OPENTELEMETRY_SUCCESS || otlp_result == NULL) { + return; + } + offset = 0; + decoded_context = NULL; + result = cprof_decode_opentelemetry_create(&decoded_context, + (unsigned char *) otlp_result, + cfl_sds_len(otlp_result), + &offset); TEST_CHECK(result == CPROF_DECODE_OPENTELEMETRY_SUCCESS); - if (result == CPROF_DECODE_OPENTELEMETRY_SUCCESS) { - cprof_decode_opentelemetry_destroy(context); + if (result == CPROF_DECODE_OPENTELEMETRY_SUCCESS && decoded_context != NULL) { + verify_decoded_cprof_dictionary_tables(decoded_context); + cprof_decode_opentelemetry_destroy(decoded_context); } + cprof_encode_opentelemetry_destroy(otlp_result); } TEST_LIST = { {"encoder", test_encoder}, {"decoder", test_decoder}, + {"encoder_dictionary_tables", test_encoder_dictionary_tables}, + {"wire_format_dictionary_present", test_wire_format_dictionary_present}, + {"decoder_dictionary_tables", test_decoder_dictionary_tables}, { 0 } }; diff --git a/lib/cprofiles/tests/text_transcoder.c b/lib/cprofiles/tests/text_encoder.c similarity index 99% rename from lib/cprofiles/tests/text_transcoder.c rename to lib/cprofiles/tests/text_encoder.c index 32aa074a1ce..433bbc304c7 100644 --- a/lib/cprofiles/tests/text_transcoder.c +++ b/lib/cprofiles/tests/text_encoder.c @@ -640,13 +640,18 @@ static void test_encoder() TEST_CHECK(offset == sizeof(serialized_data)); if (result == CPROF_DECODE_MSGPACK_SUCCESS) { - result = cprof_encode_text_create(&text_encoder_result, context); + result = cprof_encode_text_create(&text_encoder_result, + context, + CPROF_ENCODE_TEXT_RENDER_DICTIONARIES_AND_INDEXES); TEST_CHECK(result == CPROF_ENCODE_TEXT_SUCCESS); if (result == CPROF_ENCODE_TEXT_SUCCESS) { TEST_CHECK(cfl_sds_len(text_encoder_result) > 1); + printf("%s\n", text_encoder_result); + fflush(stdout); + cprof_encode_text_destroy(text_encoder_result); } diff --git a/lib/ctraces/.github/workflows/build.yaml b/lib/ctraces/.github/workflows/build.yaml index ee53dd0dadb..5b40bbe7b08 100644 --- a/lib/ctraces/.github/workflows/build.yaml +++ b/lib/ctraces/.github/workflows/build.yaml @@ -18,7 +18,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -132,7 +132,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -166,7 +166,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -197,7 +197,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out the repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: submodules: true diff --git a/lib/ctraces/.github/workflows/lint.yaml b/lib/ctraces/.github/workflows/lint.yaml index b9b8aaead39..ec32767d5e8 100644 --- a/lib/ctraces/.github/workflows/lint.yaml +++ b/lib/ctraces/.github/workflows/lint.yaml @@ -9,14 +9,14 @@ jobs: runs-on: ubuntu-latest name: PR - Shellcheck steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: ludeeus/action-shellcheck@master actionlint-pr: runs-on: ubuntu-latest name: PR - Actionlint steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - run: | echo "::add-matcher::.github/actionlint-matcher.json" bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) @@ -27,6 +27,6 @@ jobs: runs-on: ubuntu-latest name: PR - Markdownlint steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Run markdownlint uses: actionshub/markdownlint@v3.1.4 diff --git a/lib/ctraces/.github/workflows/packages.yaml b/lib/ctraces/.github/workflows/packages.yaml index 8f8e88c1c0a..c423590747a 100644 --- a/lib/ctraces/.github/workflows/packages.yaml +++ b/lib/ctraces/.github/workflows/packages.yaml @@ -18,7 +18,7 @@ jobs: matrix: format: [ rpm, deb ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -39,7 +39,7 @@ jobs: echo ${{ matrix.format }} | awk '{print toupper($0)}' | xargs -I{} cpack -G {} - name: Store the master package artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: ${{ matrix.format }}-arm64 path: | @@ -53,7 +53,7 @@ jobs: format: [ rpm, deb ] runs-on: [ ubuntu-latest ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -63,7 +63,7 @@ jobs: echo ${{ matrix.format }} | awk '{print toupper($0)}' | xargs -I{} cpack -G {} - name: Store the master package artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: ${{ matrix.format }}-amd64 path: | @@ -80,7 +80,7 @@ jobs: ext: pkg runs-on: macos-14 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -90,7 +90,7 @@ jobs: echo ${{ matrix.config.format }} | xargs -I{} cpack -G {} - name: Store the master package artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: ${{ matrix.config.format }}-${{matrix.config.arch}} path: | @@ -107,7 +107,7 @@ jobs: contents: write steps: - name: Download all artefacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: path: artifacts/ diff --git a/lib/ctraces/CMakeLists.txt b/lib/ctraces/CMakeLists.txt index 73723433d53..226e70dd674 100644 --- a/lib/ctraces/CMakeLists.txt +++ b/lib/ctraces/CMakeLists.txt @@ -26,8 +26,8 @@ endif() # CTraces Version set(CTR_VERSION_MAJOR 0) -set(CTR_VERSION_MINOR 6) -set(CTR_VERSION_PATCH 6) +set(CTR_VERSION_MINOR 7) +set(CTR_VERSION_PATCH 0) set(CTR_VERSION_STR "${CTR_VERSION_MAJOR}.${CTR_VERSION_MINOR}.${CTR_VERSION_PATCH}") # Define __FILENAME__ consistently across Operating Systems diff --git a/lib/fluent-otel-proto/CMakeLists.txt b/lib/fluent-otel-proto/CMakeLists.txt index d0f4f2939df..6639ff9baae 100644 --- a/lib/fluent-otel-proto/CMakeLists.txt +++ b/lib/fluent-otel-proto/CMakeLists.txt @@ -117,7 +117,12 @@ if (FLUENT_PROTO_REGENERATE) set(proto_file "${OTEL_PROTO_DIR}/opentelemetry/proto/profiles/v1development/profiles.proto") execute_process(COMMAND ${PROTOC_BIN} ${PROTOC_ARG_OUT} ${PROTOC_ARG_PATH} ${proto_file}) + message(STATUS "processing profiles_service.proto") + set(proto_file "${OTEL_PROTO_DIR}/opentelemetry/proto/collector/profiles/v1development/profiles_service.proto") + execute_process(COMMAND ${PROTOC_BIN} ${PROTOC_ARG_OUT} ${PROTOC_ARG_PATH} ${proto_file}) + include_directories(${PROJECT_BINARY_DIR}/opentelemetry/proto/profiles/v1development/) + include_directories(${PROJECT_BINARY_DIR}/opentelemetry/proto/collector/profiles/v1development/) FLUENT_OTEL_DEFINITION(FLUENT_OTEL_HAVE_PROFILES) endif() diff --git a/lib/fluent-otel-proto/README.md b/lib/fluent-otel-proto/README.md index 2174cd780e7..90d94e09c28 100644 --- a/lib/fluent-otel-proto/README.md +++ b/lib/fluent-otel-proto/README.md @@ -26,18 +26,16 @@ cmake ../ By default an example test gets available: -``` +```bash examples/test-api - - opentelemetry proto 'common' : found - opentelemetry proto 'resource': found - opentelemetry proto 'trace' : found - opentelemetry proto 'logs' : found -- opentelemetry proto 'metrics' : not found (enable it with -DFLUENT_PROTO_METRICS) +- opentelemetry proto 'metrics' : found +- opentelemetry proto 'profiles': found ``` -> Yes, Metrics are disabled for now. - ## Regenerate C files To regenerate the C files inside this repo, you need to main dependencies or repositories: @@ -47,9 +45,27 @@ To regenerate the C files inside this repo, you need to main dependencies or rep ### Download dependencies +#### 0. protobuf (https://github.com/protocolbuffers/protobuf) + +This version of protobuf-c to build in the next steps required an updated version of `protobuf`, at this moment this needs to be compiled manually since distros ships a very old version, here are the required steps: + +```bash +cd /tmp +git clone --depth 1 --branch v5.26.1 https://github.com/protocolbuffers/protobuf.git protobuf-src +cd protobuf-src +git submodule update --init --recursive +mkdir build && cd build +cmake .. -DCMAKE_BUILD_TYPE=Release \ + -Dprotobuf_BUILD_TESTS=OFF \ + -DCMAKE_INSTALL_PREFIX=/usr/local +make +sudo make install +sudo ldconfig +``` + #### 1. Protobuf-c -The repository [fluent/protobuf-c](https://github.com/fluent/protobuf-c) is a fork of the official protobuf-c that includes a small modification to support `options` feature from proto3. This feature is only required by the OpenTelemetry Metrics data model. +The repository [fluent/protobuf-c](https://github.com/fluent/protobuf-c) is a fork of the official protobuf-c that includes [upstream PR #781](https://github.com/protobuf-c/protobuf-c/pull/781) to support `optional` feature from proto3. This feature is only required by the OpenTelemetry Metrics data model. Download and install `protobuf-c` by running the following commands: @@ -57,7 +73,7 @@ Download and install `protobuf-c` by running the following commands: git clone https://github.com/fluent/protobuf-c cd protobuf-c ./autogen.sh -./configure --prefix=/opt/protobuf-c +./configure PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig --prefix=/opt/protobuf-c make sudo make install ``` @@ -76,7 +92,7 @@ git clone https://github.com/open-telemetry/opentelemetry-proto git clone https://github.com/fluent/fluent-otel-proto ``` -#### 4. Regenerate C Files +#### 4. Regenerate C Files The CMake command will require the following variable definitions to succeed in the C files regeneration: @@ -90,11 +106,12 @@ In addition, the following build options are available if you desire to enable/d | Build Option | Description | Default | | --------------------- | ------------------------------------------------------------ | ------- | -| FLUENT_PROTO_COMMON | Include the regeneration of a C interface for `common.proto` file. | On | -| FLUENT_PROTO_RESOURCE | Include the regeneration of a C interface for `resource.proto` file. | On | -| FLUENT_PROTO_TRACE | Include the regeneration of a C interfaces for `trace.proto` and `trace_service.proto` files. | On | -| FLUENT_PROTO_LOGS | Include the regeneration of a C interfaces for `logs.proto` and `logs_service.proto` files. | On | -| FLUENT_PROTO_METRICS | Include the regeneration of a C interfaces for `metrics.proto` and `metrics_service.proto` files. | Off | +| FLUENT_PROTO_COMMON | Include the regeneration of C interfaces for `common.proto` file. | On | +| FLUENT_PROTO_RESOURCE | Include the regeneration of C interface for `resource.proto` file. | On | +| FLUENT_PROTO_TRACE | Include the regeneration of C interfaces for `trace.proto` and `trace_service.proto` files. | On | +| FLUENT_PROTO_LOGS | Include the regeneration of C interfaces for `logs.proto` and `logs_service.proto` files. | On | +| FLUENT_PROTO_METRICS | Include the regeneration of C interfaces for `metrics.proto` and `metrics_service.proto` files. | On | +| FLUENT_PROTO_PROFILES | Include the regeneartion of C inter for `profiles.proto` | On | #### 5. Example diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.c index ca13ec4ea02..adaa3df1eac 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.c @@ -185,7 +185,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__collector__logs__v1_ { "partial_success", 1, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Collector__Logs__V1__ExportLogsServiceResponse, partial_success), diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.h index 6779ccdf372..e921607214c 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/logs/v1/logs_service.pb-c.h @@ -9,9 +9,9 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +# error This file was generated by a newer version of protobuf-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005002 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protobuf-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protobuf-c. #endif #include "opentelemetry/proto/logs/v1/logs.pb-c.h" @@ -41,7 +41,7 @@ struct Opentelemetry__Proto__Collector__Logs__V1__ExportLogsServiceRequest }; #define OPENTELEMETRY__PROTO__COLLECTOR__LOGS__V1__EXPORT_LOGS_SERVICE_REQUEST__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__logs__v1__export_logs_service_request__descriptor) \ - , 0,NULL } +, 0,NULL } struct Opentelemetry__Proto__Collector__Logs__V1__ExportLogsServiceResponse @@ -65,7 +65,7 @@ struct Opentelemetry__Proto__Collector__Logs__V1__ExportLogsServiceResponse }; #define OPENTELEMETRY__PROTO__COLLECTOR__LOGS__V1__EXPORT_LOGS_SERVICE_RESPONSE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__logs__v1__export_logs_service_response__descriptor) \ - , NULL } +, NULL } struct Opentelemetry__Proto__Collector__Logs__V1__ExportLogsPartialSuccess @@ -89,7 +89,7 @@ struct Opentelemetry__Proto__Collector__Logs__V1__ExportLogsPartialSuccess }; #define OPENTELEMETRY__PROTO__COLLECTOR__LOGS__V1__EXPORT_LOGS_PARTIAL_SUCCESS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__logs__v1__export_logs_partial_success__descriptor) \ - , 0, (char *)protobuf_c_empty_string } +, 0, (char *)protobuf_c_empty_string } /* Opentelemetry__Proto__Collector__Logs__V1__ExportLogsServiceRequest methods */ diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.c index 5ba05664592..c8eed7cf6f2 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.c @@ -185,7 +185,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__collector__metrics__ { "partial_success", 1, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Collector__Metrics__V1__ExportMetricsServiceResponse, partial_success), diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.h index d6a2b085d8e..057ac5cf3b4 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/metrics/v1/metrics_service.pb-c.h @@ -9,9 +9,9 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +# error This file was generated by a newer version of protobuf-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005002 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protobuf-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protobuf-c. #endif #include "opentelemetry/proto/metrics/v1/metrics.pb-c.h" @@ -41,7 +41,7 @@ struct Opentelemetry__Proto__Collector__Metrics__V1__ExportMetricsServiceReques }; #define OPENTELEMETRY__PROTO__COLLECTOR__METRICS__V1__EXPORT_METRICS_SERVICE_REQUEST__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__metrics__v1__export_metrics_service_request__descriptor) \ - , 0,NULL } +, 0,NULL } struct Opentelemetry__Proto__Collector__Metrics__V1__ExportMetricsServiceResponse @@ -65,7 +65,7 @@ struct Opentelemetry__Proto__Collector__Metrics__V1__ExportMetricsServiceRespon }; #define OPENTELEMETRY__PROTO__COLLECTOR__METRICS__V1__EXPORT_METRICS_SERVICE_RESPONSE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__metrics__v1__export_metrics_service_response__descriptor) \ - , NULL } +, NULL } struct Opentelemetry__Proto__Collector__Metrics__V1__ExportMetricsPartialSuccess @@ -89,7 +89,7 @@ struct Opentelemetry__Proto__Collector__Metrics__V1__ExportMetricsPartialSucces }; #define OPENTELEMETRY__PROTO__COLLECTOR__METRICS__V1__EXPORT_METRICS_PARTIAL_SUCCESS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__metrics__v1__export_metrics_partial_success__descriptor) \ - , 0, (char *)protobuf_c_empty_string } +, 0, (char *)protobuf_c_empty_string } /* Opentelemetry__Proto__Collector__Metrics__V1__ExportMetricsServiceRequest methods */ diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/profiles/v1development/profiles_service.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/profiles/v1development/profiles_service.pb-c.c index 8661e11e59d..66cd57d6421 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/profiles/v1development/profiles_service.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/profiles/v1development/profiles_service.pb-c.c @@ -142,7 +142,7 @@ void opentelemetry__proto__collector__profiles__v1development__export_profiles assert(message->base.descriptor == &opentelemetry__proto__collector__profiles__v1development__export_profiles_partial_success__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } -static const ProtobufCFieldDescriptor opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__field_descriptors[1] = +static const ProtobufCFieldDescriptor opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__field_descriptors[2] = { { "resource_profiles", @@ -156,14 +156,27 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__collector__profiles_ 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "dictionary", + 2, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfilesServiceRequest, dictionary), + &opentelemetry__proto__profiles__v1development__profiles_dictionary__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__field_indices_by_name[] = { + 1, /* field[1] = dictionary */ 0, /* field[0] = resource_profiles */ }; static const ProtobufCIntRange opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 1 } + { 0, 2 } }; const ProtobufCMessageDescriptor opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__descriptor = { @@ -173,7 +186,7 @@ const ProtobufCMessageDescriptor opentelemetry__proto__collector__profiles__v1de "Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfilesServiceRequest", "opentelemetry.proto.collector.profiles.v1development", sizeof(Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfilesServiceRequest), - 1, + 2, opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__field_descriptors, opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__field_indices_by_name, 1, opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__number_ranges, @@ -185,7 +198,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__collector__profiles_ { "partial_success", 1, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfilesServiceResponse, partial_success), diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/profiles/v1development/profiles_service.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/profiles/v1development/profiles_service.pb-c.h index 752afe1deea..a33e9d6c718 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/profiles/v1development/profiles_service.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/profiles/v1development/profiles_service.pb-c.h @@ -9,9 +9,9 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004001 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +# error This file was generated by a newer version of protobuf-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005002 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protobuf-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protobuf-c. #endif #include "opentelemetry/proto/profiles/v1development/profiles.pb-c.h" @@ -38,10 +38,14 @@ struct Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfiles */ size_t n_resource_profiles; Opentelemetry__Proto__Profiles__V1development__ResourceProfiles **resource_profiles; + /* + * The reference table containing all data shared by profiles across the message being sent. + */ + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dictionary; }; #define OPENTELEMETRY__PROTO__COLLECTOR__PROFILES__V1DEVELOPMENT__EXPORT_PROFILES_SERVICE_REQUEST__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__profiles__v1development__export_profiles_service_request__descriptor) \ - , 0,NULL } +, 0,NULL, NULL } struct Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfilesServiceResponse @@ -65,7 +69,7 @@ struct Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfiles }; #define OPENTELEMETRY__PROTO__COLLECTOR__PROFILES__V1DEVELOPMENT__EXPORT_PROFILES_SERVICE_RESPONSE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__profiles__v1development__export_profiles_service_response__descriptor) \ - , NULL } +, NULL } struct Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfilesPartialSuccess @@ -89,7 +93,7 @@ struct Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfiles }; #define OPENTELEMETRY__PROTO__COLLECTOR__PROFILES__V1DEVELOPMENT__EXPORT_PROFILES_PARTIAL_SUCCESS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__profiles__v1development__export_profiles_partial_success__descriptor) \ - , 0, (char *)protobuf_c_empty_string } +, 0, (char *)protobuf_c_empty_string } /* Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfilesServiceRequest methods */ diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.c index e703b9d2537..2833ef298ea 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.c @@ -185,7 +185,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__collector__trace__v1 { "partial_success", 1, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Collector__Trace__V1__ExportTraceServiceResponse, partial_success), diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.h index 094aed6f1b6..d27482908a7 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/collector/trace/v1/trace_service.pb-c.h @@ -9,9 +9,9 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +# error This file was generated by a newer version of protobuf-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005002 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protobuf-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protobuf-c. #endif #include "opentelemetry/proto/trace/v1/trace.pb-c.h" @@ -41,7 +41,7 @@ struct Opentelemetry__Proto__Collector__Trace__V1__ExportTraceServiceRequest }; #define OPENTELEMETRY__PROTO__COLLECTOR__TRACE__V1__EXPORT_TRACE_SERVICE_REQUEST__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__trace__v1__export_trace_service_request__descriptor) \ - , 0,NULL } +, 0,NULL } struct Opentelemetry__Proto__Collector__Trace__V1__ExportTraceServiceResponse @@ -65,7 +65,7 @@ struct Opentelemetry__Proto__Collector__Trace__V1__ExportTraceServiceResponse }; #define OPENTELEMETRY__PROTO__COLLECTOR__TRACE__V1__EXPORT_TRACE_SERVICE_RESPONSE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__trace__v1__export_trace_service_response__descriptor) \ - , NULL } +, NULL } struct Opentelemetry__Proto__Collector__Trace__V1__ExportTracePartialSuccess @@ -89,7 +89,7 @@ struct Opentelemetry__Proto__Collector__Trace__V1__ExportTracePartialSuccess }; #define OPENTELEMETRY__PROTO__COLLECTOR__TRACE__V1__EXPORT_TRACE_PARTIAL_SUCCESS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__collector__trace__v1__export_trace_partial_success__descriptor) \ - , 0, (char *)protobuf_c_empty_string } +, 0, (char *)protobuf_c_empty_string } /* Opentelemetry__Proto__Collector__Trace__V1__ExportTraceServiceRequest methods */ diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.c index 5c5abd9f7d5..fcb79ca08c0 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.c @@ -232,12 +232,57 @@ void opentelemetry__proto__common__v1__instrumentation_scope__free_unpacked assert(message->base.descriptor == &opentelemetry__proto__common__v1__instrumentation_scope__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } +void opentelemetry__proto__common__v1__entity_ref__init + (Opentelemetry__Proto__Common__V1__EntityRef *message) +{ + static const Opentelemetry__Proto__Common__V1__EntityRef init_value = OPENTELEMETRY__PROTO__COMMON__V1__ENTITY_REF__INIT; + *message = init_value; +} +size_t opentelemetry__proto__common__v1__entity_ref__get_packed_size + (const Opentelemetry__Proto__Common__V1__EntityRef *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__common__v1__entity_ref__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__common__v1__entity_ref__pack + (const Opentelemetry__Proto__Common__V1__EntityRef *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__common__v1__entity_ref__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__common__v1__entity_ref__pack_to_buffer + (const Opentelemetry__Proto__Common__V1__EntityRef *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__common__v1__entity_ref__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Common__V1__EntityRef * + opentelemetry__proto__common__v1__entity_ref__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Common__V1__EntityRef *) + protobuf_c_message_unpack (&opentelemetry__proto__common__v1__entity_ref__descriptor, + allocator, len, data); +} +void opentelemetry__proto__common__v1__entity_ref__free_unpacked + (Opentelemetry__Proto__Common__V1__EntityRef *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__common__v1__entity_ref__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_value__field_descriptors[7] = { { "string_value", 1, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, offsetof(Opentelemetry__Proto__Common__V1__AnyValue, value_case), offsetof(Opentelemetry__Proto__Common__V1__AnyValue, string_value), @@ -249,7 +294,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu { "bool_value", 2, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BOOL, offsetof(Opentelemetry__Proto__Common__V1__AnyValue, value_case), offsetof(Opentelemetry__Proto__Common__V1__AnyValue, bool_value), @@ -261,7 +306,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu { "int_value", 3, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_INT64, offsetof(Opentelemetry__Proto__Common__V1__AnyValue, value_case), offsetof(Opentelemetry__Proto__Common__V1__AnyValue, int_value), @@ -273,7 +318,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu { "double_value", 4, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_DOUBLE, offsetof(Opentelemetry__Proto__Common__V1__AnyValue, value_case), offsetof(Opentelemetry__Proto__Common__V1__AnyValue, double_value), @@ -285,7 +330,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu { "array_value", 5, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, offsetof(Opentelemetry__Proto__Common__V1__AnyValue, value_case), offsetof(Opentelemetry__Proto__Common__V1__AnyValue, array_value), @@ -297,7 +342,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu { "kvlist_value", 6, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, offsetof(Opentelemetry__Proto__Common__V1__AnyValue, value_case), offsetof(Opentelemetry__Proto__Common__V1__AnyValue, kvlist_value), @@ -309,7 +354,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__any_valu { "bytes_value", 7, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_BYTES, offsetof(Opentelemetry__Proto__Common__V1__AnyValue, value_case), offsetof(Opentelemetry__Proto__Common__V1__AnyValue, bytes_value), @@ -441,7 +486,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__key_valu { "value", 2, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Common__V1__KeyValue, value), @@ -552,3 +597,80 @@ const ProtobufCMessageDescriptor opentelemetry__proto__common__v1__instrumentati (ProtobufCMessageInit) opentelemetry__proto__common__v1__instrumentation_scope__init, NULL,NULL,NULL /* reserved[123] */ }; +static const ProtobufCFieldDescriptor opentelemetry__proto__common__v1__entity_ref__field_descriptors[4] = +{ + { + "schema_url", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Common__V1__EntityRef, schema_url), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "type", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Common__V1__EntityRef, type), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "id_keys", + 3, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_STRING, + offsetof(Opentelemetry__Proto__Common__V1__EntityRef, n_id_keys), + offsetof(Opentelemetry__Proto__Common__V1__EntityRef, id_keys), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "description_keys", + 4, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_STRING, + offsetof(Opentelemetry__Proto__Common__V1__EntityRef, n_description_keys), + offsetof(Opentelemetry__Proto__Common__V1__EntityRef, description_keys), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__common__v1__entity_ref__field_indices_by_name[] = { + 3, /* field[3] = description_keys */ + 2, /* field[2] = id_keys */ + 0, /* field[0] = schema_url */ + 1, /* field[1] = type */ +}; +static const ProtobufCIntRange opentelemetry__proto__common__v1__entity_ref__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 4 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__common__v1__entity_ref__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.common.v1.EntityRef", + "EntityRef", + "Opentelemetry__Proto__Common__V1__EntityRef", + "opentelemetry.proto.common.v1", + sizeof(Opentelemetry__Proto__Common__V1__EntityRef), + 4, + opentelemetry__proto__common__v1__entity_ref__field_descriptors, + opentelemetry__proto__common__v1__entity_ref__field_indices_by_name, + 1, opentelemetry__proto__common__v1__entity_ref__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__common__v1__entity_ref__init, + NULL,NULL,NULL /* reserved[123] */ +}; diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.h index a8c52626cc9..ac8d04b7fdd 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/common/v1/common.pb-c.h @@ -9,9 +9,9 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +# error This file was generated by a newer version of protobuf-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005002 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protobuf-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protobuf-c. #endif @@ -20,6 +20,7 @@ typedef struct Opentelemetry__Proto__Common__V1__ArrayValue Opentelemetry__Proto typedef struct Opentelemetry__Proto__Common__V1__KeyValueList Opentelemetry__Proto__Common__V1__KeyValueList; typedef struct Opentelemetry__Proto__Common__V1__KeyValue Opentelemetry__Proto__Common__V1__KeyValue; typedef struct Opentelemetry__Proto__Common__V1__InstrumentationScope Opentelemetry__Proto__Common__V1__InstrumentationScope; +typedef struct Opentelemetry__Proto__Common__V1__EntityRef Opentelemetry__Proto__Common__V1__EntityRef; /* --- enums --- */ @@ -40,7 +41,7 @@ typedef enum { } Opentelemetry__Proto__Common__V1__AnyValue__ValueCase; /* - * AnyValue is used to represent any type of attribute value. AnyValue may contain a + * Represents any type of attribute value. AnyValue may contain a * primitive value such as a string or integer or it may contain an arbitrary nested * object containing arrays, key-value lists and primitives. */ @@ -49,18 +50,18 @@ struct Opentelemetry__Proto__Common__V1__AnyValue ProtobufCMessage base; Opentelemetry__Proto__Common__V1__AnyValue__ValueCase value_case; union { - char *string_value; - protobuf_c_boolean bool_value; - int64_t int_value; + ProtobufCBinaryData bytes_value; double double_value; + int64_t int_value; + char *string_value; Opentelemetry__Proto__Common__V1__ArrayValue *array_value; Opentelemetry__Proto__Common__V1__KeyValueList *kvlist_value; - ProtobufCBinaryData bytes_value; + protobuf_c_boolean bool_value; }; }; #define OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__common__v1__any_value__descriptor) \ - , OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE__NOT_SET, {0} } +, OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE__NOT_SET, { {0} } } /* @@ -78,7 +79,7 @@ struct Opentelemetry__Proto__Common__V1__ArrayValue }; #define OPENTELEMETRY__PROTO__COMMON__V1__ARRAY_VALUE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__common__v1__array_value__descriptor) \ - , 0,NULL } +, 0,NULL } /* @@ -96,28 +97,35 @@ struct Opentelemetry__Proto__Common__V1__KeyValueList * contain 0 elements). * The keys MUST be unique (it is not allowed to have more than one * value with the same key). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_values; Opentelemetry__Proto__Common__V1__KeyValue **values; }; #define OPENTELEMETRY__PROTO__COMMON__V1__KEY_VALUE_LIST__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__common__v1__key_value_list__descriptor) \ - , 0,NULL } +, 0,NULL } /* - * KeyValue is a key-value pair that is used to store Span attributes, Link + * Represents a key-value pair that is used to store Span attributes, Link * attributes, etc. */ struct Opentelemetry__Proto__Common__V1__KeyValue { ProtobufCMessage base; + /* + * The key name of the pair. + */ char *key; + /* + * The value of the pair. + */ Opentelemetry__Proto__Common__V1__AnyValue *value; }; #define OPENTELEMETRY__PROTO__COMMON__V1__KEY_VALUE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__common__v1__key_value__descriptor) \ - , (char *)protobuf_c_empty_string, NULL } +, (char *)protobuf_c_empty_string, NULL } /* @@ -128,22 +136,79 @@ struct Opentelemetry__Proto__Common__V1__InstrumentationScope { ProtobufCMessage base; /* + * A name denoting the Instrumentation scope. * An empty instrumentation scope name means the name is unknown. */ char *name; + /* + * Defines the version of the instrumentation scope. + * An empty instrumentation scope version means the version is unknown. + */ char *version; /* * Additional attributes that describe the scope. [Optional]. * Attribute keys MUST be unique (it is not allowed to have more than one * attribute with the same key). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_attributes; Opentelemetry__Proto__Common__V1__KeyValue **attributes; + /* + * 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_t dropped_attributes_count; }; #define OPENTELEMETRY__PROTO__COMMON__V1__INSTRUMENTATION_SCOPE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__common__v1__instrumentation_scope__descriptor) \ - , (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0,NULL, 0 } +, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0,NULL, 0 } + + +/* + * A reference to an Entity. + * Entity represents an object of interest associated with produced telemetry: e.g spans, metrics, profiles, or logs. + * Status: [Development] + */ +struct Opentelemetry__Proto__Common__V1__EntityRef +{ + ProtobufCMessage base; + /* + * The Schema URL, if known. This is the identifier of the Schema that the entity data + * is recorded in. To learn more about Schema URL see + * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url + * This schema_url applies to the data in this message and to the Resource attributes + * referenced by id_keys and description_keys. + * TODO: discuss if we are happy with this somewhat complicated definition of what + * the schema_url applies to. + * This field obsoletes the schema_url field in ResourceMetrics/ResourceSpans/ResourceLogs. + */ + char *schema_url; + /* + * Defines the type of the entity. MUST not change during the lifetime of the entity. + * For example: "service" or "host". This field is required and MUST not be empty + * for valid entities. + */ + char *type; + /* + * Attribute Keys that identify the entity. + * MUST not change during the lifetime of the entity. The Id must contain at least one attribute. + * These keys MUST exist in the containing {message}.attributes. + */ + size_t n_id_keys; + char **id_keys; + /* + * Descriptive (non-identifying) attribute keys of the entity. + * MAY change over the lifetime of the entity. MAY be empty. + * These attribute keys are not part of entity's identity. + * These keys MUST exist in the containing {message}.attributes. + */ + size_t n_description_keys; + char **description_keys; +}; +#define OPENTELEMETRY__PROTO__COMMON__V1__ENTITY_REF__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__common__v1__entity_ref__descriptor) \ +, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0,NULL, 0,NULL } /* Opentelemetry__Proto__Common__V1__AnyValue methods */ @@ -241,6 +306,25 @@ Opentelemetry__Proto__Common__V1__InstrumentationScope * void opentelemetry__proto__common__v1__instrumentation_scope__free_unpacked (Opentelemetry__Proto__Common__V1__InstrumentationScope *message, ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Common__V1__EntityRef methods */ +void opentelemetry__proto__common__v1__entity_ref__init + (Opentelemetry__Proto__Common__V1__EntityRef *message); +size_t opentelemetry__proto__common__v1__entity_ref__get_packed_size + (const Opentelemetry__Proto__Common__V1__EntityRef *message); +size_t opentelemetry__proto__common__v1__entity_ref__pack + (const Opentelemetry__Proto__Common__V1__EntityRef *message, + uint8_t *out); +size_t opentelemetry__proto__common__v1__entity_ref__pack_to_buffer + (const Opentelemetry__Proto__Common__V1__EntityRef *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Common__V1__EntityRef * + opentelemetry__proto__common__v1__entity_ref__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__common__v1__entity_ref__free_unpacked + (Opentelemetry__Proto__Common__V1__EntityRef *message, + ProtobufCAllocator *allocator); /* --- per-message closures --- */ typedef void (*Opentelemetry__Proto__Common__V1__AnyValue_Closure) @@ -258,6 +342,9 @@ typedef void (*Opentelemetry__Proto__Common__V1__KeyValue_Closure) typedef void (*Opentelemetry__Proto__Common__V1__InstrumentationScope_Closure) (const Opentelemetry__Proto__Common__V1__InstrumentationScope *message, void *closure_data); +typedef void (*Opentelemetry__Proto__Common__V1__EntityRef_Closure) + (const Opentelemetry__Proto__Common__V1__EntityRef *message, + void *closure_data); /* --- services --- */ @@ -269,6 +356,7 @@ extern const ProtobufCMessageDescriptor opentelemetry__proto__common__v1__array_ extern const ProtobufCMessageDescriptor opentelemetry__proto__common__v1__key_value_list__descriptor; extern const ProtobufCMessageDescriptor opentelemetry__proto__common__v1__key_value__descriptor; extern const ProtobufCMessageDescriptor opentelemetry__proto__common__v1__instrumentation_scope__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__common__v1__entity_ref__descriptor; PROTOBUF_C__END_DECLS diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.c index 9ecfa356ac3..19ee76819e3 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.c @@ -230,7 +230,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__logs__v1__resource_l { "resource", 1, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Logs__V1__ResourceLogs, resource), @@ -294,7 +294,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__logs__v1__scope_logs { "scope", 1, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Logs__V1__ScopeLogs, scope), @@ -353,7 +353,7 @@ const ProtobufCMessageDescriptor opentelemetry__proto__logs__v1__scope_logs__des (ProtobufCMessageInit) opentelemetry__proto__logs__v1__scope_logs__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor opentelemetry__proto__logs__v1__log_record__field_descriptors[10] = +static const ProtobufCFieldDescriptor opentelemetry__proto__logs__v1__log_record__field_descriptors[11] = { { "time_unix_nano", @@ -394,7 +394,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__logs__v1__log_record { "body", 5, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Logs__V1__LogRecord, body), @@ -475,11 +475,24 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__logs__v1__log_record 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "event_name", + 12, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Logs__V1__LogRecord, event_name), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned opentelemetry__proto__logs__v1__log_record__field_indices_by_name[] = { 4, /* field[4] = attributes */ 3, /* field[3] = body */ 5, /* field[5] = dropped_attributes_count */ + 10, /* field[10] = event_name */ 6, /* field[6] = flags */ 9, /* field[9] = observed_time_unix_nano */ 1, /* field[1] = severity_number */ @@ -492,7 +505,7 @@ static const ProtobufCIntRange opentelemetry__proto__logs__v1__log_record__numbe { { 1, 0 }, { 5, 3 }, - { 0, 10 } + { 0, 11 } }; const ProtobufCMessageDescriptor opentelemetry__proto__logs__v1__log_record__descriptor = { @@ -502,7 +515,7 @@ const ProtobufCMessageDescriptor opentelemetry__proto__logs__v1__log_record__des "Opentelemetry__Proto__Logs__V1__LogRecord", "opentelemetry.proto.logs.v1", sizeof(Opentelemetry__Proto__Logs__V1__LogRecord), - 10, + 11, opentelemetry__proto__logs__v1__log_record__field_descriptors, opentelemetry__proto__logs__v1__log_record__field_indices_by_name, 2, opentelemetry__proto__logs__v1__log_record__number_ranges, diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.h index ea7f00fc125..aacf998e911 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/logs/v1/logs.pb-c.h @@ -9,9 +9,9 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +# error This file was generated by a newer version of protobuf-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005002 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protobuf-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protobuf-c. #endif #include "opentelemetry/proto/common/v1/common.pb-c.h" @@ -107,7 +107,7 @@ struct Opentelemetry__Proto__Logs__V1__LogsData }; #define OPENTELEMETRY__PROTO__LOGS__V1__LOGS_DATA__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__logs__v1__logs_data__descriptor) \ - , 0,NULL } +, 0,NULL } /* @@ -128,7 +128,8 @@ struct Opentelemetry__Proto__Logs__V1__ResourceLogs Opentelemetry__Proto__Logs__V1__ScopeLogs **scope_logs; /* * The Schema URL, if known. This is the identifier of the Schema that the resource data - * is recorded in. To learn more about Schema URL see + * is recorded in. Notably, the last part of the URL path is the version number of the + * schema: http[s]://server[:port]/path/. To learn more about Schema URL see * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url * This schema_url applies to the data in the "resource" field. It does not apply * to the data in the "scope_logs" field which have their own schema_url field. @@ -137,7 +138,7 @@ struct Opentelemetry__Proto__Logs__V1__ResourceLogs }; #define OPENTELEMETRY__PROTO__LOGS__V1__RESOURCE_LOGS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__logs__v1__resource_logs__descriptor) \ - , NULL, 0,NULL, (char *)protobuf_c_empty_string } +, NULL, 0,NULL, (char *)protobuf_c_empty_string } /* @@ -159,15 +160,17 @@ struct Opentelemetry__Proto__Logs__V1__ScopeLogs Opentelemetry__Proto__Logs__V1__LogRecord **log_records; /* * The Schema URL, if known. This is the identifier of the Schema that the log data - * is recorded in. To learn more about Schema URL see + * is recorded in. Notably, the last part of the URL path is the version number of the + * schema: http[s]://server[:port]/path/. To learn more about Schema URL see * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - * This schema_url applies to all logs in the "logs" field. + * This schema_url applies to the data in the "scope" field and all logs in the + * "log_records" field. */ char *schema_url; }; #define OPENTELEMETRY__PROTO__LOGS__V1__SCOPE_LOGS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__logs__v1__scope_logs__descriptor) \ - , NULL, 0,NULL, (char *)protobuf_c_empty_string } +, NULL, 0,NULL, (char *)protobuf_c_empty_string } /* @@ -219,6 +222,7 @@ struct Opentelemetry__Proto__Logs__V1__LogRecord * Additional attributes that describe the specific event occurrence. [Optional]. * Attribute keys MUST be unique (it is not allowed to have more than one * attribute with the same key). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_attributes; Opentelemetry__Proto__Common__V1__KeyValue **attributes; @@ -256,10 +260,20 @@ struct Opentelemetry__Proto__Logs__V1__LogRecord * - the field contains an invalid value. */ ProtobufCBinaryData span_id; + /* + * A unique identifier of event category/type. + * All events with the same event_name are expected to conform to the same + * schema for both their attributes and their body. + * Recommended to be fully qualified and short (no longer than 256 characters). + * Presence of event_name on the log record identifies this record + * as an event. + * [Optional]. + */ + char *event_name; }; #define OPENTELEMETRY__PROTO__LOGS__V1__LOG_RECORD__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__logs__v1__log_record__descriptor) \ - , 0, 0, OPENTELEMETRY__PROTO__LOGS__V1__SEVERITY_NUMBER__SEVERITY_NUMBER_UNSPECIFIED, (char *)protobuf_c_empty_string, NULL, 0,NULL, 0, 0, {0,NULL}, {0,NULL} } +, 0, 0, OPENTELEMETRY__PROTO__LOGS__V1__SEVERITY_NUMBER__SEVERITY_NUMBER_UNSPECIFIED, (char *)protobuf_c_empty_string, NULL, 0,NULL, 0, 0, {0,NULL}, {0,NULL}, (char *)protobuf_c_empty_string } /* Opentelemetry__Proto__Logs__V1__LogsData methods */ diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.c index 31671477da8..00f0443cdc5 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.c @@ -692,7 +692,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__resourc { "resource", 1, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Metrics__V1__ResourceMetrics, resource), @@ -756,7 +756,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__scope_m { "scope", 1, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Metrics__V1__ScopeMetrics, scope), @@ -856,7 +856,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric_ { "gauge", 5, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, offsetof(Opentelemetry__Proto__Metrics__V1__Metric, data_case), offsetof(Opentelemetry__Proto__Metrics__V1__Metric, gauge), @@ -868,7 +868,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric_ { "sum", 7, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, offsetof(Opentelemetry__Proto__Metrics__V1__Metric, data_case), offsetof(Opentelemetry__Proto__Metrics__V1__Metric, sum), @@ -880,7 +880,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric_ { "histogram", 9, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, offsetof(Opentelemetry__Proto__Metrics__V1__Metric, data_case), offsetof(Opentelemetry__Proto__Metrics__V1__Metric, histogram), @@ -892,7 +892,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric_ { "exponential_histogram", 10, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, offsetof(Opentelemetry__Proto__Metrics__V1__Metric, data_case), offsetof(Opentelemetry__Proto__Metrics__V1__Metric, exponential_histogram), @@ -904,7 +904,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__metric_ { "summary", 11, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, offsetof(Opentelemetry__Proto__Metrics__V1__Metric, data_case), offsetof(Opentelemetry__Proto__Metrics__V1__Metric, summary), @@ -1231,7 +1231,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__number_ { "as_double", 4, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_DOUBLE, offsetof(Opentelemetry__Proto__Metrics__V1__NumberDataPoint, value_case), offsetof(Opentelemetry__Proto__Metrics__V1__NumberDataPoint, as_double), @@ -1255,7 +1255,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__number_ { "as_int", 6, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_SFIXED64, offsetof(Opentelemetry__Proto__Metrics__V1__NumberDataPoint, value_case), offsetof(Opentelemetry__Proto__Metrics__V1__NumberDataPoint, as_int), @@ -1359,13 +1359,13 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__histogr { "sum", 5, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_DOUBLE, - offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, _sum_case), + offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, has_sum), offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, sum), NULL, NULL, - PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1431,25 +1431,25 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__histogr { "min", 11, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_DOUBLE, - offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, _min_case), + offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, has_min), offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, min), NULL, NULL, - PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { "max", 12, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_DOUBLE, - offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, _max_case), + offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, has_max), offsetof(Opentelemetry__Proto__Metrics__V1__HistogramDataPoint, max), NULL, NULL, - PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -1590,13 +1590,13 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exponen { "sum", 5, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_DOUBLE, - offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, _sum_case), + offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, has_sum), offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, sum), NULL, NULL, - PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1626,7 +1626,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exponen { "positive", 8, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, positive), @@ -1638,7 +1638,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exponen { "negative", 9, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, negative), @@ -1674,25 +1674,25 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exponen { "min", 12, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_DOUBLE, - offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, _min_case), + offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, has_min), offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, min), NULL, NULL, - PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { "max", 13, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_DOUBLE, - offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, _max_case), + offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, has_max), offsetof(Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint, max), NULL, NULL, - PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */ + 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -1928,7 +1928,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exempla { "as_double", 3, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_DOUBLE, offsetof(Opentelemetry__Proto__Metrics__V1__Exemplar, value_case), offsetof(Opentelemetry__Proto__Metrics__V1__Exemplar, as_double), @@ -1964,7 +1964,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__metrics__v1__exempla { "as_int", 6, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_SFIXED64, offsetof(Opentelemetry__Proto__Metrics__V1__Exemplar, value_case), offsetof(Opentelemetry__Proto__Metrics__V1__Exemplar, as_int), diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.h index 51de5389b0d..8514c57c0a3 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/metrics/v1/metrics.pb-c.h @@ -9,9 +9,9 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +# error This file was generated by a newer version of protobuf-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005002 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protobuf-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protobuf-c. #endif #include "opentelemetry/proto/common/v1/common.pb-c.h" @@ -174,7 +174,7 @@ struct Opentelemetry__Proto__Metrics__V1__MetricsData }; #define OPENTELEMETRY__PROTO__METRICS__V1__METRICS_DATA__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__metrics_data__descriptor) \ - , 0,NULL } +, 0,NULL } /* @@ -195,7 +195,8 @@ struct Opentelemetry__Proto__Metrics__V1__ResourceMetrics Opentelemetry__Proto__Metrics__V1__ScopeMetrics **scope_metrics; /* * The Schema URL, if known. This is the identifier of the Schema that the resource data - * is recorded in. To learn more about Schema URL see + * is recorded in. Notably, the last part of the URL path is the version number of the + * schema: http[s]://server[:port]/path/. To learn more about Schema URL see * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url * This schema_url applies to the data in the "resource" field. It does not apply * to the data in the "scope_metrics" field which have their own schema_url field. @@ -204,7 +205,7 @@ struct Opentelemetry__Proto__Metrics__V1__ResourceMetrics }; #define OPENTELEMETRY__PROTO__METRICS__V1__RESOURCE_METRICS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__resource_metrics__descriptor) \ - , NULL, 0,NULL, (char *)protobuf_c_empty_string } +, NULL, 0,NULL, (char *)protobuf_c_empty_string } /* @@ -226,15 +227,17 @@ struct Opentelemetry__Proto__Metrics__V1__ScopeMetrics Opentelemetry__Proto__Metrics__V1__Metric **metrics; /* * The Schema URL, if known. This is the identifier of the Schema that the metric data - * is recorded in. To learn more about Schema URL see + * is recorded in. Notably, the last part of the URL path is the version number of the + * schema: http[s]://server[:port]/path/. To learn more about Schema URL see * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - * This schema_url applies to all metrics in the "metrics" field. + * This schema_url applies to the data in the "scope" field and all metrics in the + * "metrics" field. */ char *schema_url; }; #define OPENTELEMETRY__PROTO__METRICS__V1__SCOPE_METRICS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__scope_metrics__descriptor) \ - , NULL, 0,NULL, (char *)protobuf_c_empty_string } +, NULL, 0,NULL, (char *)protobuf_c_empty_string } typedef enum { @@ -324,16 +327,16 @@ struct Opentelemetry__Proto__Metrics__V1__Metric { ProtobufCMessage base; /* - * name of the metric. + * The name of the metric. */ char *name; /* - * description of the metric, which can be used in documentation. + * A description of the metric, which can be used in documentation. */ char *description; /* - * unit in which the metric value is reported. Follows the format - * described by http://unitsofmeasure.org/ucum.html. + * The unit in which the metric value is reported. Follows the format + * described by https://unitsofmeasure.org/ucum.html. */ char *unit; /* @@ -344,21 +347,22 @@ struct Opentelemetry__Proto__Metrics__V1__Metric * for lossless roundtrip translation to / from another data model. * Attribute keys MUST be unique (it is not allowed to have more than one * attribute with the same key). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_metadata; Opentelemetry__Proto__Common__V1__KeyValue **metadata; Opentelemetry__Proto__Metrics__V1__Metric__DataCase data_case; union { + Opentelemetry__Proto__Metrics__V1__ExponentialHistogram *exponential_histogram; Opentelemetry__Proto__Metrics__V1__Gauge *gauge; - Opentelemetry__Proto__Metrics__V1__Sum *sum; Opentelemetry__Proto__Metrics__V1__Histogram *histogram; - Opentelemetry__Proto__Metrics__V1__ExponentialHistogram *exponential_histogram; + Opentelemetry__Proto__Metrics__V1__Sum *sum; Opentelemetry__Proto__Metrics__V1__Summary *summary; }; }; #define OPENTELEMETRY__PROTO__METRICS__V1__METRIC__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__metric__descriptor) \ - , (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0,NULL, OPENTELEMETRY__PROTO__METRICS__V1__METRIC__DATA__NOT_SET, {0} } +, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, (char *)protobuf_c_empty_string, 0,NULL, OPENTELEMETRY__PROTO__METRICS__V1__METRIC__DATA__NOT_SET, {0} } /* @@ -374,12 +378,16 @@ struct Opentelemetry__Proto__Metrics__V1__Metric struct Opentelemetry__Proto__Metrics__V1__Gauge { ProtobufCMessage base; + /* + * The time series data points. + * Note: Multiple time series may be included (same timestamp, different attributes). + */ size_t n_data_points; Opentelemetry__Proto__Metrics__V1__NumberDataPoint **data_points; }; #define OPENTELEMETRY__PROTO__METRICS__V1__GAUGE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__gauge__descriptor) \ - , 0,NULL } +, 0,NULL } /* @@ -389,6 +397,10 @@ struct Opentelemetry__Proto__Metrics__V1__Gauge struct Opentelemetry__Proto__Metrics__V1__Sum { ProtobufCMessage base; + /* + * The time series data points. + * Note: Multiple time series may be included (same timestamp, different attributes). + */ size_t n_data_points; Opentelemetry__Proto__Metrics__V1__NumberDataPoint **data_points; /* @@ -397,13 +409,13 @@ struct Opentelemetry__Proto__Metrics__V1__Sum */ Opentelemetry__Proto__Metrics__V1__AggregationTemporality aggregation_temporality; /* - * If "true" means that the sum is monotonic. + * Represents whether the sum is monotonic. */ protobuf_c_boolean is_monotonic; }; #define OPENTELEMETRY__PROTO__METRICS__V1__SUM__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__sum__descriptor) \ - , 0,NULL, OPENTELEMETRY__PROTO__METRICS__V1__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_UNSPECIFIED, 0 } +, 0,NULL, OPENTELEMETRY__PROTO__METRICS__V1__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_UNSPECIFIED, 0 } /* @@ -413,6 +425,10 @@ struct Opentelemetry__Proto__Metrics__V1__Sum struct Opentelemetry__Proto__Metrics__V1__Histogram { ProtobufCMessage base; + /* + * The time series data points. + * Note: Multiple time series may be included (same timestamp, different attributes). + */ size_t n_data_points; Opentelemetry__Proto__Metrics__V1__HistogramDataPoint **data_points; /* @@ -423,7 +439,7 @@ struct Opentelemetry__Proto__Metrics__V1__Histogram }; #define OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__histogram__descriptor) \ - , 0,NULL, OPENTELEMETRY__PROTO__METRICS__V1__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_UNSPECIFIED } +, 0,NULL, OPENTELEMETRY__PROTO__METRICS__V1__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_UNSPECIFIED } /* @@ -433,6 +449,10 @@ struct Opentelemetry__Proto__Metrics__V1__Histogram struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogram { ProtobufCMessage base; + /* + * The time series data points. + * Note: Multiple time series may be included (same timestamp, different attributes). + */ size_t n_data_points; Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint **data_points; /* @@ -443,13 +463,13 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogram }; #define OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__exponential_histogram__descriptor) \ - , 0,NULL, OPENTELEMETRY__PROTO__METRICS__V1__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_UNSPECIFIED } +, 0,NULL, OPENTELEMETRY__PROTO__METRICS__V1__AGGREGATION_TEMPORALITY__AGGREGATION_TEMPORALITY_UNSPECIFIED } /* * Summary metric data are used to convey quantile summaries, * a Prometheus (see: https://prometheus.io/docs/concepts/metric_types/#summary) - * and OpenMetrics (see: https://github.com/OpenObservability/OpenMetrics/blob/4dbf6075567ab43296eed941037c12951faafb92/protos/prometheus.proto#L45) + * and OpenMetrics (see: https://github.com/prometheus/OpenMetrics/blob/4dbf6075567ab43296eed941037c12951faafb92/protos/prometheus.proto#L45) * data type. These data points cannot always be merged in a meaningful way. * While they can be useful in some applications, histogram data points are * recommended for new applications. @@ -460,12 +480,16 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogram struct Opentelemetry__Proto__Metrics__V1__Summary { ProtobufCMessage base; + /* + * The time series data points. + * Note: Multiple time series may be included (same timestamp, different attributes). + */ size_t n_data_points; Opentelemetry__Proto__Metrics__V1__SummaryDataPoint **data_points; }; #define OPENTELEMETRY__PROTO__METRICS__V1__SUMMARY__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__summary__descriptor) \ - , 0,NULL } +, 0,NULL } typedef enum { @@ -487,6 +511,7 @@ struct Opentelemetry__Proto__Metrics__V1__NumberDataPoint * where this point belongs. The list may be empty (may contain 0 elements). * Attribute keys MUST be unique (it is not allowed to have more than one * attribute with the same key). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_attributes; Opentelemetry__Proto__Common__V1__KeyValue **attributes; @@ -522,26 +547,8 @@ struct Opentelemetry__Proto__Metrics__V1__NumberDataPoint }; #define OPENTELEMETRY__PROTO__METRICS__V1__NUMBER_DATA_POINT__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__number_data_point__descriptor) \ - , 0,NULL, 0, 0, 0,NULL, 0, OPENTELEMETRY__PROTO__METRICS__V1__NUMBER_DATA_POINT__VALUE__NOT_SET, {0} } - - -typedef enum { - OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___SUM__NOT_SET = 0, - OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___SUM_SUM = 5 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___SUM__CASE) -} Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__SumCase; - -typedef enum { - OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MIN__NOT_SET = 0, - OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MIN_MIN = 11 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MIN__CASE) -} Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__MinCase; +, 0,NULL, 0, 0, 0,NULL, 0, OPENTELEMETRY__PROTO__METRICS__V1__NUMBER_DATA_POINT__VALUE__NOT_SET, {0} } -typedef enum { - OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MAX__NOT_SET = 0, - OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MAX_MAX = 12 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MAX__CASE) -} Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__MaxCase; /* * HistogramDataPoint is a single data point in a timeseries that describes the @@ -562,6 +569,7 @@ struct Opentelemetry__Proto__Metrics__V1__HistogramDataPoint * where this point belongs. The list may be empty (may contain 0 elements). * Attribute keys MUST be unique (it is not allowed to have more than one * attribute with the same key). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_attributes; Opentelemetry__Proto__Common__V1__KeyValue **attributes; @@ -584,12 +592,25 @@ struct Opentelemetry__Proto__Metrics__V1__HistogramDataPoint * histogram is provided. */ uint64_t count; + /* + * sum of the values in the population. If count is zero then this field + * must be zero. + * Note: Sum should only be filled out when measuring non-negative discrete + * events, and is assumed to be monotonic over the values of these events. + * Negative events *can* be recorded, but sum should not be filled out when + * doing so. This is specifically to enforce compatibility w/ OpenMetrics, + * see: https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#histogram + */ + protobuf_c_boolean has_sum; + double sum; /* * bucket_counts is an optional field contains the count values of histogram * for each bucket. * The sum of the bucket_counts must equal the value in the count field. * The number of elements in bucket_counts array must be by one greater than - * the number of elements in explicit_bounds array. + * the number of elements in explicit_bounds array. The exception to this rule + * is when the length of bucket_counts is 0, then the length of explicit_bounds + * must also be 0. */ size_t n_bucket_counts; uint64_t *bucket_counts; @@ -603,6 +624,8 @@ struct Opentelemetry__Proto__Metrics__V1__HistogramDataPoint * Histogram buckets are inclusive of their upper boundary, except the last * bucket where the boundary is at infinity. This format is intentionally * compatible with the OpenMetrics histogram definition. + * If bucket_counts length is 0 then explicit_bounds length must also be 0, + * otherwise the data point is invalid. */ size_t n_explicit_bounds; double *explicit_bounds; @@ -617,37 +640,20 @@ struct Opentelemetry__Proto__Metrics__V1__HistogramDataPoint * for the available flags and their meaning. */ uint32_t flags; - Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__SumCase _sum_case; - union { - /* - * sum of the values in the population. If count is zero then this field - * must be zero. - * Note: Sum should only be filled out when measuring non-negative discrete - * events, and is assumed to be monotonic over the values of these events. - * Negative events *can* be recorded, but sum should not be filled out when - * doing so. This is specifically to enforce compatibility w/ OpenMetrics, - * see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram - */ - double sum; - }; - Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__MinCase _min_case; - union { - /* - * min is the minimum value over (start_time, end_time]. - */ - double min; - }; - Opentelemetry__Proto__Metrics__V1__HistogramDataPoint__MaxCase _max_case; - union { - /* - * max is the maximum value over (start_time, end_time]. - */ - double max; - }; + /* + * min is the minimum value over (start_time, end_time]. + */ + protobuf_c_boolean has_min; + double min; + /* + * max is the maximum value over (start_time, end_time]. + */ + protobuf_c_boolean has_max; + double max; }; #define OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__histogram_data_point__descriptor) \ - , 0,NULL, 0, 0, 0, 0,NULL, 0,NULL, 0,NULL, 0, OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___SUM__NOT_SET, {0}, OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MIN__NOT_SET, {0}, OPENTELEMETRY__PROTO__METRICS__V1__HISTOGRAM_DATA_POINT___MAX__NOT_SET, {0} } +, 0,NULL, 0, 0, 0, 0, 0, 0,NULL, 0,NULL, 0,NULL, 0, 0, 0, 0, 0 } /* @@ -658,13 +664,12 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__Bucket { ProtobufCMessage base; /* - * Offset is the bucket index of the first entry in the bucket_counts array. - * + * The bucket index of the first entry in the bucket_counts array. * Note: This uses a varint encoding as a simple form of compression. */ int32_t offset; /* - * bucket_counts is an array of count values, where bucket_counts[i] carries + * An array of count values, where bucket_counts[i] carries * the count of the bucket at index (offset+i). bucket_counts[i] is the count * of values greater than base^(offset+i) and less than or equal to * base^(offset+i+1). @@ -678,26 +683,8 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__Bucket }; #define OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT__BUCKETS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__exponential_histogram_data_point__buckets__descriptor) \ - , 0, 0,NULL } - +, 0, 0,NULL } -typedef enum { - OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___SUM__NOT_SET = 0, - OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___SUM_SUM = 5 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___SUM__CASE) -} Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__SumCase; - -typedef enum { - OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MIN__NOT_SET = 0, - OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MIN_MIN = 12 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MIN__CASE) -} Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__MinCase; - -typedef enum { - OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MAX__NOT_SET = 0, - OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MAX_MAX = 13 - PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MAX__CASE) -} Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__MaxCase; /* * ExponentialHistogramDataPoint is a single data point in a timeseries that describes the @@ -713,6 +700,7 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint * where this point belongs. The list may be empty (may contain 0 elements). * Attribute keys MUST be unique (it is not allowed to have more than one * attribute with the same key). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_attributes; Opentelemetry__Proto__Common__V1__KeyValue **attributes; @@ -730,11 +718,22 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint */ uint64_t time_unix_nano; /* - * count is the number of values in the population. Must be + * The number of values in the population. Must be * non-negative. This value must be equal to the sum of the "bucket_counts" * values in the positive and negative Buckets plus the "zero_count" field. */ uint64_t count; + /* + * The sum of the values in the population. If count is zero then this field + * must be zero. + * Note: Sum should only be filled out when measuring non-negative discrete + * events, and is assumed to be monotonic over the values of these events. + * Negative events *can* be recorded, but sum should not be filled out when + * doing so. This is specifically to enforce compatibility w/ OpenMetrics, + * see: https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#histogram + */ + protobuf_c_boolean has_sum; + double sum; /* * scale describes the resolution of the histogram. Boundaries are * located at powers of the base, where: @@ -750,7 +749,7 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint */ int32_t scale; /* - * zero_count is the count of values that are either exactly zero or + * The count of values that are either exactly zero or * within the region considered zero by the instrumentation at the * tolerated degree of precision. This bucket stores values that * cannot be expressed using the standard exponential formula as @@ -778,6 +777,16 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint */ size_t n_exemplars; Opentelemetry__Proto__Metrics__V1__Exemplar **exemplars; + /* + * The minimum value over (start_time, end_time]. + */ + protobuf_c_boolean has_min; + double min; + /* + * The maximum value over (start_time, end_time]. + */ + protobuf_c_boolean has_max; + double max; /* * ZeroThreshold may be optionally set to convey the width of the zero * region. Where the zero region is defined as the closed interval @@ -787,37 +796,10 @@ struct Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint * have been rounded to zero. */ double zero_threshold; - Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__SumCase _sum_case; - union { - /* - * sum of the values in the population. If count is zero then this field - * must be zero. - * Note: Sum should only be filled out when measuring non-negative discrete - * events, and is assumed to be monotonic over the values of these events. - * Negative events *can* be recorded, but sum should not be filled out when - * doing so. This is specifically to enforce compatibility w/ OpenMetrics, - * see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram - */ - double sum; - }; - Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__MinCase _min_case; - union { - /* - * min is the minimum value over (start_time, end_time]. - */ - double min; - }; - Opentelemetry__Proto__Metrics__V1__ExponentialHistogramDataPoint__MaxCase _max_case; - union { - /* - * max is the maximum value over (start_time, end_time]. - */ - double max; - }; }; #define OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__exponential_histogram_data_point__descriptor) \ - , 0,NULL, 0, 0, 0, 0, 0, NULL, NULL, 0, 0,NULL, 0, OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___SUM__NOT_SET, {0}, OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MIN__NOT_SET, {0}, OPENTELEMETRY__PROTO__METRICS__V1__EXPONENTIAL_HISTOGRAM_DATA_POINT___MAX__NOT_SET, {0} } +, 0,NULL, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0,NULL, 0, 0, 0, 0, 0 } /* @@ -844,7 +826,7 @@ struct Opentelemetry__Proto__Metrics__V1__SummaryDataPoint__ValueAtQuantile }; #define OPENTELEMETRY__PROTO__METRICS__V1__SUMMARY_DATA_POINT__VALUE_AT_QUANTILE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__summary_data_point__value_at_quantile__descriptor) \ - , 0, 0 } +, 0, 0 } /* @@ -860,6 +842,7 @@ struct Opentelemetry__Proto__Metrics__V1__SummaryDataPoint * where this point belongs. The list may be empty (may contain 0 elements). * Attribute keys MUST be unique (it is not allowed to have more than one * attribute with the same key). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_attributes; Opentelemetry__Proto__Common__V1__KeyValue **attributes; @@ -887,7 +870,7 @@ struct Opentelemetry__Proto__Metrics__V1__SummaryDataPoint * events, and is assumed to be monotonic over the values of these events. * Negative events *can* be recorded, but sum should not be filled out when * doing so. This is specifically to enforce compatibility w/ OpenMetrics, - * see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#summary + * see: https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#summary */ double sum; /* @@ -904,7 +887,7 @@ struct Opentelemetry__Proto__Metrics__V1__SummaryDataPoint }; #define OPENTELEMETRY__PROTO__METRICS__V1__SUMMARY_DATA_POINT__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__summary_data_point__descriptor) \ - , 0,NULL, 0, 0, 0, 0, 0,NULL, 0 } +, 0,NULL, 0, 0, 0, 0, 0,NULL, 0 } typedef enum { @@ -956,7 +939,7 @@ struct Opentelemetry__Proto__Metrics__V1__Exemplar }; #define OPENTELEMETRY__PROTO__METRICS__V1__EXEMPLAR__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__metrics__v1__exemplar__descriptor) \ - , 0,NULL, 0, {0,NULL}, {0,NULL}, OPENTELEMETRY__PROTO__METRICS__V1__EXEMPLAR__VALUE__NOT_SET, {0} } +, 0,NULL, 0, {0,NULL}, {0,NULL}, OPENTELEMETRY__PROTO__METRICS__V1__EXEMPLAR__VALUE__NOT_SET, {0} } /* Opentelemetry__Proto__Metrics__V1__MetricsData methods */ diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.c index 1af8619d953..683c9465c11 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.c @@ -7,6 +7,51 @@ #endif #include "opentelemetry/proto/profiles/v1development/profiles.pb-c.h" +void opentelemetry__proto__profiles__v1development__profiles_dictionary__init + (Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILES_DICTIONARY__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__profiles_dictionary__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profiles_dictionary__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__profiles_dictionary__pack + (const Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profiles_dictionary__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__profiles_dictionary__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profiles_dictionary__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary * + opentelemetry__proto__profiles__v1development__profiles_dictionary__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__profiles_dictionary__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__profiles_dictionary__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profiles_dictionary__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} void opentelemetry__proto__profiles__v1development__profiles_data__init (Opentelemetry__Proto__Profiles__V1development__ProfilesData *message) { @@ -142,343 +187,1518 @@ void opentelemetry__proto__profiles__v1development__scope_profiles__free_unpac assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__scope_profiles__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } -void opentelemetry__proto__profiles__v1development__profile_container__init - (Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message) +void opentelemetry__proto__profiles__v1development__profile__init + (Opentelemetry__Proto__Profiles__V1development__Profile *message) { - static const Opentelemetry__Proto__Profiles__V1development__ProfileContainer init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILE_CONTAINER__INIT; + static const Opentelemetry__Proto__Profiles__V1development__Profile init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILE__INIT; *message = init_value; } -size_t opentelemetry__proto__profiles__v1development__profile_container__get_packed_size - (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message) +size_t opentelemetry__proto__profiles__v1development__profile__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Profile *message) { - assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile_container__descriptor); + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile__descriptor); return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); } -size_t opentelemetry__proto__profiles__v1development__profile_container__pack - (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, +size_t opentelemetry__proto__profiles__v1development__profile__pack + (const Opentelemetry__Proto__Profiles__V1development__Profile *message, uint8_t *out) { - assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile_container__descriptor); + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile__descriptor); return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); } -size_t opentelemetry__proto__profiles__v1development__profile_container__pack_to_buffer - (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, +size_t opentelemetry__proto__profiles__v1development__profile__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Profile *message, ProtobufCBuffer *buffer) { - assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile_container__descriptor); + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile__descriptor); return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); } -Opentelemetry__Proto__Profiles__V1development__ProfileContainer * - opentelemetry__proto__profiles__v1development__profile_container__unpack +Opentelemetry__Proto__Profiles__V1development__Profile * + opentelemetry__proto__profiles__v1development__profile__unpack (ProtobufCAllocator *allocator, size_t len, const uint8_t *data) { - return (Opentelemetry__Proto__Profiles__V1development__ProfileContainer *) - protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__profile_container__descriptor, + return (Opentelemetry__Proto__Profiles__V1development__Profile *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__profile__descriptor, allocator, len, data); } -void opentelemetry__proto__profiles__v1development__profile_container__free_unpacked - (Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, +void opentelemetry__proto__profiles__v1development__profile__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Profile *message, ProtobufCAllocator *allocator) { if(!message) return; - assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile_container__descriptor); + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__profile__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } -static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__profiles_data__field_descriptors[1] = +void opentelemetry__proto__profiles__v1development__link__init + (Opentelemetry__Proto__Profiles__V1development__Link *message) { - { - "resource_profiles", - 1, - PROTOBUF_C_LABEL_REPEATED, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesData, n_resource_profiles), - offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesData, resource_profiles), - &opentelemetry__proto__profiles__v1development__resource_profiles__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned opentelemetry__proto__profiles__v1development__profiles_data__field_indices_by_name[] = { - 0, /* field[0] = resource_profiles */ -}; -static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__profiles_data__number_ranges[1 + 1] = + static const Opentelemetry__Proto__Profiles__V1development__Link init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LINK__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__link__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Link *message) { - { 1, 0 }, - { 0, 1 } -}; -const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profiles_data__descriptor = + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__link__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__link__pack + (const Opentelemetry__Proto__Profiles__V1development__Link *message, + uint8_t *out) { - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "opentelemetry.proto.profiles.v1development.ProfilesData", - "ProfilesData", - "Opentelemetry__Proto__Profiles__V1development__ProfilesData", - "opentelemetry.proto.profiles.v1development", - sizeof(Opentelemetry__Proto__Profiles__V1development__ProfilesData), - 1, - opentelemetry__proto__profiles__v1development__profiles_data__field_descriptors, - opentelemetry__proto__profiles__v1development__profiles_data__field_indices_by_name, - 1, opentelemetry__proto__profiles__v1development__profiles_data__number_ranges, - (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__profiles_data__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__resource_profiles__field_descriptors[3] = + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__link__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__link__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Link *message, + ProtobufCBuffer *buffer) { - { - "resource", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - 0, /* quantifier_offset */ - offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, resource), - &opentelemetry__proto__resource__v1__resource__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "scope_profiles", - 2, - PROTOBUF_C_LABEL_REPEATED, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, n_scope_profiles), - offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, scope_profiles), - &opentelemetry__proto__profiles__v1development__scope_profiles__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "schema_url", - 3, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_STRING, - 0, /* quantifier_offset */ - offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, schema_url), - NULL, - &protobuf_c_empty_string, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned opentelemetry__proto__profiles__v1development__resource_profiles__field_indices_by_name[] = { - 0, /* field[0] = resource */ - 2, /* field[2] = schema_url */ - 1, /* field[1] = scope_profiles */ -}; -static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__resource_profiles__number_ranges[1 + 1] = + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__link__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Link * + opentelemetry__proto__profiles__v1development__link__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) { - { 1, 0 }, - { 0, 3 } -}; -const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__resource_profiles__descriptor = + return (Opentelemetry__Proto__Profiles__V1development__Link *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__link__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__link__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Link *message, + ProtobufCAllocator *allocator) { - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "opentelemetry.proto.profiles.v1development.ResourceProfiles", - "ResourceProfiles", - "Opentelemetry__Proto__Profiles__V1development__ResourceProfiles", - "opentelemetry.proto.profiles.v1development", - sizeof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles), - 3, - opentelemetry__proto__profiles__v1development__resource_profiles__field_descriptors, - opentelemetry__proto__profiles__v1development__resource_profiles__field_indices_by_name, - 1, opentelemetry__proto__profiles__v1development__resource_profiles__number_ranges, - (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__resource_profiles__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__scope_profiles__field_descriptors[3] = + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__link__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__value_type__init + (Opentelemetry__Proto__Profiles__V1development__ValueType *message) { - { - "scope", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_MESSAGE, - 0, /* quantifier_offset */ - offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, scope), - &opentelemetry__proto__common__v1__instrumentation_scope__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "profiles", - 2, - PROTOBUF_C_LABEL_REPEATED, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, n_profiles), - offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, profiles), - &opentelemetry__proto__profiles__v1development__profile_container__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "schema_url", - 3, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_STRING, - 0, /* quantifier_offset */ - offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, schema_url), - NULL, - &protobuf_c_empty_string, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned opentelemetry__proto__profiles__v1development__scope_profiles__field_indices_by_name[] = { - 1, /* field[1] = profiles */ - 2, /* field[2] = schema_url */ - 0, /* field[0] = scope */ -}; -static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__scope_profiles__number_ranges[1 + 1] = + static const Opentelemetry__Proto__Profiles__V1development__ValueType init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__VALUE_TYPE__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__value_type__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message) { - { 1, 0 }, - { 0, 3 } -}; -const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__scope_profiles__descriptor = + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__value_type__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__value_type__pack + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message, + uint8_t *out) { - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "opentelemetry.proto.profiles.v1development.ScopeProfiles", - "ScopeProfiles", - "Opentelemetry__Proto__Profiles__V1development__ScopeProfiles", - "opentelemetry.proto.profiles.v1development", - sizeof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles), - 3, - opentelemetry__proto__profiles__v1development__scope_profiles__field_descriptors, - opentelemetry__proto__profiles__v1development__scope_profiles__field_indices_by_name, - 1, opentelemetry__proto__profiles__v1development__scope_profiles__number_ranges, - (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__scope_profiles__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__profile_container__field_descriptors[8] = + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__value_type__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__value_type__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message, + ProtobufCBuffer *buffer) { - { - "profile_id", - 1, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BYTES, - 0, /* quantifier_offset */ - offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, profile_id), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "start_time_unix_nano", - 2, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_FIXED64, - 0, /* quantifier_offset */ - offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, start_time_unix_nano), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "end_time_unix_nano", - 3, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_FIXED64, - 0, /* quantifier_offset */ - offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, end_time_unix_nano), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "attributes", - 4, - PROTOBUF_C_LABEL_REPEATED, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, n_attributes), - offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, attributes), - &opentelemetry__proto__common__v1__key_value__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "dropped_attributes_count", - 5, - PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_UINT32, - 0, /* quantifier_offset */ - offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, dropped_attributes_count), - NULL, - NULL, + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__value_type__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__ValueType * + opentelemetry__proto__profiles__v1development__value_type__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__ValueType *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__value_type__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__value_type__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ValueType *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__value_type__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__sample__init + (Opentelemetry__Proto__Profiles__V1development__Sample *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Sample init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__SAMPLE__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__sample__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Sample *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__sample__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__sample__pack + (const Opentelemetry__Proto__Profiles__V1development__Sample *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__sample__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__sample__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Sample *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__sample__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Sample * + opentelemetry__proto__profiles__v1development__sample__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Sample *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__sample__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__sample__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Sample *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__sample__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__mapping__init + (Opentelemetry__Proto__Profiles__V1development__Mapping *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Mapping init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__MAPPING__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__mapping__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__mapping__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__mapping__pack + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__mapping__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__mapping__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__mapping__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Mapping * + opentelemetry__proto__profiles__v1development__mapping__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Mapping *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__mapping__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__mapping__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Mapping *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__mapping__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__stack__init + (Opentelemetry__Proto__Profiles__V1development__Stack *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Stack init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__STACK__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__stack__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Stack *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__stack__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__stack__pack + (const Opentelemetry__Proto__Profiles__V1development__Stack *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__stack__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__stack__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Stack *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__stack__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Stack * + opentelemetry__proto__profiles__v1development__stack__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Stack *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__stack__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__stack__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Stack *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__stack__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__location__init + (Opentelemetry__Proto__Profiles__V1development__Location *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Location init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LOCATION__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__location__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Location *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__location__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__location__pack + (const Opentelemetry__Proto__Profiles__V1development__Location *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__location__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__location__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Location *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__location__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Location * + opentelemetry__proto__profiles__v1development__location__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Location *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__location__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__location__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Location *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__location__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__line__init + (Opentelemetry__Proto__Profiles__V1development__Line *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Line init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LINE__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__line__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Line *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__line__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__line__pack + (const Opentelemetry__Proto__Profiles__V1development__Line *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__line__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__line__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Line *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__line__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Line * + opentelemetry__proto__profiles__v1development__line__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Line *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__line__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__line__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Line *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__line__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__function__init + (Opentelemetry__Proto__Profiles__V1development__Function *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__Function init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__FUNCTION__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__function__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Function *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__function__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__function__pack + (const Opentelemetry__Proto__Profiles__V1development__Function *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__function__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__function__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Function *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__function__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__Function * + opentelemetry__proto__profiles__v1development__function__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__Function *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__function__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__function__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Function *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__function__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +void opentelemetry__proto__profiles__v1development__key_value_and_unit__init + (Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *message) +{ + static const Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit init_value = OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__KEY_VALUE_AND_UNIT__INIT; + *message = init_value; +} +size_t opentelemetry__proto__profiles__v1development__key_value_and_unit__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *message) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__key_value_and_unit__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t opentelemetry__proto__profiles__v1development__key_value_and_unit__pack + (const Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *message, + uint8_t *out) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__key_value_and_unit__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t opentelemetry__proto__profiles__v1development__key_value_and_unit__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__key_value_and_unit__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit * + opentelemetry__proto__profiles__v1development__key_value_and_unit__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *) + protobuf_c_message_unpack (&opentelemetry__proto__profiles__v1development__key_value_and_unit__descriptor, + allocator, len, data); +} +void opentelemetry__proto__profiles__v1development__key_value_and_unit__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &opentelemetry__proto__profiles__v1development__key_value_and_unit__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__profiles_dictionary__field_descriptors[7] = +{ + { + "mapping_table", + 1, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, n_mapping_table), + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, mapping_table), + &opentelemetry__proto__profiles__v1development__mapping__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "location_table", + 2, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, n_location_table), + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, location_table), + &opentelemetry__proto__profiles__v1development__location__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "function_table", + 3, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, n_function_table), + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, function_table), + &opentelemetry__proto__profiles__v1development__function__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "link_table", + 4, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, n_link_table), + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, link_table), + &opentelemetry__proto__profiles__v1development__link__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "string_table", + 5, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_STRING, + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, n_string_table), + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, string_table), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "attribute_table", + 6, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, n_attribute_table), + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, attribute_table), + &opentelemetry__proto__profiles__v1development__key_value_and_unit__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "stack_table", + 7, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, n_stack_table), + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary, stack_table), + &opentelemetry__proto__profiles__v1development__stack__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__profiles_dictionary__field_indices_by_name[] = { + 5, /* field[5] = attribute_table */ + 2, /* field[2] = function_table */ + 3, /* field[3] = link_table */ + 1, /* field[1] = location_table */ + 0, /* field[0] = mapping_table */ + 6, /* field[6] = stack_table */ + 4, /* field[4] = string_table */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__profiles_dictionary__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 7 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profiles_dictionary__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.ProfilesDictionary", + "ProfilesDictionary", + "Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary), + 7, + opentelemetry__proto__profiles__v1development__profiles_dictionary__field_descriptors, + opentelemetry__proto__profiles__v1development__profiles_dictionary__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__profiles_dictionary__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__profiles_dictionary__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__profiles_data__field_descriptors[2] = +{ + { + "resource_profiles", + 1, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesData, n_resource_profiles), + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesData, resource_profiles), + &opentelemetry__proto__profiles__v1development__resource_profiles__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "dictionary", + 2, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ProfilesData, dictionary), + &opentelemetry__proto__profiles__v1development__profiles_dictionary__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__profiles_data__field_indices_by_name[] = { + 1, /* field[1] = dictionary */ + 0, /* field[0] = resource_profiles */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__profiles_data__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 2 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profiles_data__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.ProfilesData", + "ProfilesData", + "Opentelemetry__Proto__Profiles__V1development__ProfilesData", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__ProfilesData), + 2, + opentelemetry__proto__profiles__v1development__profiles_data__field_descriptors, + opentelemetry__proto__profiles__v1development__profiles_data__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__profiles_data__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__profiles_data__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__resource_profiles__field_descriptors[3] = +{ + { + "resource", + 1, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, resource), + &opentelemetry__proto__resource__v1__resource__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "scope_profiles", + 2, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, n_scope_profiles), + offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, scope_profiles), + &opentelemetry__proto__profiles__v1development__scope_profiles__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "schema_url", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles, schema_url), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__resource_profiles__field_indices_by_name[] = { + 0, /* field[0] = resource */ + 2, /* field[2] = schema_url */ + 1, /* field[1] = scope_profiles */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__resource_profiles__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 3 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__resource_profiles__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.ResourceProfiles", + "ResourceProfiles", + "Opentelemetry__Proto__Profiles__V1development__ResourceProfiles", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__ResourceProfiles), + 3, + opentelemetry__proto__profiles__v1development__resource_profiles__field_descriptors, + opentelemetry__proto__profiles__v1development__resource_profiles__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__resource_profiles__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__resource_profiles__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__scope_profiles__field_descriptors[3] = +{ + { + "scope", + 1, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, scope), + &opentelemetry__proto__common__v1__instrumentation_scope__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "profiles", + 2, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, n_profiles), + offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, profiles), + &opentelemetry__proto__profiles__v1development__profile__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "schema_url", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles, schema_url), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__scope_profiles__field_indices_by_name[] = { + 1, /* field[1] = profiles */ + 2, /* field[2] = schema_url */ + 0, /* field[0] = scope */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__scope_profiles__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 3 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__scope_profiles__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.ScopeProfiles", + "ScopeProfiles", + "Opentelemetry__Proto__Profiles__V1development__ScopeProfiles", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__ScopeProfiles), + 3, + opentelemetry__proto__profiles__v1development__scope_profiles__field_descriptors, + opentelemetry__proto__profiles__v1development__scope_profiles__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__scope_profiles__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__scope_profiles__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__profile__field_descriptors[11] = +{ + { + "sample_type", + 1, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, sample_type), + &opentelemetry__proto__profiles__v1development__value_type__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "samples", + 2, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_samples), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, samples), + &opentelemetry__proto__profiles__v1development__sample__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "time_unix_nano", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_FIXED64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, time_unix_nano), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "duration_nano", + 4, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, duration_nano), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "period_type", + 5, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_MESSAGE, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, period_type), + &opentelemetry__proto__profiles__v1development__value_type__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "period", + 6, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, period), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "profile_id", + 7, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BYTES, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, profile_id), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "dropped_attributes_count", + 8, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, dropped_attributes_count), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "original_payload_format", + 9, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_STRING, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, original_payload_format), + NULL, + &protobuf_c_empty_string, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "original_payload", + 10, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BYTES, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, original_payload), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "attribute_indices", + 11, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT32, + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, n_attribute_indices), + offsetof(Opentelemetry__Proto__Profiles__V1development__Profile, attribute_indices), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__profile__field_indices_by_name[] = { + 10, /* field[10] = attribute_indices */ + 7, /* field[7] = dropped_attributes_count */ + 3, /* field[3] = duration_nano */ + 9, /* field[9] = original_payload */ + 8, /* field[8] = original_payload_format */ + 5, /* field[5] = period */ + 4, /* field[4] = period_type */ + 6, /* field[6] = profile_id */ + 0, /* field[0] = sample_type */ + 1, /* field[1] = samples */ + 2, /* field[2] = time_unix_nano */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__profile__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 11 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profile__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Profile", + "Profile", + "Opentelemetry__Proto__Profiles__V1development__Profile", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Profile), + 11, + opentelemetry__proto__profiles__v1development__profile__field_descriptors, + opentelemetry__proto__profiles__v1development__profile__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__profile__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__profile__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__link__field_descriptors[2] = +{ + { + "trace_id", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BYTES, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Link, trace_id), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "span_id", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_BYTES, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Link, span_id), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__link__field_indices_by_name[] = { + 1, /* field[1] = span_id */ + 0, /* field[0] = trace_id */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__link__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 2 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__link__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Link", + "Link", + "Opentelemetry__Proto__Profiles__V1development__Link", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Link), + 2, + opentelemetry__proto__profiles__v1development__link__field_descriptors, + opentelemetry__proto__profiles__v1development__link__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__link__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__link__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__value_type__field_descriptors[2] = +{ + { + "type_strindex", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ValueType, type_strindex), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "unit_strindex", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__ValueType, unit_strindex), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__value_type__field_indices_by_name[] = { + 0, /* field[0] = type_strindex */ + 1, /* field[1] = unit_strindex */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__value_type__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 2 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__value_type__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.ValueType", + "ValueType", + "Opentelemetry__Proto__Profiles__V1development__ValueType", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__ValueType), + 2, + opentelemetry__proto__profiles__v1development__value_type__field_descriptors, + opentelemetry__proto__profiles__v1development__value_type__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__value_type__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__value_type__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__sample__field_descriptors[5] = +{ + { + "stack_index", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, stack_index), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "values", + 2, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT64, + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, n_values), + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, values), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "attribute_indices", + 3, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT32, + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, n_attribute_indices), + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, attribute_indices), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "link_index", + 4, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, link_index), + NULL, + NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "original_payload_format", - 6, + "timestamps_unix_nano", + 5, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_FIXED64, + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, n_timestamps_unix_nano), + offsetof(Opentelemetry__Proto__Profiles__V1development__Sample, timestamps_unix_nano), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__sample__field_indices_by_name[] = { + 2, /* field[2] = attribute_indices */ + 3, /* field[3] = link_index */ + 0, /* field[0] = stack_index */ + 4, /* field[4] = timestamps_unix_nano */ + 1, /* field[1] = values */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__sample__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 5 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__sample__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Sample", + "Sample", + "Opentelemetry__Proto__Profiles__V1development__Sample", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Sample), + 5, + opentelemetry__proto__profiles__v1development__sample__field_descriptors, + opentelemetry__proto__profiles__v1development__sample__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__sample__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__sample__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__mapping__field_descriptors[5] = +{ + { + "memory_start", + 1, PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_STRING, + PROTOBUF_C_TYPE_UINT64, 0, /* quantifier_offset */ - offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, original_payload_format), + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, memory_start), + NULL, NULL, - &protobuf_c_empty_string, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "original_payload", - 7, + "memory_limit", + 2, PROTOBUF_C_LABEL_NONE, - PROTOBUF_C_TYPE_BYTES, + PROTOBUF_C_TYPE_UINT64, 0, /* quantifier_offset */ - offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, original_payload), + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, memory_limit), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "profile", - 8, + "file_offset", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, file_offset), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "filename_strindex", + 4, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, filename_strindex), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "attribute_indices", + 5, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT32, + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, n_attribute_indices), + offsetof(Opentelemetry__Proto__Profiles__V1development__Mapping, attribute_indices), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__mapping__field_indices_by_name[] = { + 4, /* field[4] = attribute_indices */ + 2, /* field[2] = file_offset */ + 3, /* field[3] = filename_strindex */ + 1, /* field[1] = memory_limit */ + 0, /* field[0] = memory_start */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__mapping__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 5 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__mapping__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Mapping", + "Mapping", + "Opentelemetry__Proto__Profiles__V1development__Mapping", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Mapping), + 5, + opentelemetry__proto__profiles__v1development__mapping__field_descriptors, + opentelemetry__proto__profiles__v1development__mapping__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__mapping__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__mapping__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__stack__field_descriptors[1] = +{ + { + "location_indices", + 1, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT32, + offsetof(Opentelemetry__Proto__Profiles__V1development__Stack, n_location_indices), + offsetof(Opentelemetry__Proto__Profiles__V1development__Stack, location_indices), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__stack__field_indices_by_name[] = { + 0, /* field[0] = location_indices */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__stack__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 1 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__stack__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Stack", + "Stack", + "Opentelemetry__Proto__Profiles__V1development__Stack", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Stack), + 1, + opentelemetry__proto__profiles__v1development__stack__field_descriptors, + opentelemetry__proto__profiles__v1development__stack__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__stack__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__stack__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__location__field_descriptors[4] = +{ + { + "mapping_index", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, mapping_index), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "address", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_UINT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, address), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "lines", + 3, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, n_lines), + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, lines), + &opentelemetry__proto__profiles__v1development__line__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "attribute_indices", + 4, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_INT32, + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, n_attribute_indices), + offsetof(Opentelemetry__Proto__Profiles__V1development__Location, attribute_indices), + NULL, + NULL, + PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__location__field_indices_by_name[] = { + 1, /* field[1] = address */ + 3, /* field[3] = attribute_indices */ + 2, /* field[2] = lines */ + 0, /* field[0] = mapping_index */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__location__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 4 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__location__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Location", + "Location", + "Opentelemetry__Proto__Profiles__V1development__Location", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Location), + 4, + opentelemetry__proto__profiles__v1development__location__field_descriptors, + opentelemetry__proto__profiles__v1development__location__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__location__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__location__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__line__field_descriptors[3] = +{ + { + "function_index", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Line, function_index), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "line", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Line, line), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "column", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Line, column), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__line__field_indices_by_name[] = { + 2, /* field[2] = column */ + 0, /* field[0] = function_index */ + 1, /* field[1] = line */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__line__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 3 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__line__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Line", + "Line", + "Opentelemetry__Proto__Profiles__V1development__Line", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Line), + 3, + opentelemetry__proto__profiles__v1development__line__field_descriptors, + opentelemetry__proto__profiles__v1development__line__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__line__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__line__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__function__field_descriptors[4] = +{ + { + "name_strindex", + 1, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Function, name_strindex), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "system_name_strindex", + 2, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Function, system_name_strindex), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "filename_strindex", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Function, filename_strindex), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "start_line", + 4, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT64, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__Function, start_line), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, +}; +static const unsigned opentelemetry__proto__profiles__v1development__function__field_indices_by_name[] = { + 2, /* field[2] = filename_strindex */ + 0, /* field[0] = name_strindex */ + 3, /* field[3] = start_line */ + 1, /* field[1] = system_name_strindex */ +}; +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__function__number_ranges[1 + 1] = +{ + { 1, 0 }, + { 0, 4 } +}; +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__function__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "opentelemetry.proto.profiles.v1development.Function", + "Function", + "Opentelemetry__Proto__Profiles__V1development__Function", + "opentelemetry.proto.profiles.v1development", + sizeof(Opentelemetry__Proto__Profiles__V1development__Function), + 4, + opentelemetry__proto__profiles__v1development__function__field_descriptors, + opentelemetry__proto__profiles__v1development__function__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__function__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__function__init, + NULL,NULL,NULL /* reserved[123] */ +}; +static const ProtobufCFieldDescriptor opentelemetry__proto__profiles__v1development__key_value_and_unit__field_descriptors[3] = +{ + { + "key_strindex", + 1, PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit, key_strindex), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "value", + 2, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ - offsetof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer, profile), - &opentelemetry__proto__profiles__v1development__profile__descriptor, + offsetof(Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit, value), + &opentelemetry__proto__common__v1__any_value__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "unit_strindex", + 3, + PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit, unit_strindex), + NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; -static const unsigned opentelemetry__proto__profiles__v1development__profile_container__field_indices_by_name[] = { - 3, /* field[3] = attributes */ - 4, /* field[4] = dropped_attributes_count */ - 2, /* field[2] = end_time_unix_nano */ - 6, /* field[6] = original_payload */ - 5, /* field[5] = original_payload_format */ - 7, /* field[7] = profile */ - 0, /* field[0] = profile_id */ - 1, /* field[1] = start_time_unix_nano */ +static const unsigned opentelemetry__proto__profiles__v1development__key_value_and_unit__field_indices_by_name[] = { + 0, /* field[0] = key_strindex */ + 2, /* field[2] = unit_strindex */ + 1, /* field[1] = value */ }; -static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__profile_container__number_ranges[1 + 1] = +static const ProtobufCIntRange opentelemetry__proto__profiles__v1development__key_value_and_unit__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 8 } + { 0, 3 } }; -const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profile_container__descriptor = +const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__key_value_and_unit__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "opentelemetry.proto.profiles.v1development.ProfileContainer", - "ProfileContainer", - "Opentelemetry__Proto__Profiles__V1development__ProfileContainer", + "opentelemetry.proto.profiles.v1development.KeyValueAndUnit", + "KeyValueAndUnit", + "Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit", "opentelemetry.proto.profiles.v1development", - sizeof(Opentelemetry__Proto__Profiles__V1development__ProfileContainer), - 8, - opentelemetry__proto__profiles__v1development__profile_container__field_descriptors, - opentelemetry__proto__profiles__v1development__profile_container__field_indices_by_name, - 1, opentelemetry__proto__profiles__v1development__profile_container__number_ranges, - (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__profile_container__init, + sizeof(Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit), + 3, + opentelemetry__proto__profiles__v1development__key_value_and_unit__field_descriptors, + opentelemetry__proto__profiles__v1development__key_value_and_unit__field_indices_by_name, + 1, opentelemetry__proto__profiles__v1development__key_value_and_unit__number_ranges, + (ProtobufCMessageInit) opentelemetry__proto__profiles__v1development__key_value_and_unit__init, NULL,NULL,NULL /* reserved[123] */ }; diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.h index fe20ffa45d1..6e63c86c19e 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/profiles/v1development/profiles.pb-c.h @@ -9,19 +9,28 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1004001 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +# error This file was generated by a newer version of protobuf-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005002 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protobuf-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protobuf-c. #endif #include "opentelemetry/proto/common/v1/common.pb-c.h" #include "opentelemetry/proto/resource/v1/resource.pb-c.h" -#include "opentelemetry/proto/profiles/v1development/pprofextended.pb-c.h" +typedef struct Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary; typedef struct Opentelemetry__Proto__Profiles__V1development__ProfilesData Opentelemetry__Proto__Profiles__V1development__ProfilesData; typedef struct Opentelemetry__Proto__Profiles__V1development__ResourceProfiles Opentelemetry__Proto__Profiles__V1development__ResourceProfiles; typedef struct Opentelemetry__Proto__Profiles__V1development__ScopeProfiles Opentelemetry__Proto__Profiles__V1development__ScopeProfiles; -typedef struct Opentelemetry__Proto__Profiles__V1development__ProfileContainer Opentelemetry__Proto__Profiles__V1development__ProfileContainer; +typedef struct Opentelemetry__Proto__Profiles__V1development__Profile Opentelemetry__Proto__Profiles__V1development__Profile; +typedef struct Opentelemetry__Proto__Profiles__V1development__Link Opentelemetry__Proto__Profiles__V1development__Link; +typedef struct Opentelemetry__Proto__Profiles__V1development__ValueType Opentelemetry__Proto__Profiles__V1development__ValueType; +typedef struct Opentelemetry__Proto__Profiles__V1development__Sample Opentelemetry__Proto__Profiles__V1development__Sample; +typedef struct Opentelemetry__Proto__Profiles__V1development__Mapping Opentelemetry__Proto__Profiles__V1development__Mapping; +typedef struct Opentelemetry__Proto__Profiles__V1development__Stack Opentelemetry__Proto__Profiles__V1development__Stack; +typedef struct Opentelemetry__Proto__Profiles__V1development__Location Opentelemetry__Proto__Profiles__V1development__Location; +typedef struct Opentelemetry__Proto__Profiles__V1development__Line Opentelemetry__Proto__Profiles__V1development__Line; +typedef struct Opentelemetry__Proto__Profiles__V1development__Function Opentelemetry__Proto__Profiles__V1development__Function; +typedef struct Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit; /* --- enums --- */ @@ -29,6 +38,94 @@ typedef struct Opentelemetry__Proto__Profiles__V1development__ProfileContainer O /* --- messages --- */ +/* + * ProfilesDictionary represents the profiles data shared across the + * entire message being sent. The following applies to all fields in this + * message: + * - A dictionary is an array of dictionary items. Users of the dictionary + * compactly reference the items using the index within the array. + * - A dictionary MUST have a zero value encoded as the first element. This + * allows for _index fields pointing into the dictionary to use a 0 pointer + * value to indicate 'null' / 'not set'. Unless otherwise defined, a 'zero + * value' message value is one with all default field values, so as to + * minimize wire encoded size. + * - There SHOULD NOT be dupes in a dictionary. The identity of dictionary + * items is based on their value, recursively as needed. If a particular + * implementation does emit duplicated items, it MUST NOT attempt to give them + * meaning based on the index or order. A profile processor may remove + * duplicate items and this MUST NOT have any observable effects for + * consumers. + * - There SHOULD NOT be orphaned (unreferenced) items in a dictionary. A + * profile processor may remove ("garbage-collect") orphaned items and this + * MUST NOT have any observable effects for consumers. + */ +struct Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary +{ + ProtobufCMessage base; + /* + * 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 zero value (Mapping{}) and present. + */ + size_t n_mapping_table; + Opentelemetry__Proto__Profiles__V1development__Mapping **mapping_table; + /* + * Locations referenced by samples via Stack.location_indices. + * location_table[0] must always be zero value (Location{}) and present. + */ + size_t n_location_table; + Opentelemetry__Proto__Profiles__V1development__Location **location_table; + /* + * Functions referenced by locations via Line.function_index. + * function_table[0] must always be zero value (Function{}) and present. + */ + size_t n_function_table; + Opentelemetry__Proto__Profiles__V1development__Function **function_table; + /* + * Links referenced by samples via Sample.link_index. + * link_table[0] must always be zero value (Link{}) and present. + */ + size_t n_link_table; + Opentelemetry__Proto__Profiles__V1development__Link **link_table; + /* + * A common table for strings referenced by various messages. + * string_table[0] must always be "" and present. + */ + size_t n_string_table; + char **string_table; + /* + * A common table for attributes referenced by the Profile, Sample, Mapping + * and Location messages below through attribute_indices field. Each entry is + * a key/value pair with an optional unit. Since this is a dictionary table, + * multiple entries with the same key may be present, unlike direct attribute + * tables like Resource.attributes. The referencing attribute_indices fields, + * though, do maintain the key uniqueness requirement. + * It's recommended to use attributes for variables with bounded cardinality, + * such as categorical variables + * (https://en.wikipedia.org/wiki/Categorical_variable). Using an attribute of + * a floating point type (e.g., CPU time) in a sample can quickly make every + * attribute value unique, defeating the purpose of the dictionary and + * impractically increasing the profile size. + * Examples of attributes: + * "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" + * "abc.com/myattribute": true + * "allocation_size": 128 bytes + * attribute_table[0] must always be zero value (KeyValueAndUnit{}) and present. + */ + size_t n_attribute_table; + Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit **attribute_table; + /* + * Stacks referenced by samples via Sample.stack_index. + * stack_table[0] must always be zero value (Stack{}) and present. + */ + size_t n_stack_table; + Opentelemetry__Proto__Profiles__V1development__Stack **stack_table; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILES_DICTIONARY__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__profiles_dictionary__descriptor) \ +, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL } + + /* * ProfilesData represents the profiles data that can be stored in persistent storage, * OR can be embedded by other protocols that transfer OTLP profiles data but do not @@ -44,17 +141,25 @@ struct Opentelemetry__Proto__Profiles__V1development__ProfilesData ProtobufCMessage base; /* * An array of ResourceProfiles. - * For data coming from a single resource this array will typically contain - * one element. Intermediary nodes that receive data from multiple origins - * typically batch the data before forwarding further and in that case this - * array will contain multiple elements. + * For data coming from an SDK profiler, this array will typically contain one + * element. Host-level profilers will usually create one ResourceProfile per + * container, as well as one additional ResourceProfile grouping all samples + * from non-containerized processes. + * Other resource groupings are possible as well and clarified via + * Resource.attributes and semantic conventions. + * Tools that visualize profiles should prefer displaying + * resources_profiles[0].scope_profiles[0].profiles[0] by default. */ size_t n_resource_profiles; Opentelemetry__Proto__Profiles__V1development__ResourceProfiles **resource_profiles; + /* + * One instance of ProfilesDictionary + */ + Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *dictionary; }; #define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILES_DATA__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__profiles_data__descriptor) \ - , 0,NULL } +, 0,NULL, NULL } /* @@ -75,7 +180,8 @@ struct Opentelemetry__Proto__Profiles__V1development__ResourceProfiles Opentelemetry__Proto__Profiles__V1development__ScopeProfiles **scope_profiles; /* * The Schema URL, if known. This is the identifier of the Schema that the resource data - * is recorded in. To learn more about Schema URL see + * is recorded in. Notably, the last part of the URL path is the version number of the + * schema: http[s]://server[:port]/path/. To learn more about Schema URL see * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url * This schema_url applies to the data in the "resource" field. It does not apply * to the data in the "scope_profiles" field which have their own schema_url field. @@ -84,11 +190,11 @@ struct Opentelemetry__Proto__Profiles__V1development__ResourceProfiles }; #define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__RESOURCE_PROFILES__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__resource_profiles__descriptor) \ - , NULL, 0,NULL, (char *)protobuf_c_empty_string } +, NULL, 0,NULL, (char *)protobuf_c_empty_string } /* - * A collection of ProfileContainers produced by an InstrumentationScope. + * A collection of Profiles produced by an InstrumentationScope. */ struct Opentelemetry__Proto__Profiles__V1development__ScopeProfiles { @@ -100,89 +206,409 @@ struct Opentelemetry__Proto__Profiles__V1development__ScopeProfiles */ Opentelemetry__Proto__Common__V1__InstrumentationScope *scope; /* - * A list of ProfileContainers that originate from an instrumentation scope. + * A list of Profiles that originate from an instrumentation scope. */ size_t n_profiles; - Opentelemetry__Proto__Profiles__V1development__ProfileContainer **profiles; + Opentelemetry__Proto__Profiles__V1development__Profile **profiles; /* - * The Schema URL, if known. This is the identifier of the Schema that the metric data - * is recorded in. To learn more about Schema URL see + * The Schema URL, if known. This is the identifier of the Schema that the profile data + * is recorded in. Notably, the last part of the URL path is the version number of the + * schema: http[s]://server[:port]/path/. To learn more about Schema URL see * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - * This schema_url applies to all profiles in the "profiles" field. + * This schema_url applies to the data in the "scope" field and all profiles in the + * "profiles" field. */ char *schema_url; }; #define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__SCOPE_PROFILES__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__scope_profiles__descriptor) \ - , NULL, 0,NULL, (char *)protobuf_c_empty_string } +, NULL, 0,NULL, (char *)protobuf_c_empty_string } /* - * A ProfileContainer represents a single profile. It wraps pprof profile with OpenTelemetry specific metadata. + * Represents a complete profile, including sample types, samples, mappings to + * binaries, stacks, locations, functions, string table, and additional + * metadata. It modifies and annotates pprof Profile with OpenTelemetry + * specific fields. + * Note that whilst fields in this message retain the name and field id from pprof in most cases + * for ease of understanding data migration, it is not intended that pprof:Profile and + * OpenTelemetry:Profile encoding be wire compatible. */ -struct Opentelemetry__Proto__Profiles__V1development__ProfileContainer +struct Opentelemetry__Proto__Profiles__V1development__Profile { ProtobufCMessage base; /* - * 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. + * 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: + * ["allocated_objects","count"] or ["allocated_space","bytes"], */ - ProtobufCBinaryData profile_id; + Opentelemetry__Proto__Profiles__V1development__ValueType *sample_type; /* - * start_time_unix_nano is the start time of the profile. - * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - * This field is semantically required and it is expected that end_time >= start_time. + * The set of samples recorded in this profile. */ - uint64_t start_time_unix_nano; + size_t n_samples; + Opentelemetry__Proto__Profiles__V1development__Sample **samples; /* - * end_time_unix_nano is the end time of the profile. - * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - * This field is semantically required and it is expected that end_time >= start_time. + * Time of collection (UTC) represented as nanoseconds past the epoch. */ - uint64_t end_time_unix_nano; + uint64_t time_unix_nano; /* - * attributes is a collection of key/value pairs. Note, global attributes - * like server name can be set using the resource API. Examples of attributes: - * "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" - * "/http/server_latency": 300 - * "abc.com/myattribute": true - * "abc.com/score": 10.239 - * The OpenTelemetry API specification further restricts the allowed value types: - * 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). + * Duration of the profile, if a duration makes sense. */ - size_t n_attributes; - Opentelemetry__Proto__Common__V1__KeyValue **attributes; + uint64_t duration_nano; /* - * dropped_attributes_count is the number of attributes that were discarded. Attributes + * The kind of events between sampled occurrences. + * e.g [ "cpu","cycles" ] or [ "heap","bytes" ] + */ + Opentelemetry__Proto__Profiles__V1development__ValueType *period_type; + /* + * The number of events between sampled occurrences. + */ + int64_t period; + /* + * A globally unique identifier for a profile. The ID is a 16-byte array. An ID with + * all zeroes is considered invalid. It may be used for deduplication and signal + * correlation purposes. It is acceptable to treat two profiles with different values + * in this field as not equal, even if they represented the same object at an earlier + * time. + * This field is optional; an ID may be assigned to an ID-less profile in a later step. + */ + ProtobufCBinaryData profile_id; + /* + * 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_t dropped_attributes_count; /* - * Specifies format of the original payload. Common values are defined in semantic conventions. [required if original_payload is present] + * The original payload format. See also original_payload. Optional, but the + * format and the bytes must be set or unset together. + * The allowed values for the format string are defined by the OpenTelemetry + * specification. Some examples are "jfr", "pprof", "linux_perf". + * The original payload may be optionally provided when the conversion to the + * OLTP format was done from a different format with some loss of the fidelity + * and the receiver may want to store the original payload to allow future + * lossless export or reinterpretation. Some examples of the original format + * are JFR (Java Flight Recorder), pprof, Linux perf. + * Even when the original payload is in a format that is semantically close to + * OTLP, such as pprof, a conversion may still be lossy in some cases (e.g. if + * the pprof file contains custom extensions or conventions). + * The original payload can be large in size, so including the original + * payload should be configurable by the profiler or collector options. The + * default behavior should be to not include the original payload. */ char *original_payload_format; /* - * 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 `profile` MUST be present and contain the same profiling information. + * The original payload bytes. See also original_payload_format. Optional, but + * format and the bytes must be set or unset together. */ ProtobufCBinaryData original_payload; /* - * This is a reference to a pprof profile. Required, even when original_payload is present. + * References to attributes in attribute_table. [optional] + */ + size_t n_attribute_indices; + int32_t *attribute_indices; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__profile__descriptor) \ +, NULL, 0,NULL, 0, 0, NULL, 0, {0,NULL}, 0, (char *)protobuf_c_empty_string, {0,NULL}, 0,NULL } + + +/* + * A pointer from a profile Sample to a trace Span. + * Connects a profile sample to a trace span, identified by unique trace and span IDs. + */ +struct Opentelemetry__Proto__Profiles__V1development__Link +{ + ProtobufCMessage base; + /* + * A unique identifier of a trace that this linked span is part of. The ID is a + * 16-byte array. + */ + ProtobufCBinaryData trace_id; + /* + * A unique identifier for the linked span. The ID is an 8-byte array. + */ + ProtobufCBinaryData span_id; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LINK__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__link__descriptor) \ +, {0,NULL}, {0,NULL} } + + +/* + * ValueType describes the type and units of a value. + */ +struct Opentelemetry__Proto__Profiles__V1development__ValueType +{ + ProtobufCMessage base; + /* + * Index into ProfilesDictionary.string_table. + */ + int32_t type_strindex; + /* + * Index into ProfilesDictionary.string_table. + */ + int32_t unit_strindex; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__VALUE_TYPE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__value_type__descriptor) \ +, 0, 0 } + + +/* + * 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. + * Examples of different ways of representing a sample with the total value of 10: + * Report of a stacktrace at 10 timestamps (consumers must assume the value is 1 for each point): + * values: [] + * timestamps_unix_nano: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + * Report of a stacktrace with an aggregated value without timestamps: + * values: [10] + * timestamps_unix_nano: [] + * Report of a stacktrace at 4 timestamps where each point records a specific value: + * values: [2, 2, 3, 3] + * timestamps_unix_nano: [1, 2, 3, 4] + */ +struct Opentelemetry__Proto__Profiles__V1development__Sample +{ + ProtobufCMessage base; + /* + * Reference to stack in ProfilesDictionary.stack_table. + */ + int32_t stack_index; + /* + * The type and unit of each value is defined by Profile.sample_type. + */ + size_t n_values; + int64_t *values; + /* + * References to attributes in ProfilesDictionary.attribute_table. [optional] + */ + size_t n_attribute_indices; + int32_t *attribute_indices; + /* + * Reference to link in ProfilesDictionary.link_table. [optional] + * It can be unset / set to 0 if no link exists, as link_table[0] is always a 'null' default value. + */ + int32_t link_index; + /* + * Timestamps associated with Sample represented in nanoseconds. These + * timestamps should fall within the Profile's time range. + */ + size_t n_timestamps_unix_nano; + uint64_t *timestamps_unix_nano; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__SAMPLE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__sample__descriptor) \ +, 0, 0,NULL, 0,NULL, 0, 0,NULL } + + +/* + * Describes the mapping of a binary in memory, including its address range, + * file offset, and metadata like build ID + */ +struct Opentelemetry__Proto__Profiles__V1development__Mapping +{ + ProtobufCMessage base; + /* + * Address at which the binary (or DLL) is loaded into memory. + */ + uint64_t memory_start; + /* + * The limit of the address range occupied by this mapping. + */ + uint64_t memory_limit; + /* + * Offset in the binary that corresponds to the first mapped address. + */ + uint64_t file_offset; + /* + * The object this entry is loaded from. This can be a filename on + * disk for the main binary and shared libraries, or virtual + * abstractions like "[vdso]". + */ + /* + * Index into ProfilesDictionary.string_table. + */ + int32_t filename_strindex; + /* + * References to attributes in ProfilesDictionary.attribute_table. [optional] + */ + size_t n_attribute_indices; + int32_t *attribute_indices; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__MAPPING__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__mapping__descriptor) \ +, 0, 0, 0, 0, 0,NULL } + + +/* + * A Stack represents a stack trace as a list of locations. + */ +struct Opentelemetry__Proto__Profiles__V1development__Stack +{ + ProtobufCMessage base; + /* + * References to locations in ProfilesDictionary.location_table. + * The first location is the leaf frame. + */ + size_t n_location_indices; + int32_t *location_indices; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__STACK__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__stack__descriptor) \ +, 0,NULL } + + +/* + * Describes function and line table debug information. + */ +struct Opentelemetry__Proto__Profiles__V1development__Location +{ + ProtobufCMessage base; + /* + * Reference to mapping in ProfilesDictionary.mapping_table. + * 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_t mapping_index; + /* + * 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 + * middle of a call instruction. It is up to display tools to find + * the beginning of the instruction if necessary. */ - Opentelemetry__Proto__Profiles__V1development__Profile *profile; + uint64_t address; + /* + * Multiple line indicates this location has inlined functions, + * where the last entry represents the caller into which the + * preceding entries were inlined. + * E.g., if memcpy() is inlined into printf: + * lines[0].function_name == "memcpy" + * lines[1].function_name == "printf" + */ + size_t n_lines; + Opentelemetry__Proto__Profiles__V1development__Line **lines; + /* + * References to attributes in ProfilesDictionary.attribute_table. [optional] + */ + size_t n_attribute_indices; + int32_t *attribute_indices; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LOCATION__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__location__descriptor) \ +, 0, 0, 0,NULL, 0,NULL } + + +/* + * Details a specific line in a source code, linked to a function. + */ +struct Opentelemetry__Proto__Profiles__V1development__Line +{ + ProtobufCMessage base; + /* + * Reference to function in ProfilesDictionary.function_table. + */ + int32_t function_index; + /* + * Line number in source code. 0 means unset. + */ + int64_t line; + /* + * Column number in source code. 0 means unset. + */ + int64_t column; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__LINE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__line__descriptor) \ +, 0, 0, 0 } + + +/* + * Describes a function, including its human-readable name, system name, + * source file, and starting line number in the source. + */ +struct Opentelemetry__Proto__Profiles__V1development__Function +{ + ProtobufCMessage base; + /* + * The function name. Empty string if not available. + */ + int32_t name_strindex; + /* + * Function name, as identified by the system. For instance, + * it can be a C++ mangled name. Empty string if not available. + */ + int32_t system_name_strindex; + /* + * Source file containing the function. Empty string if not available. + */ + int32_t filename_strindex; + /* + * Line number in source file. 0 means unset. + */ + int64_t start_line; }; -#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__PROFILE_CONTAINER__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__profile_container__descriptor) \ - , {0,NULL}, 0, 0, 0,NULL, 0, (char *)protobuf_c_empty_string, {0,NULL}, NULL } +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__FUNCTION__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__function__descriptor) \ +, 0, 0, 0, 0 } + +/* + * A custom 'dictionary native' style of encoding attributes which is more convenient + * for profiles than opentelemetry.proto.common.v1.KeyValue + * Specifically, uses the string table for keys and allows optional unit information. + */ +struct Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit +{ + ProtobufCMessage base; + /* + * The index into the string table for the attribute's key. + */ + int32_t key_strindex; + /* + * The value of the attribute. + */ + Opentelemetry__Proto__Common__V1__AnyValue *value; + /* + * The index into the string table for the attribute's unit. + * zero indicates implicit (by semconv) or non-defined unit. + */ + int32_t unit_strindex; +}; +#define OPENTELEMETRY__PROTO__PROFILES__V1DEVELOPMENT__KEY_VALUE_AND_UNIT__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__profiles__v1development__key_value_and_unit__descriptor) \ +, 0, NULL, 0 } + +/* Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary methods */ +void opentelemetry__proto__profiles__v1development__profiles_dictionary__init + (Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *message); +size_t opentelemetry__proto__profiles__v1development__profiles_dictionary__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *message); +size_t opentelemetry__proto__profiles__v1development__profiles_dictionary__pack + (const Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__profiles_dictionary__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary * + opentelemetry__proto__profiles__v1development__profiles_dictionary__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__profiles_dictionary__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *message, + ProtobufCAllocator *allocator); /* Opentelemetry__Proto__Profiles__V1development__ProfilesData methods */ void opentelemetry__proto__profiles__v1development__profiles_data__init (Opentelemetry__Proto__Profiles__V1development__ProfilesData *message); @@ -240,27 +666,201 @@ Opentelemetry__Proto__Profiles__V1development__ScopeProfiles * void opentelemetry__proto__profiles__v1development__scope_profiles__free_unpacked (Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message, ProtobufCAllocator *allocator); -/* Opentelemetry__Proto__Profiles__V1development__ProfileContainer methods */ -void opentelemetry__proto__profiles__v1development__profile_container__init - (Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message); -size_t opentelemetry__proto__profiles__v1development__profile_container__get_packed_size - (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message); -size_t opentelemetry__proto__profiles__v1development__profile_container__pack - (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, +/* Opentelemetry__Proto__Profiles__V1development__Profile methods */ +void opentelemetry__proto__profiles__v1development__profile__init + (Opentelemetry__Proto__Profiles__V1development__Profile *message); +size_t opentelemetry__proto__profiles__v1development__profile__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Profile *message); +size_t opentelemetry__proto__profiles__v1development__profile__pack + (const Opentelemetry__Proto__Profiles__V1development__Profile *message, uint8_t *out); -size_t opentelemetry__proto__profiles__v1development__profile_container__pack_to_buffer - (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, +size_t opentelemetry__proto__profiles__v1development__profile__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Profile *message, ProtobufCBuffer *buffer); -Opentelemetry__Proto__Profiles__V1development__ProfileContainer * - opentelemetry__proto__profiles__v1development__profile_container__unpack +Opentelemetry__Proto__Profiles__V1development__Profile * + opentelemetry__proto__profiles__v1development__profile__unpack (ProtobufCAllocator *allocator, size_t len, const uint8_t *data); -void opentelemetry__proto__profiles__v1development__profile_container__free_unpacked - (Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, +void opentelemetry__proto__profiles__v1development__profile__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Profile *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Link methods */ +void opentelemetry__proto__profiles__v1development__link__init + (Opentelemetry__Proto__Profiles__V1development__Link *message); +size_t opentelemetry__proto__profiles__v1development__link__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Link *message); +size_t opentelemetry__proto__profiles__v1development__link__pack + (const Opentelemetry__Proto__Profiles__V1development__Link *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__link__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Link *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Link * + opentelemetry__proto__profiles__v1development__link__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__link__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Link *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__ValueType methods */ +void opentelemetry__proto__profiles__v1development__value_type__init + (Opentelemetry__Proto__Profiles__V1development__ValueType *message); +size_t opentelemetry__proto__profiles__v1development__value_type__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message); +size_t opentelemetry__proto__profiles__v1development__value_type__pack + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__value_type__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__ValueType * + opentelemetry__proto__profiles__v1development__value_type__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__value_type__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__ValueType *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Sample methods */ +void opentelemetry__proto__profiles__v1development__sample__init + (Opentelemetry__Proto__Profiles__V1development__Sample *message); +size_t opentelemetry__proto__profiles__v1development__sample__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Sample *message); +size_t opentelemetry__proto__profiles__v1development__sample__pack + (const Opentelemetry__Proto__Profiles__V1development__Sample *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__sample__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Sample *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Sample * + opentelemetry__proto__profiles__v1development__sample__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__sample__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Sample *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Mapping methods */ +void opentelemetry__proto__profiles__v1development__mapping__init + (Opentelemetry__Proto__Profiles__V1development__Mapping *message); +size_t opentelemetry__proto__profiles__v1development__mapping__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message); +size_t opentelemetry__proto__profiles__v1development__mapping__pack + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__mapping__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Mapping * + opentelemetry__proto__profiles__v1development__mapping__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__mapping__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Mapping *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Stack methods */ +void opentelemetry__proto__profiles__v1development__stack__init + (Opentelemetry__Proto__Profiles__V1development__Stack *message); +size_t opentelemetry__proto__profiles__v1development__stack__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Stack *message); +size_t opentelemetry__proto__profiles__v1development__stack__pack + (const Opentelemetry__Proto__Profiles__V1development__Stack *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__stack__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Stack *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Stack * + opentelemetry__proto__profiles__v1development__stack__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__stack__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Stack *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Location methods */ +void opentelemetry__proto__profiles__v1development__location__init + (Opentelemetry__Proto__Profiles__V1development__Location *message); +size_t opentelemetry__proto__profiles__v1development__location__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Location *message); +size_t opentelemetry__proto__profiles__v1development__location__pack + (const Opentelemetry__Proto__Profiles__V1development__Location *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__location__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Location *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Location * + opentelemetry__proto__profiles__v1development__location__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__location__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Location *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Line methods */ +void opentelemetry__proto__profiles__v1development__line__init + (Opentelemetry__Proto__Profiles__V1development__Line *message); +size_t opentelemetry__proto__profiles__v1development__line__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Line *message); +size_t opentelemetry__proto__profiles__v1development__line__pack + (const Opentelemetry__Proto__Profiles__V1development__Line *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__line__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Line *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Line * + opentelemetry__proto__profiles__v1development__line__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__line__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Line *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__Function methods */ +void opentelemetry__proto__profiles__v1development__function__init + (Opentelemetry__Proto__Profiles__V1development__Function *message); +size_t opentelemetry__proto__profiles__v1development__function__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__Function *message); +size_t opentelemetry__proto__profiles__v1development__function__pack + (const Opentelemetry__Proto__Profiles__V1development__Function *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__function__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__Function *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__Function * + opentelemetry__proto__profiles__v1development__function__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__function__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__Function *message, + ProtobufCAllocator *allocator); +/* Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit methods */ +void opentelemetry__proto__profiles__v1development__key_value_and_unit__init + (Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *message); +size_t opentelemetry__proto__profiles__v1development__key_value_and_unit__get_packed_size + (const Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *message); +size_t opentelemetry__proto__profiles__v1development__key_value_and_unit__pack + (const Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *message, + uint8_t *out); +size_t opentelemetry__proto__profiles__v1development__key_value_and_unit__pack_to_buffer + (const Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *message, + ProtobufCBuffer *buffer); +Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit * + opentelemetry__proto__profiles__v1development__key_value_and_unit__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void opentelemetry__proto__profiles__v1development__key_value_and_unit__free_unpacked + (Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *message, ProtobufCAllocator *allocator); /* --- per-message closures --- */ +typedef void (*Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary_Closure) + (const Opentelemetry__Proto__Profiles__V1development__ProfilesDictionary *message, + void *closure_data); typedef void (*Opentelemetry__Proto__Profiles__V1development__ProfilesData_Closure) (const Opentelemetry__Proto__Profiles__V1development__ProfilesData *message, void *closure_data); @@ -270,8 +870,35 @@ typedef void (*Opentelemetry__Proto__Profiles__V1development__ResourceProfiles_C typedef void (*Opentelemetry__Proto__Profiles__V1development__ScopeProfiles_Closure) (const Opentelemetry__Proto__Profiles__V1development__ScopeProfiles *message, void *closure_data); -typedef void (*Opentelemetry__Proto__Profiles__V1development__ProfileContainer_Closure) - (const Opentelemetry__Proto__Profiles__V1development__ProfileContainer *message, +typedef void (*Opentelemetry__Proto__Profiles__V1development__Profile_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Profile *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Link_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Link *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__ValueType_Closure) + (const Opentelemetry__Proto__Profiles__V1development__ValueType *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Sample_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Sample *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Mapping_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Mapping *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Stack_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Stack *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Location_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Location *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Line_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Line *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__Function_Closure) + (const Opentelemetry__Proto__Profiles__V1development__Function *message, + void *closure_data); +typedef void (*Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit_Closure) + (const Opentelemetry__Proto__Profiles__V1development__KeyValueAndUnit *message, void *closure_data); /* --- services --- */ @@ -279,10 +906,20 @@ typedef void (*Opentelemetry__Proto__Profiles__V1development__ProfileContainer_C /* --- descriptors --- */ +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profiles_dictionary__descriptor; extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profiles_data__descriptor; extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__resource_profiles__descriptor; extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__scope_profiles__descriptor; -extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profile_container__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__profile__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__link__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__value_type__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__sample__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__mapping__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__stack__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__location__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__line__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__function__descriptor; +extern const ProtobufCMessageDescriptor opentelemetry__proto__profiles__v1development__key_value_and_unit__descriptor; PROTOBUF_C__END_DECLS diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.c index c250bf6c4a5..84fbabfdc4c 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.c @@ -52,7 +52,7 @@ void opentelemetry__proto__resource__v1__resource__free_unpacked assert(message->base.descriptor == &opentelemetry__proto__resource__v1__resource__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } -static const ProtobufCFieldDescriptor opentelemetry__proto__resource__v1__resource__field_descriptors[2] = +static const ProtobufCFieldDescriptor opentelemetry__proto__resource__v1__resource__field_descriptors[3] = { { "attributes", @@ -78,15 +78,28 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__resource__v1__resour 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "entity_refs", + 3, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(Opentelemetry__Proto__Resource__V1__Resource, n_entity_refs), + offsetof(Opentelemetry__Proto__Resource__V1__Resource, entity_refs), + &opentelemetry__proto__common__v1__entity_ref__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned opentelemetry__proto__resource__v1__resource__field_indices_by_name[] = { 0, /* field[0] = attributes */ 1, /* field[1] = dropped_attributes_count */ + 2, /* field[2] = entity_refs */ }; static const ProtobufCIntRange opentelemetry__proto__resource__v1__resource__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 2 } + { 0, 3 } }; const ProtobufCMessageDescriptor opentelemetry__proto__resource__v1__resource__descriptor = { @@ -96,7 +109,7 @@ const ProtobufCMessageDescriptor opentelemetry__proto__resource__v1__resource__d "Opentelemetry__Proto__Resource__V1__Resource", "opentelemetry.proto.resource.v1", sizeof(Opentelemetry__Proto__Resource__V1__Resource), - 2, + 3, opentelemetry__proto__resource__v1__resource__field_descriptors, opentelemetry__proto__resource__v1__resource__field_indices_by_name, 1, opentelemetry__proto__resource__v1__resource__number_ranges, diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.h index 7def59296d0..4650dd70a8c 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/resource/v1/resource.pb-c.h @@ -9,9 +9,9 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +# error This file was generated by a newer version of protobuf-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005002 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protobuf-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protobuf-c. #endif #include "opentelemetry/proto/common/v1/common.pb-c.h" @@ -34,18 +34,26 @@ struct Opentelemetry__Proto__Resource__V1__Resource * Set of attributes that describe the resource. * Attribute keys MUST be unique (it is not allowed to have more than one * attribute with the same key). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_attributes; Opentelemetry__Proto__Common__V1__KeyValue **attributes; /* - * dropped_attributes_count is the number of dropped attributes. If the value is 0, then + * The number of dropped attributes. If the value is 0, then * no attributes were dropped. */ uint32_t dropped_attributes_count; + /* + * Set of entities that participate in this Resource. + * Note: keys in the references MUST exist in attributes of this message. + * Status: [Development] + */ + size_t n_entity_refs; + Opentelemetry__Proto__Common__V1__EntityRef **entity_refs; }; #define OPENTELEMETRY__PROTO__RESOURCE__V1__RESOURCE__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__resource__v1__resource__descriptor) \ - , 0,NULL, 0 } +, 0,NULL, 0, 0,NULL } /* Opentelemetry__Proto__Resource__V1__Resource methods */ diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.c b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.c index 3a7f82cfe52..54bf8b44170 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.c +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.c @@ -287,7 +287,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__trace__v1__resource_ { "resource", 1, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Trace__V1__ResourceSpans, resource), @@ -351,7 +351,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__trace__v1__scope_spa { "scope", 1, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Trace__V1__ScopeSpans, scope), @@ -799,7 +799,7 @@ static const ProtobufCFieldDescriptor opentelemetry__proto__trace__v1__span__fie { "status", 15, - PROTOBUF_C_LABEL_NONE, + PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_MESSAGE, 0, /* quantifier_offset */ offsetof(Opentelemetry__Proto__Trace__V1__Span, status), diff --git a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.h b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.h index b0d699f4af7..f4e7a5a794b 100644 --- a/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.h +++ b/lib/fluent-otel-proto/proto_c/opentelemetry/proto/trace/v1/trace.pb-c.h @@ -9,9 +9,9 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1005000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +# error This file was generated by a newer version of protobuf-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1005002 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protobuf-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protobuf-c. #endif #include "opentelemetry/proto/common/v1/common.pb-c.h" @@ -147,7 +147,7 @@ struct Opentelemetry__Proto__Trace__V1__TracesData }; #define OPENTELEMETRY__PROTO__TRACE__V1__TRACES_DATA__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__trace__v1__traces_data__descriptor) \ - , 0,NULL } +, 0,NULL } /* @@ -168,7 +168,8 @@ struct Opentelemetry__Proto__Trace__V1__ResourceSpans Opentelemetry__Proto__Trace__V1__ScopeSpans **scope_spans; /* * The Schema URL, if known. This is the identifier of the Schema that the resource data - * is recorded in. To learn more about Schema URL see + * is recorded in. Notably, the last part of the URL path is the version number of the + * schema: http[s]://server[:port]/path/. To learn more about Schema URL see * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url * This schema_url applies to the data in the "resource" field. It does not apply * to the data in the "scope_spans" field which have their own schema_url field. @@ -177,7 +178,7 @@ struct Opentelemetry__Proto__Trace__V1__ResourceSpans }; #define OPENTELEMETRY__PROTO__TRACE__V1__RESOURCE_SPANS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__trace__v1__resource_spans__descriptor) \ - , NULL, 0,NULL, (char *)protobuf_c_empty_string } +, NULL, 0,NULL, (char *)protobuf_c_empty_string } /* @@ -199,15 +200,17 @@ struct Opentelemetry__Proto__Trace__V1__ScopeSpans Opentelemetry__Proto__Trace__V1__Span **spans; /* * The Schema URL, if known. This is the identifier of the Schema that the span data - * is recorded in. To learn more about Schema URL see + * is recorded in. Notably, the last part of the URL path is the version number of the + * schema: http[s]://server[:port]/path/. To learn more about Schema URL see * https://opentelemetry.io/docs/specs/otel/schemas/#schema-url - * This schema_url applies to all spans and span events in the "spans" field. + * This schema_url applies to the data in the "scope" field and all spans and span + * events in the "spans" field. */ char *schema_url; }; #define OPENTELEMETRY__PROTO__TRACE__V1__SCOPE_SPANS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__trace__v1__scope_spans__descriptor) \ - , NULL, 0,NULL, (char *)protobuf_c_empty_string } +, NULL, 0,NULL, (char *)protobuf_c_empty_string } /* @@ -218,30 +221,31 @@ struct Opentelemetry__Proto__Trace__V1__Span__Event { ProtobufCMessage base; /* - * time_unix_nano is the time the event occurred. + * The time the event occurred. */ uint64_t time_unix_nano; /* - * name of the event. + * The name of the event. * This field is semantically required to be set to non-empty string. */ char *name; /* - * attributes is a collection of attribute key/value pairs on the event. + * A collection of attribute key/value pairs on the event. * Attribute keys MUST be unique (it is not allowed to have more than one * attribute with the same key). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_attributes; Opentelemetry__Proto__Common__V1__KeyValue **attributes; /* - * dropped_attributes_count is the number of dropped attributes. If the value is 0, + * The number of dropped attributes. If the value is 0, * then no attributes were dropped. */ uint32_t dropped_attributes_count; }; #define OPENTELEMETRY__PROTO__TRACE__V1__SPAN__EVENT__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__trace__v1__span__event__descriptor) \ - , 0, (char *)protobuf_c_empty_string, 0,NULL, 0 } +, 0, (char *)protobuf_c_empty_string, 0,NULL, 0 } /* @@ -267,14 +271,15 @@ struct Opentelemetry__Proto__Trace__V1__Span__Link */ char *trace_state; /* - * attributes is a collection of attribute key/value pairs on the link. + * A collection of attribute key/value pairs on the link. * Attribute keys MUST be unique (it is not allowed to have more than one * attribute with the same key). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_attributes; Opentelemetry__Proto__Common__V1__KeyValue **attributes; /* - * dropped_attributes_count is the number of dropped attributes. If the value is 0, + * The number of dropped attributes. If the value is 0, * then no attributes were dropped. */ uint32_t dropped_attributes_count; @@ -296,7 +301,7 @@ struct Opentelemetry__Proto__Trace__V1__Span__Link }; #define OPENTELEMETRY__PROTO__TRACE__V1__SPAN__LINK__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__trace__v1__span__link__descriptor) \ - , {0,NULL}, {0,NULL}, (char *)protobuf_c_empty_string, 0,NULL, 0, 0 } +, {0,NULL}, {0,NULL}, (char *)protobuf_c_empty_string, 0,NULL, 0, 0 } /* @@ -370,7 +375,7 @@ struct Opentelemetry__Proto__Trace__V1__Span */ Opentelemetry__Proto__Trace__V1__Span__SpanKind kind; /* - * start_time_unix_nano is the start time of the span. On the client side, this is the time + * The start time of the span. On the client side, this is the time * kept by the local machine where the span execution starts. On the server side, this * is the time when the server's application handler starts running. * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. @@ -378,7 +383,7 @@ struct Opentelemetry__Proto__Trace__V1__Span */ uint64_t start_time_unix_nano; /* - * end_time_unix_nano is the end time of the span. On the client side, this is the time + * The end time of the span. On the client side, this is the time * kept by the local machine where the span execution ends. On the server side, this * is the time when the server application handler stops running. * Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. @@ -386,43 +391,42 @@ struct Opentelemetry__Proto__Trace__V1__Span */ uint64_t end_time_unix_nano; /* - * attributes is a collection of key/value pairs. Note, global attributes + * A collection of key/value pairs. Note, global attributes * like server name can be set using the resource API. Examples of attributes: * "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" * "/http/server_latency": 300 * "example.com/myattribute": true * "example.com/score": 10.239 - * The OpenTelemetry API specification further restricts the allowed value types: - * 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). + * The behavior of software that receives duplicated keys can be unpredictable. */ size_t n_attributes; Opentelemetry__Proto__Common__V1__KeyValue **attributes; /* - * dropped_attributes_count is the number of attributes that were discarded. Attributes + * 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_t dropped_attributes_count; /* - * events is a collection of Event items. + * A collection of Event items. */ size_t n_events; Opentelemetry__Proto__Trace__V1__Span__Event **events; /* - * dropped_events_count is the number of dropped events. If the value is 0, then no + * The number of dropped events. If the value is 0, then no * events were dropped. */ uint32_t dropped_events_count; /* - * links is a collection of Links, which are references from this span to a span + * A collection of Links, which are references from this span to a span * in the same or different trace. */ size_t n_links; Opentelemetry__Proto__Trace__V1__Span__Link **links; /* - * dropped_links_count is the number of dropped links after the maximum size was + * The number of dropped links after the maximum size was * enforced. If this value is 0, then no links were dropped. */ uint32_t dropped_links_count; @@ -434,7 +438,7 @@ struct Opentelemetry__Proto__Trace__V1__Span }; #define OPENTELEMETRY__PROTO__TRACE__V1__SPAN__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__trace__v1__span__descriptor) \ - , {0,NULL}, {0,NULL}, (char *)protobuf_c_empty_string, {0,NULL}, 0, (char *)protobuf_c_empty_string, OPENTELEMETRY__PROTO__TRACE__V1__SPAN__SPAN_KIND__SPAN_KIND_UNSPECIFIED, 0, 0, 0,NULL, 0, 0,NULL, 0, 0,NULL, 0, NULL } +, {0,NULL}, {0,NULL}, (char *)protobuf_c_empty_string, {0,NULL}, 0, (char *)protobuf_c_empty_string, OPENTELEMETRY__PROTO__TRACE__V1__SPAN__SPAN_KIND__SPAN_KIND_UNSPECIFIED, 0, 0, 0,NULL, 0, 0,NULL, 0, 0,NULL, 0, NULL } /* @@ -455,7 +459,7 @@ struct Opentelemetry__Proto__Trace__V1__Status }; #define OPENTELEMETRY__PROTO__TRACE__V1__STATUS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&opentelemetry__proto__trace__v1__status__descriptor) \ - , (char *)protobuf_c_empty_string, OPENTELEMETRY__PROTO__TRACE__V1__STATUS__STATUS_CODE__STATUS_CODE_UNSET } +, (char *)protobuf_c_empty_string, OPENTELEMETRY__PROTO__TRACE__V1__STATUS__STATUS_CODE__STATUS_CODE_UNSET } /* Opentelemetry__Proto__Trace__V1__TracesData methods */ diff --git a/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.c b/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.c index 776ee4fb594..005bc196f8e 100644 --- a/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.c +++ b/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2023, Dave Benson and the protobuf-c authors. + * Copyright (c) 2008-2025, Dave Benson and the protobuf-c authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,14 +28,14 @@ */ /*! \file - * Support library for `protoc-c` generated code. + * Support library for `protoc-gen-c` generated code. * * This file implements the public API used by the code generated - * by `protoc-c`. + * by `protoc-gen-c`. * * \authors Dave Benson and the protobuf-c authors * - * \copyright 2008-2014. Licensed under the terms of the [BSD-2-Clause] license. + * \copyright 2008-2025. Licensed under the terms of the [BSD-2-Clause] license. */ /** @@ -3278,6 +3278,8 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc, n_unknown * sizeof(ProtobufCMessageUnknownField)); if (rv->unknown_fields == NULL) goto error_cleanup; + } else { + rv->unknown_fields = NULL; } /* do real parsing */ diff --git a/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.h b/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.h old mode 100755 new mode 100644 index a0625117e8d..cb5c82ec43d --- a/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.h +++ b/lib/fluent-otel-proto/proto_c/protobuf-c/protobuf-c.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2023, Dave Benson and the protobuf-c authors. + * Copyright (c) 2008-2025, Dave Benson and the protobuf-c authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,16 +34,17 @@ * * This file defines the public API for the `libprotobuf-c` support library. * This API includes interfaces that can be used directly by client code as well - * as the interfaces used by the code generated by the `protoc-c` compiler. + * as the interfaces used by the code generated by the `protoc-gen-c` compiler + * plugin. * * The `libprotobuf-c` support library performs the actual serialization and * deserialization of Protocol Buffers messages. It interacts with structures, - * definitions, and metadata generated by the `protoc-c` compiler from .proto - * files. + * definitions, and metadata generated by the `protoc-gen-c` compiler plugin + * from .proto files. * * \authors Dave Benson and the `protobuf-c` authors. * - * \copyright 2008-2014. Licensed under the terms of the [BSD-2-Clause] license. + * \copyright 2008-2025. Licensed under the terms of the [BSD-2-Clause] license. * * [protobuf-c]: https://github.com/protobuf-c/protobuf-c * [Protocol Buffers]: https://developers.google.com/protocol-buffers/ @@ -74,7 +75,7 @@ * * - Identifiers for functions and globals are all lowercase, with camel case * words separated by single underscores. For example, one of the function - * prototypes generated by `protoc-c` for the above example: + * prototypes generated by `protoc-gen-c` for the above example: * ~~~{.c} Foo__Bar__BazBah * @@ -794,16 +795,16 @@ protobuf_c_version_number(void); * The version of the protobuf-c headers, represented as a string using the same * format as protobuf_c_version(). */ -#define PROTOBUF_C_VERSION "1.5.0" +#define PROTOBUF_C_VERSION "1.5.2" /** * The version of the protobuf-c headers, represented as an integer using the * same format as protobuf_c_version_number(). */ -#define PROTOBUF_C_VERSION_NUMBER 1005000 +#define PROTOBUF_C_VERSION_NUMBER 1005002 /** - * The minimum protoc-c version which works with the current version of the + * The minimum protoc-gen-c version which works with the current version of the * protobuf-c headers. */ #define PROTOBUF_C_MIN_COMPILER_VERSION 1000000 diff --git a/lib/fluent-otel-proto/src/CMakeLists.txt b/lib/fluent-otel-proto/src/CMakeLists.txt index 6fc714b52f2..b34a41b8c44 100644 --- a/lib/fluent-otel-proto/src/CMakeLists.txt +++ b/lib/fluent-otel-proto/src/CMakeLists.txt @@ -36,7 +36,6 @@ endif() if (FLUENT_PROTO_PROFILES) set(src ${src} ${OTEL_C_FILES}/proto/profiles/v1development/profiles.pb-c.c) - set(src ${src} ${OTEL_C_FILES}/proto/profiles/v1development/pprofextended.pb-c.c) set(src ${src} ${OTEL_C_FILES}/proto/collector/profiles/v1development/profiles_service.pb-c.c) endif() diff --git a/plugins/in_opentelemetry/opentelemetry.c b/plugins/in_opentelemetry/opentelemetry.c index c3617197a1f..f2c0430ea0a 100644 --- a/plugins/in_opentelemetry/opentelemetry.c +++ b/plugins/in_opentelemetry/opentelemetry.c @@ -211,7 +211,7 @@ static struct flb_config_map config_map[] = { "environments" }, { - FLB_CONFIG_MAP_BOOL, "encode_profiles_as_log", "true", + FLB_CONFIG_MAP_BOOL, "encode_profiles_as_log", "false", 0, FLB_TRUE, offsetof(struct flb_opentelemetry, encode_profiles_as_log), "Encode profiles received as text and ingest them in the logging pipeline" }, diff --git a/plugins/in_opentelemetry/opentelemetry_prot.c b/plugins/in_opentelemetry/opentelemetry_prot.c index fa102a4a4be..a974049d3a2 100644 --- a/plugins/in_opentelemetry/opentelemetry_prot.c +++ b/plugins/in_opentelemetry/opentelemetry_prot.c @@ -46,6 +46,39 @@ #define HTTP_CONTENT_JSON 0 +static int is_grpc_content_type(const char *content_type) +{ + if (content_type == NULL) { + return FLB_FALSE; + } + + if (strncasecmp(content_type, "application/grpc", 16) != 0) { + return FLB_FALSE; + } + + if (content_type[16] == '\0' || + content_type[16] == '+' || + content_type[16] == ';') { + return FLB_TRUE; + } + + return FLB_FALSE; +} + +static int is_profiles_export_path(const char *path) +{ + if (path == NULL) { + return FLB_FALSE; + } + + if (strcmp(path, "/opentelemetry.proto.collector.profiles.v1experimental.ProfilesService/Export") == 0 || + strcmp(path, "/opentelemetry.proto.collector.profiles.v1development.ProfilesService/Export") == 0) { + return FLB_TRUE; + } + + return FLB_FALSE; +} + static int send_response(struct http_conn *conn, int http_status, char *message) { int len; @@ -717,6 +750,17 @@ static int send_grpc_response_ng(struct flb_http_response *response, return 0; } +static int send_grpc_error_response_ng(struct flb_http_response *response, + int grpc_status, + const char *grpc_message) +{ + const char *message; + + message = grpc_message != NULL ? grpc_message : ""; + + return send_grpc_response_ng(response, NULL, 0, grpc_status, (char *) message); +} + static int send_export_logs_service_response_ng(struct flb_http_response *response, int status) { @@ -838,6 +882,47 @@ static int send_export_traces_service_response_ng(struct flb_http_response *resp return 0; } + +static int send_export_profiles_service_response_ng(struct flb_http_response *response, + int status) +{ + uint8_t *message_buffer; + size_t message_length; + const char *grpc_message; + int grpc_status; + Opentelemetry__Proto__Collector__Profiles__V1development__ExportProfilesServiceResponse message; + + if (status == 0) { + opentelemetry__proto__collector__profiles__v1development__export_profiles_service_response__init(&message); + + message_length = opentelemetry__proto__collector__profiles__v1development__export_profiles_service_response__get_packed_size(&message); + + message_buffer = flb_calloc(message_length, sizeof(uint8_t)); + if (message_buffer == NULL) { + return -1; + } + + opentelemetry__proto__collector__profiles__v1development__export_profiles_service_response__pack(&message, message_buffer); + + grpc_status = 0; + grpc_message = "-"; + } + else { + grpc_status = 2; /* gRPC UNKNOWN */ + grpc_message = "Serialization error."; + message_buffer = NULL; + message_length = 0; + } + + send_grpc_response_ng(response, message_buffer, message_length, grpc_status, (char *) grpc_message); + + if (message_buffer != NULL) { + flb_free(message_buffer); + } + + return 0; +} + static int process_payload_metrics_ng(struct flb_opentelemetry *ctx, flb_sds_t tag, struct flb_http_request *request, @@ -857,7 +942,7 @@ static int process_payload_metrics_ng(struct flb_opentelemetry *ctx, flb_plg_error(ctx->ins, "Unsupported metrics with content type %s", request->content_type); } - else if (strcasecmp(request->content_type, "application/grpc") == 0 || + else if (is_grpc_content_type(request->content_type) == FLB_TRUE || strcasecmp(request->content_type, "application/x-protobuf") == 0 || strcasecmp(request->content_type, "application/json") == 0) { @@ -906,7 +991,9 @@ static int ingest_profiles_context_as_log_entry(struct flb_opentelemetry *ctx, return -1; } - ret = cprof_encode_text_create(&text_encoded_profiles_context, profiles_context); + ret = cprof_encode_text_create(&text_encoded_profiles_context, + profiles_context, + CPROF_ENCODE_TEXT_RENDER_DICTIONARIES_AND_INDEXES); if (ret != CPROF_ENCODE_TEXT_SUCCESS) { flb_log_event_encoder_destroy(encoder); @@ -958,7 +1045,8 @@ static int ingest_profiles_context_as_log_entry(struct flb_opentelemetry *ctx, static int process_payload_profiles_ng(struct flb_opentelemetry *ctx, flb_sds_t tag, struct flb_http_request *request, - struct flb_http_response *response) + char *payload, + size_t payload_size) { struct cprof *profiles_context; size_t offset; @@ -974,26 +1062,15 @@ static int process_payload_profiles_ng(struct flb_opentelemetry *ctx, return -1; } - else if (strcasecmp(request->content_type, "application/x-protobuf") == 0) { - flb_error("[otel] unsuported profiles encoding type : %s", - request->content_type); - - return -1; - } - else if (strcasecmp(request->content_type, "application/grpc") == 0) { - if (cfl_sds_len(request->body) < 5) { - flb_error("[otel] malformed grpc packet of size %zu", - cfl_sds_len(request->body)); - - return -1; - } - + else if (is_grpc_content_type(request->content_type) == FLB_TRUE || + strcasecmp(request->content_type, "application/protobuf") == 0 || + strcasecmp(request->content_type, "application/x-protobuf") == 0) { profiles_context = NULL; offset = 0; ret = cprof_decode_opentelemetry_create(&profiles_context, - &((uint8_t *) request->body)[5], - (cfl_sds_len(request->body)) - 5, + (uint8_t *) payload, + payload_size, &offset); if (ret != CPROF_DECODE_OPENTELEMETRY_SUCCESS) { @@ -1046,6 +1123,8 @@ static int send_export_service_response_ng(struct flb_http_response *response, return send_export_traces_service_response_ng(response, result); case 'L': return send_export_logs_service_response_ng(response, result); + case 'P': + return send_export_profiles_service_response_ng(response, result); default: return -1; } @@ -1072,6 +1151,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, char *encoding = NULL; size_t encoding_size = 0; char *buf = (char *) request->body; + size_t request_body_size = 0; char *payload = NULL; size_t payload_size = 0; size_t max_grpc_size = 16 * 1024 * 1024; /* 16M limit per message */ @@ -1098,7 +1178,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, grpc_request = FLB_TRUE; } else if (context->profile_support_enabled && - strcmp(request->path, "/opentelemetry.proto.collector.profiles.v1experimental.ProfilesService/Export") == 0) { + is_profiles_export_path(request->path) == FLB_TRUE) { grpc_request = FLB_TRUE; } else { @@ -1110,38 +1190,59 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, /* HTTP/1.1 needs Host header */ if (request->protocol_version == HTTP_PROTOCOL_VERSION_11 && request->host == NULL) { + if (grpc_request) { + send_grpc_error_response_ng(response, 3, "missing host header"); + return -1; + } return -1; } if (request->method != HTTP_METHOD_POST) { - send_response_ng(response, 400, "error: invalid HTTP method\n"); + if (grpc_request) { + send_grpc_error_response_ng(response, 3, "invalid HTTP method"); + } + else { + send_response_ng(response, 400, "error: invalid HTTP method\n"); + } return -1; } /* check content-length */ if (request->content_length <= 0) { - send_response_ng(response, 400, "error: invalid content-length\n"); + if (grpc_request) { + send_grpc_error_response_ng(response, 3, "invalid content-length"); + } + else { + send_response_ng(response, 400, "error: invalid content-length\n"); + } return -1; } if (request->body == NULL) { - send_response_ng(response, 400, "error: invalid payload\n"); + if (grpc_request) { + send_grpc_error_response_ng(response, 3, "invalid payload"); + } + else { + send_response_ng(response, 400, "error: invalid payload\n"); + } return -1; } + request_body_size = cfl_sds_len(request->body); /* If this is a gRPC request validate the content-type */ if (grpc_request && request->content_type == NULL) { - send_response_ng(response, 400, "error: missing content type for expected gRPC request\n"); + send_grpc_error_response_ng(response, 3, "missing content-type"); return -1; } /* Check if the payload is gRPC compressed */ - if (grpc_request && strcasecmp(request->content_type, "application/grpc") == 0) { + if (grpc_request && is_grpc_content_type(request->content_type) == FLB_TRUE) { next_grpc_message: - if (grpc_offset + 5 > cfl_sds_len(request->body)) { - send_response_ng(response, 400, "error: invalid gRPC packet\n"); + if (grpc_offset > request_body_size || + request_body_size - grpc_offset < 5) { + send_grpc_error_response_ng(response, 3, "invalid gRPC packet"); return -1; } @@ -1152,12 +1253,12 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, ((uint64_t) (uint8_t) buf[4]); if (grpc_size == 0 || grpc_size > max_grpc_size) { - send_response_ng(response, 400, "error: gRPC message size out of valid range\n"); + send_grpc_error_response_ng(response, 3, "gRPC message size out of valid range"); return -1; } - if (cfl_sds_len(request->body) < grpc_size + 5) { - send_response_ng(response, 400, "error: invalid gRPC packet\n"); + if (request_body_size - grpc_offset < grpc_size + 5) { + send_grpc_error_response_ng(response, 3, "invalid gRPC packet"); return -1; } @@ -1169,7 +1270,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, /* malformed gRPC message */ if (ret == -1) { - send_response_ng(response, 400, "error: missing gRPC encoding\n"); + send_grpc_error_response_ng(response, 3, "missing gRPC encoding"); return -1; } @@ -1202,12 +1303,12 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, buf, grpc_size); } else { - send_response_ng(response, 400, "error: unsupported gRPC encoding\n"); + send_grpc_error_response_ng(response, 12, "unsupported gRPC encoding"); return -1; } if (ret <= 0) { - send_response_ng(response, 400, "error: decompression error\n"); + send_grpc_error_response_ng(response, 13, "decompression error"); return -1; } @@ -1215,7 +1316,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, } else { /* uncompressed payload */ - payload = buf + grpc_offset + 5; + payload = buf + 5; payload_size = grpc_size; grpc_uncompressed = FLB_FALSE; } @@ -1273,7 +1374,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, payload, payload_size); } else if (context->profile_support_enabled && - strcmp(request->path, "/opentelemetry.proto.collector.profiles.v1experimental.ProfilesService/Export") == 0) { + is_profiles_export_path(request->path) == FLB_TRUE) { payload_type = 'P'; if (context->tag_from_uri == FLB_TRUE) { tag = flb_sds_create("v1development_profiles"); @@ -1281,7 +1382,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, else { tag = flb_sds_create(context->ins->tag); } - ret = process_payload_profiles_ng(context, tag, request, response); + ret = process_payload_profiles_ng(context, tag, request, payload, payload_size); } if (grpc_request) { @@ -1292,7 +1393,7 @@ int opentelemetry_prot_handle_ng(struct flb_http_request *request, } /* check if we have more gRPC messages to process */ - if (grpc_offset < cfl_sds_len(request->body)) { + if (grpc_offset < request_body_size) { buf = (char *) request->body + grpc_offset; goto next_grpc_message; } diff --git a/plugins/out_stdout/stdout.c b/plugins/out_stdout/stdout.c index 2cbb68ee781..082663a7b66 100644 --- a/plugins/out_stdout/stdout.c +++ b/plugins/out_stdout/stdout.c @@ -186,7 +186,9 @@ static void print_profiles_text(struct flb_output_instance *ins, bytes, &off)) == CPROF_DECODE_MSGPACK_SUCCESS) { /* convert to text representation */ - ret = cprof_encode_text_create(&text, profiles_context); + ret = cprof_encode_text_create(&text, + profiles_context, + CPROF_ENCODE_TEXT_RENDER_RESOLVED); if (ret != CPROF_ENCODE_TEXT_SUCCESS) { flb_plg_debug(ins, "cprofiles text encoder returned : %d", ret);