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

Other instruments #10

Open
hardbyte opened this issue Oct 21, 2024 · 4 comments · Fixed by #11 or #12
Open

Other instruments #10

hardbyte opened this issue Oct 21, 2024 · 4 comments · Fixed by #11 or #12

Comments

@hardbyte
Copy link
Contributor

Hey great work with the crate!

I forked a similar repo that was tied to prometheus to make it use the opentelemetry SDK. Perhaps we could combine efforts?

I think some of these instruments would make sense in this library

@francoposa
Copy link
Owner

Hi, I definitely welcome some contribution!

Just regarding my sort of my desired scope for the crate at the moment:

I want to keep scope for this library strictly to the OTEL HTTP server spec.

Meaning w.r.t the instruments you linked:

  • http.server.active_requests - can be ported over with that name
  • http.server.request.size - would need renamed to http.server.request.body.size
  • same for response.size
  • requests - not ported over, as it's not in the OTEL spec and using the request.duration histogram's count here is assumed correct way

I would want to keep the labels as strict to OTEL spec as possible as well. I think I personally would aim to take a bit stricter approach to the url.scheme label, make server.address and server-port opt-in, etc.

@hardbyte
Copy link
Contributor Author

Great, all sounds sensible to me. I've opened #11 for the first one.

For request size - do you think trusting the CONTENT_LENGTH header is the right approach to avoid consuming the body?

@francoposa
Copy link
Owner

For request size - do you think trusting the CONTENT_LENGTH header is the right approach to avoid consuming the body?

I think this is the right approach for a metrics middleware.

Double-checking the body instead of trusting the CONTENT_LENGTH header is more of an approach for debugging a specific issue with a misbehaving client.

Given that the spec suggests to look for it in the header and that it's optional, so I think the approach is to just set it if it's in the header.

[1]: The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the Content-Length header. For requests using transport encoding, this should be the compressed size.

As a reference point, the tower middleware which is specifically for limiting the body size also trusts the header: https://docs.rs/tower-http/latest/src/tower_http/limit/service.rs.html

This was linked to pull requests Nov 24, 2024
@francoposa
Copy link
Owner

It appears we just need server.response.body.size to consider this accomplished. There's already a separate issue for further header parsing attempts to set the url.scheme label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants