open-telemetry / opentelemetry-erlang-api

Erlang/Elixir OpenTelemetry API
Apache License 2.0
60 stars 13 forks source link

Trouble with setting attributes in Elixir #87

Closed TylerPachal closed 3 years ago

TylerPachal commented 3 years ago

I have a collector setup with the following:

receivers:
  otlp:
    protocols:
      grpc:
  otlp/withendpoint:
    protocols:
      grpc:
        endpoint: 127.0.0.1:55680
processors:
  batch:
    timeout: 1s
    send_batch_size: 1024
exporters:
  file:
    path: ./export.json
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [file]

I have setup a simple mix project to test my setup, and everything is working except for the attributes. My code is:

OpenTelemetry.Tracer.with_span "my_span" do
  OpenTelemetry.Span.set_attribute("my_attribute", "my_value")
  IO.puts("Hello World")
end

And when I view the export.json from the collectors' file exporter I see attributes with keys but no values:

{
  "resourceSpans": [
    {
      "resource": {},
      "instrumentationLibrarySpans": [
        {
          "spans": [
            {
              "traceId": "dgXm9O5iuK3po4eyIdo3bg==",
              "spanId": "9048Pni5l9U=",
              "name": "my_span",
              "startTimeUnixNano": "1602593490423393000",
              "endTimeUnixNano": "1602593490423493000",
              "attributes": [
                {
                  "key": "my_attribute"     <------ Shouldn't there be a value here?
                }
              ],
              "status": {}
            }
          ]
        }
      ]
    }
  ]
}

Similarly, when I look in the Elastic APM UI I don't see any of the attributes.


This is my first time setting up this library, so it is possible I have done something wrong.

I tried adding some io:format() statements to the Erlang code and was able to observe that my attributes at least make it to the end_span function:

{:span, 302347528670894367161519873871600156673, 3902607265688963337, :undefined, :undefined, "my_span", :SPAN_KIND_UNSPECIFIED, -576460726049923000, -576460726049827000, [{"my_attribute", "my_value"}], [], [], :undefined, :undefined, 1, true, :undefined}
tsloughter commented 3 years ago

Hey, sorry, can you move this issue to the repo https://github.com/open-telemetry/opentelemetry-erlang

I will get this repo archived.

tsloughter commented 3 years ago

Closed because we are archiving this repo and will track this issue on the main repo https://github.com/open-telemetry/opentelemetry-erlang

In my latest PR this definitely has been resolved too https://github.com/open-telemetry/opentelemetry-erlang/pull/126