Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Req 1.27 SemConv #375

Merged
merged 17 commits into from
Oct 16, 2024
Merged

Conversation

bryannaegele
Copy link
Collaborator

@bryannaegele bryannaegele commented Sep 13, 2024

Updates Req to SemConv 1.26. This creates a number of breaking changes in order to comply with the new SemConv.

Given previous stability, breaking changes, and otel http semconv stability, this will mark a 1.0 release, as well.

Addresses #183 for Req

Resolves #351
Resolves #363

@tsloughter
Copy link
Member

If it wasn't 1.0 then it wasn't stable. No need to do a major version bump if it was 0.x.

@bryannaegele bryannaegele marked this pull request as ready for review September 24, 2024 22:39
@bryannaegele bryannaegele changed the title Req 1.26 SemConv Req 1.27 SemConv Sep 24, 2024
Copy link
Contributor

@GregMefford GregMefford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is mostly ready to go, thanks so much for the work here! ❤️
I just had a few comments to think about / tweak before I'm ready to give it a ✅

Comment on lines 40 to 44
# propagate_trace_headers_fn: [
# type: :mfa,
# default: {__MODULE__, :default_propagation_fn, []},
# doc: "Default function returns `false`. See docs for more info"
# ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this commented-out code just here for our reference as developers of this library, or was it accidentally not removed? It feels weird to me that it's there but commented-out if it's just there as private documentation.

instrumentation/opentelemetry_req/lib/opentelemetry_req.ex Outdated Show resolved Hide resolved
instrumentation/opentelemetry_req/lib/opentelemetry_req.ex Outdated Show resolved Hide resolved
instrumentation/opentelemetry_req/lib/opentelemetry_req.ex Outdated Show resolved Hide resolved
instrumentation/opentelemetry_req/lib/opentelemetry_req.ex Outdated Show resolved Hide resolved

if response.status >= 400 do
OpenTelemetry.Tracer.set_status(OpenTelemetry.status(:error, ""))
Tracer.set_status(OpenTelemetry.status(:error, ""))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it was already like this, but IMO it shouldn't be an error span necessarily just because the server successfully returned a 404 for example, if that's what the caller expected. In that case, the client did its job correctly, so there was no error. In fact, the server that the client called probably did as well unless it was a 5xx error, so it shouldn't be an error on its span either. Does OTel say we should do it this way for HTTP clients, or is this just something we've chosen to do here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an error for HTTP clients.

For HTTP status codes in the 4xx range span status MUST be left unset in case of SpanKind.SERVER
and SHOULD be set to Error in case of SpanKind.CLIENT.

https://hexdocs.pm/opentelemetry_semantic_conventions/http-spans.html#status

Copy link
Contributor

@GregMefford GregMefford Oct 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO that's a bummer and not something I would want to have in my traces personally, so I guess that's why it's a SHOULD instead of a MUST. But as a library, I guess we have to decide whether we think it's right to follow that convention, since it's not required. My vote would be to not set it as an error unless it was like a timeout or connection error or something where there's no response at all. If it's a 5xx, I would be fine with it being marked as an error in the client, just to call attention to it even though it's not Req's fault if the server returns a 504 or something, but I think it's totally normal for 404s to happen all the time when you're just querying an API for "does this thing exist?" and it just says "no" as a 404 - you don't need to call special attention to that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users are allowed to mark a span ok so they can hook into the request and mark it should they choose to. We could look at adding a response step to let folks supply a function but this PR isn't seeking to change any existing functionality. I think that's a fine feature request.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that makes sense! ✅

instrumentation/opentelemetry_req/lib/opentelemetry_req.ex Outdated Show resolved Hide resolved
instrumentation/opentelemetry_req/lib/opentelemetry_req.ex Outdated Show resolved Hide resolved
instrumentation/opentelemetry_req/lib/opentelemetry_req.ex Outdated Show resolved Hide resolved
url: "/"
)

assert_receive {:span, span(name: :GET)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it weird that the name is an atom here and a binary when the path params are parsed? Feels surprising to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't to_atom anything for users as a general rule. I'm not sure I'd want to deviate from it since sobelow would probably gripe but I don't know that for a fact. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I don't think we'd convert to an atom, but I was kind of expecting that the span name would always be a string.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atoms are dirt cheap. A string is always heavier and requires memory allocation. It's also an implementation detail that shouldn't concern the user. This only arises if they don't set the path params.

I wouldn't mind adding an efficiency option to allow creating atoms but I don't know how sobelow would treat that. Suppose we could always just put the ignore statement in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the other comment, I don't think this is a blocker if that's already how it was working before, but I agree that it would be something worth considering as an option in a future PR where we can focus on just that aspect.

Copy link
Contributor

@GregMefford GregMefford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is good to merge.

@bryannaegele bryannaegele merged commit 3f43ca2 into open-telemetry:main Oct 16, 2024
29 checks passed
@bryannaegele bryannaegele deleted the req-1.26-semconv branch October 16, 2024 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Req - SemConv 1.26 OpentelemetryReq: log when path_params not set and continue
3 participants