open-telemetry / opentelemetry-erlang-contrib

OpenTelemetry instrumentation for Erlang & Elixir
https://opentelemetry.io
Apache License 2.0
153 stars 113 forks source link

Normalize HTTP instrumenters options #201

Open albertored opened 1 year ago

albertored commented 1 year ago

At the moment we have 3 HTTP server instumneters (cowboy, phoenix and elli) and 4 HTTP client ones (finch, httpoison, req and tesla). They expose some common option, some options that somehow overlap but are not equal and some options that are specific to that instrumenter.

Proposed options

The set of common options I would like to have on each HTTP instrumenter is the following:

Actual extra options

In addition to these options some library expose its own specific ones:

bryannaegele commented 1 year ago

tesla has the mark_status_ok options to allow setting the span status to ok to request that returns an HTTP status code that is normally mapped as an error. This is against semantic conventions, we should decide if extending this option to other instrumenters or removing it from tesla.

This is actually spec compliant and is contained in the API spec. Operators are allowed to mark a span as Ok unless explicitly prevented from doing so by another part of the spec. HTTP does not contain any prevention.

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status

albertored commented 1 year ago

The specification is very clear, thanks for sharing. I got confused by the HTTP semantic conventions (https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#status) where setting span status to error for codes >= 400 is a MUST

albertored commented 1 year ago

If this is the case (the span can be marked as ok as configured) then we should extend this functionality also to other libs and to 2xx and 3xx status codes, now it is allowed only for 4xx and 5xx ones.

albertored commented 1 year ago

Moving here a comment from @tsloughter

Actually, maybe there should be one function that returns whether to create a span and whether to propagate:

filter(Req) -> {boolean(), boolean()}

I actually don't see filtering mentioned at all in this doc? We def need some function or regex (on path) based filtering to allow users to define if spans should be started or not for a request.

Like https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp#Filter

bryannaegele commented 1 year ago

If this is the case (the span can be marked as ok as configured) then we should extend this functionality also to other libs and to 2xx and 3xx status codes, now it is allowed only for 4xx and 5xx ones.

You can only mark an error'd span ok. Those codes aren't errors.

bryannaegele commented 1 year ago

I know it's not fun, but you might want to spend some time reading through the General, API, and SDK sections of the spec to get a good understanding of the foundations.

albertored commented 1 year ago

I read it but my understanding of the total order part was "once set to ok the status can't change" not "to set the status to ok it must pass from an error one", thanks for clarifying that to me.

I also hope my previous messages don't sound arrogant, it was not my intention but not being a native English speaker I imagine they can be misread

bryannaegele commented 1 year ago

No worries on the language bit :)

The intent of Ok is to override any marking of the span as errored and prevent any future changes to the status. There's no other benefit and having an explicit option for those defined would likely just cause confusion.