Skip to content

Performance improvement for encoding protos with unchanged data #220

@tsloughter

Description

@tsloughter

I feel like I brought this up before but I forget where and didn't see an existing issue opened by me.

Basically I'd like to be able to re-use the unchanged parts of an encoded proto in later calls in cases like: https://github.com/open-telemetry/opentelemetry-erlang/blob/main/apps/opentelemetry_exporter/src/opentelemetry_exporter.erl#L500

In these protos that get encoded on every export of traces are parts like the Resource and each tracer's Instrumentation Scope that do not change. So being able to do something like:

PartialResourceSpans =  opentelemetry_exporter_trace_service_pb:encode_partial(#{resource => #{attributes => to_attributes(otel_attributes:map(Attributes)),
                                                                                        dropped_attributes_count => otel_attributes:dropped(Attributes)}}, export_trace_service_request),
opentelemetry_exporter_trace_service_pb:encode_msg(PartialResourceSpans, #{scope_spans => InstrumentationScopeSpans}, export_trace_service_request),

Then PartialResourceSpans could be kept in the state or an ets table for concurrent look up, and each export only have to encode InstrumentationScopeSpans (where those would also use the partial encoding function on their unchanging data).

Does that make sense? Do you think it would work with how encoding is done and be acceptable if I were to put together a PR?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions