Skip to content

feat(proxy): add the service to the proxy metrics - #3521

Open
pbleser-oc wants to merge 2 commits into
opencloud-eu:mainfrom
pbleser-oc:feat/add-service-to-proxy-metrics
Open

feat(proxy): add the service to the proxy metrics#3521
pbleser-oc wants to merge 2 commits into
opencloud-eu:mainfrom
pbleser-oc:feat/add-service-to-proxy-metrics

Conversation

@pbleser-oc

@pbleser-oc pbleser-oc commented Sep 11, 2026

Copy link
Copy Markdown
Member

Description

Improve the metrics for the proxy service.

  • extend the instrumenter middleware to add a label with the name of the service the request is being dispatched to
  • add a native Prometheus histogram that tracks the durations and also includes a label for the name of the service the request is being dispatched to, as well as a result label (success, client-error, server-error) based on the HTTP status code of the response
  • add per-service gauge functions to count the number of in-flight requests
  • add a counter for routing failures, for when an inbound request cannot be mapped to a route
  • extend the route.RoutingInfo struct with a service attribute, and a Service() getter
  • remove the routing_failure_count metric, as it is redundant

Added metrics:

  • opencloud_proxy_request_duration_seconds{service=..., method=..., result=...} (native histogram)
  • opencloud_proxy_service_request_total{service=..., method=..., result=...} (counter)
  • opencloud_proxy_service_duration_seconds{service=..., method=..., result=...} (legacy histogram)

The labels:

  • method: is the HTTP method (GET, ...)
  • result: maps the HTTP response status code to one of three values to reduce the cardinality, either success (0-399), client-error (400-499), server-error (500-)
  • success: is the service identifier, e.g. eu.opencloud.web.webdav, eu.opencloud.web.graph, ...

Note

Previously existing metrics have been kept as-is, backwards compatibility is retained.

Motivation and Context

More detailed metrics will allow for better introspection of a running production installment, in order to determine if something is slow, and what, by being able to drill down by service and not just with global metrics that do not differentiate.

How Has This Been Tested?

Manually by checking the resulting metrics when querying the /metrics endpoint of the debug address, as well as with a Prometheus scraping container.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation added

@codacy-production

codacy-production Bot commented Sep 11, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity

Metric Results
Complexity 5

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@pbleser-oc
pbleser-oc force-pushed the feat/add-service-to-proxy-metrics branch 2 times, most recently from 1ae07d0 to 689ef9e Compare September 14, 2026 08:17
Improve the metrics for the proxy service.

 * extend the instrumenter middleware to add a label with the name of
   the service the request is being dispatched to

 * add a native Prometheus histogram that tracks the durations and also
   includes a label for the name of the service the request is being
   dispatched to, as well as a 'result' label ('success',
   'client-error', 'server-error') based on the HTTP status code of the
   response

 * add per-service gauge functions to count the number of in-flight
   requests

 * add a counter for routing failures, for when an inbound request
   cannot be mapped to a route

 * extend the route.RoutingInfo struct with a service attribute, and a
   Service() getter

 * remove the 'routing_failure_count' metric, as it is redundant
@pbleser-oc
pbleser-oc force-pushed the feat/add-service-to-proxy-metrics branch from 689ef9e to 0deca84 Compare September 14, 2026 08:18

@micbar micbar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See my question.

Comment thread services/proxy/README.md
…ics for compatibility

 * re-add the metrics that were existing prior to this PR, to keep them
   for compatibility reasons with existing Grafana panels:
   - opencloud_proxy_requests_total
   - opencloud_proxy_errors_total
   - opencloud_proxy_duration_seconds

 * renamed new metric opencloud_proxy_request_total (that contains the
   service label) to opencloud_proxy_service_request_total

 * renamed new metric opencloud_proxy_duration_seconds (that contains
   the service label) to opencloud_proxy_service_duration_seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Qualification

Development

Successfully merging this pull request may close these issues.

2 participants