Skip to content

service.instance.id is sent as an integer, not as a string in protobuf messages #688

Open
@aquap

Description

@aquap

I am consuming OpenTelemetry events from an Elixir Phoenix application that depends on the hex package :opentelemetry 1.3.1 and exported using the http_protobuf exporter.

The service.instance.id is being received unexpectedly not as a long UUID-like string, but as a large negative integer by my consumer.

The OpenTelemetry documentation indicates that the (experimental) service.instance.id parameter should be a string, and the examples show some kind of UUID string.

https://opentelemetry.io/docs/specs/semconv/resource/#service

To consume this value from BEAM language opentelemetry, it would be useful if it were either a UUID or a long hex string.

I have instrumented the protobuf decoder in my collector, and it appears that service.instance.id is being sent by opentelemetry-erlang as a protobuf integer, rather than a protobuf string or binary. The resource attributes aren't definitively typed in the proto definitions, so the protobuf type is probably being identified from the type of the erlang variable.

Quickly reviewing the code in otel_resource_detector.erl shows this value being generated from otel_id_generator:generate_trace_id/0 which in other contexts - providing trace.id in spans - delivers a protobuf binary which is easily, consistently and mostly automatically coerced to a long hex string by the consumer because of the typing in the proto definition for spans.

As a guess (not being somebody comfortable with erlang), I'd suggest stringifying the values in otel_resource_detector.erl in the function add_service_instance/1 and hopefully the protobuf encoder in the exporter will pick the right type.

Activity

tsloughter

tsloughter commented on Feb 7, 2024

@tsloughter
Member

Thanks for the report! This should definitely be converted to a string in otel_resource_detector. We will get that fixed.

added
bugSomething isn't working
specA change to the SDK specification that must be implemented.
semconvSemantic Convetions
on Feb 7, 2024
Annosha

Annosha commented on Oct 17, 2024

@Annosha

Hi @tsloughter if this is a beginner friendly issue can I work on it?

tsloughter

tsloughter commented on Oct 17, 2024

@tsloughter
Member

@Annosha yes, I think it is actually. I just forgot all about it. Happy to help you with digging in if you need.

tsloughter

tsloughter commented on Oct 25, 2024

@tsloughter
Member

Update on this: Thanks to @Annosha for opening a PR but when reviewing I checked the semantic conventions (https://github.com/open-telemetry/semantic-conventions/blob/d9d1e21a5bbb37fe8facea323491d59342a5f810/docs/attributes-registry/service.md#service-instance-id) and we are actually all wrong at the moment.

Not only should this not be an integer but we shouldn't be using the node name as we are doing but instead using that as input to create a UUIDv5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsemconvSemantic ConvetionsspecA change to the SDK specification that must be implemented.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @tsloughter@aquap@Annosha

      Issue actions

        service.instance.id is sent as an integer, not as a string in protobuf messages · Issue #688 · open-telemetry/opentelemetry-erlang