opentelemetry-sdk-workers icon indicating copy to clipboard operation
opentelemetry-sdk-workers copied to clipboard

Define SpanKind

Open oxcafedead opened this issue 1 year ago • 1 comments

Hi,

I have a question regarding SpanKind which is set to INTERNAL now.

As per docs:

  • https://opentelemetry.io/docs/concepts/signals/traces/#internal
  • https://opentelemetry.io/docs/reference/specification/trace/api/#spankind

INTERNAL span kind should be used to instrument some internal functions/operations within application process. Workers are technically a remote service, so I believe they should produce SERVER spans.

Overall, such inconsistency results in Elastic APM incorrectly "drawing" such spans on a timeline, because the timestamps of worker traces differ from client/backend traces, since they are sent in different times.

The current workaround for me looks like this:

const oTelSdk = new WorkersSDK(request, ctx, env, {
    service: "myWorker",
...
});
oTelSdk.span.kind = SpanKind.SERVER; // ugly hack :)

Is there possibility to change this default span kind or give possibility to override it on API level?

oxcafedead avatar Apr 06 '23 06:04 oxcafedead