opentelemetry-python-contrib icon indicating copy to clipboard operation
opentelemetry-python-contrib copied to clipboard

[WIP] add metric to count responses per endpoint

Open tomklino opened this issue 10 months ago • 2 comments
trafficstars

Description

Add a metric to track the number of responses per endpoint per status code

Fixes # (issue) - no open issue about it that I'm aware of

Type of change

  • [x] New feature (non-breaking change which adds functionality)
  • [x] This change requires a documentation update

How Has This Been Tested?

This change has been tested locally. This change DOES NOT YET have automated tests written for it.

  • [ ] Run a multithread wsgi server and an opentelemetry debug collector (or mock), send requests to multiple different endpoints, check that the reported values in the collector match the number of requests sent per endpoint, with the expected status codes

Specific example for a test:

  • Run a test server that listens for endpoints /api/foo and /api/bar.
  • The test server should respond with a status code 200, unless a different one specified in a request header "TEST_STATUS_CODE".
  • Send the following requests to the server:
    • /api/foo with a TEST_STATUS_CODE set to 200
    • /api/foo with a TEST_STATUS_CODE set to 500
    • /api/bar with a TEST_STATUS_CODE set to 200
    • /api/bar with a TEST_STATUS_CODE set to 500
  • Wait for the metrics report to the collector
  • Verify that the collector got 1 in the values for each of the metrics

Does This PR Require a Core Repo Change?

  • [ ] Yes. - Link to PR:
  • [x] No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • [ ] Followed the style guidelines of this project
  • [ ] Changelogs have been updated
  • [ ] Unit tests have been added
  • [ ] Documentation has been updated

tomklino avatar Jan 08 '25 10:01 tomklino

http.server.duration already covers this

alexmojaki avatar Jan 18 '25 06:01 alexmojaki