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

Request/Response body size metric per operation name #5152

Closed
grzn opened this issue May 13, 2024 · 6 comments
Closed

Request/Response body size metric per operation name #5152

grzn opened this issue May 13, 2024 · 6 comments
Labels
component/open-telemetry OTLP, Datadog, Prometheus, etc. and the integrations around it. raised by user

Comments

@grzn
Copy link

grzn commented May 13, 2024

The metric 'apollo_router_http_request_duration_seconds' is great, exposing the duration for each Gql operation.
It would even better to have a metric for the request/response body sizes per opeation.

From what I gather this is not doable with a custom router metric (does not have the operation name selector/attribute) and not with a super graph selector/attribute (does not have the request/body size)

@abernix abernix added the component/open-telemetry OTLP, Datadog, Prometheus, etc. and the integrations around it. label May 17, 2024
@bnjjj
Copy link
Contributor

bnjjj commented May 30, 2024

@grzn It's actually already possible using custom router metric but not really obvious neither well documented. To get the operation name you can have it using response_context selector and use the operation_name entry. That would result in something like this:

telemetry:
  instrumentation:
    instruments:
      router:
        http.server.request.body.size:
          attributes:
            graphql.operation.name:
              response_context: operation_name
        http.server.response.body.size:
          attributes:
            graphql.operation.name:
              response_context: operation_name

@bnjjj bnjjj closed this as completed May 30, 2024
@grzn
Copy link
Author

grzn commented Jun 2, 2024

@bnjjj thanks, it works well for request body size, but not for response body size; after adding this, the metrics lo longer shows on he metrics response.

$ curl http://localhost:9091/metrics | grep http_server_res
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 69332  100 69332    0     0  53.4M      0 --:--:-- --:--:-- --:--:-- 66.1M

@bnjjj
Copy link
Contributor

bnjjj commented Jun 3, 2024

Thanks @grzn I'll try to reproduce. Could you tell me which version of the router are you using ?

@bnjjj bnjjj reopened this Jun 3, 2024
@bnjjj
Copy link
Contributor

bnjjj commented Jun 3, 2024

I was able to reproduce @grzn. It's not related to the configuration but the implementation of the response body size metric itself. It's based on the value of content-length header but that header is not populated. I need to dig more in order to fix that issue I'll create a follow up issue and close this one.

@bnjjj bnjjj closed this as completed Jun 3, 2024
@bnjjj
Copy link
Contributor

bnjjj commented Jun 3, 2024

#5319

@grzn
Copy link
Author

grzn commented Jun 3, 2024

cool, thanks @bnjjj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/open-telemetry OTLP, Datadog, Prometheus, etc. and the integrations around it. raised by user
Projects
None yet
Development

No branches or pull requests

3 participants