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

Add connectors HTTP metrics #5900

Closed
wants to merge 2 commits into from
Closed

Conversation

pubmodmatt
Copy link
Contributor

@pubmodmatt pubmodmatt commented Aug 27, 2024

Add connectors HTTP metrics:

  • apollo_router_http_connector_requests_total - counts requests by subgraph/connector/status
  • apollo_router_http_connector_request_duration_seconds - a histogram of request times by subgraph/connector

Example metric data:

# HELP apollo_router_http_connector_request_duration_seconds Duration of connectors HTTP requests
# TYPE apollo_router_http_connector_request_duration_seconds histogram
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="0.001"} 0
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="0.005"} 0
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="0.015"} 0
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="0.05"} 2
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="0.1"} 2
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="0.2"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="0.3"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="0.4"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="0.5"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="1"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="5"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="10"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router",le="+Inf"} 3
apollo_router_http_connector_request_duration_seconds_sum{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router"} 0.175789542
apollo_router_http_connector_request_duration_seconds_count{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",subgraph="posts",otel_scope_name="apollo/router"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="0.001"} 0
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="0.005"} 0
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="0.015"} 0
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="0.05"} 2
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="0.1"} 2
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="0.2"} 2
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="0.3"} 2
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="0.4"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="0.5"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="1"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="5"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="10"} 3
apollo_router_http_connector_request_duration_seconds_bucket{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router",le="+Inf"} 3
apollo_router_http_connector_request_duration_seconds_sum{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router"} 0.433746667
apollo_router_http_connector_request_duration_seconds_count{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",subgraph="posts",otel_scope_name="apollo/router"} 3
# HELP apollo_router_http_connector_requests_total Total number of HTTP requests made through connectors
# TYPE apollo_router_http_connector_requests_total counter
apollo_router_http_connector_requests_total{connector="posts.jsonPlaceholder http: GET /users/{$args.id!}",status="200",subgraph="posts",otel_scope_name="apollo/router"} 3
apollo_router_http_connector_requests_total{connector="posts.jsonPlaceholder http: GET /users/{$this.id!}/posts",status="200",subgraph="posts",otel_scope_name="apollo/router"} 3

Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Tests added and passing3
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@pubmodmatt pubmodmatt requested a review from a team August 27, 2024 19:38
@pubmodmatt pubmodmatt self-assigned this Aug 27, 2024
@pubmodmatt pubmodmatt requested review from a team as code owners August 27, 2024 19:38
@lennyburdette
Copy link
Contributor

@bnjjj can you take a look at these new metrics? 🙏🏻

Copy link
Contributor

@bnjjj bnjjj left a comment

Choose a reason for hiding this comment

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

I'm wondering if we really need this as we already have metrics for subgraphs https://www.apollographql.com/docs/router/configuration/telemetry/instrumentation/instruments#opentelemetry-standard-instruments What's the difference, how could we try to include this metrics in custom telemetry ? Is it related to a specific service in plugin trait ?

apollo-router/src/services/connector_service.rs Outdated Show resolved Hide resolved
@bnjjj
Copy link
Contributor

bnjjj commented Sep 6, 2024

cc @BrynCooke

@pubmodmatt
Copy link
Contributor Author

I'm wondering if we really need this as we already have metrics for subgraphs https://www.apollographql.com/docs/router/configuration/telemetry/instrumentation/instruments#opentelemetry-standard-instruments What's the difference, how could we try to include this metrics in custom telemetry ? Is it related to a specific service in plugin trait ?

@bnjjj - these metrics are modeled after these router metrics, only instead of for subgraph calls, these are for REST API calls made through the connector service. They are scoped to a connector, so we can see, for example, that for a given connector, how many requests received a status 200 vs 404, or a histogram of how long the HTTP requests take in the REST API. If there's a better way of doing this please let me know.

@BrynCooke
Copy link
Contributor

Agree that metrics should integrate with the existing standard instruments rather than making new ones. In particular adding a selector for the connector. This way users can configure the metrics to include whatever information they want.

The problem with fixed metrics is that users almost always need to add extra attributes to make them useful. In general the rule is, if the metric change was a result of a request then it should be integrated with the telemetry config, lifecycle things such as router reloads can be static.

@pubmodmatt pubmodmatt closed this Sep 23, 2024
@pubmodmatt
Copy link
Contributor Author

Going to rework this based on conversations with the router team.

@abernix abernix deleted the pubmodmatt/connectors/metrics branch January 20, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants