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 coprocessor metrics #3483

Merged
merged 5 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changesets/feat_garypen_177_coprocessor_metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Add coprocessor metrics ([PR #3483](https://github.com/apollographql/router/pull/3483))

Introduces a new metric for the router:

```
apollo.router.operations.coprocessor
```

It has two attributes:

```
coprocessor.stage: string (RouterRequest, RouterResponse, SubgraphRequest, SubgraphResponse)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit. Would be nice if these names matched the other use in the metrics naming.
e.g.
router.request, router.response etc rather than CamelCase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should monitor this and make the change in a followup PR if it seems sensible. Right now, the values are set to match the exact values transmitted in the coprocessor protocol. It would be nice to have some user feedback before changing.

coprocessor.succeeded: bool
```

By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3483
52 changes: 44 additions & 8 deletions apollo-router/src/plugins/coprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ impl RouterStage {
let sdl = sdl.clone();

async move {
process_router_request_stage(
let mut succeeded = true;
let result = process_router_request_stage(
http_client,
coprocessor_url,
sdl,
Expand All @@ -294,11 +295,19 @@ impl RouterStage {
)
.await
.map_err(|error| {
succeeded = false;
tracing::error!(
"external extensibility: router request stage error: {error}"
);
error
})
});
tracing::info!(
monotonic_counter.apollo.router.operations.coprocessor = 1u64,
coprocessor.stage = %PipelineStep::RouterRequest,
coprocessor.succeeded = succeeded,
"Total operations with co-processors enabled"
);
result
}
})
});
Expand All @@ -314,7 +323,8 @@ impl RouterStage {
async move {
let response: router::Response = fut.await?;

process_router_response_stage(
let mut succeeded = true;
let result = process_router_response_stage(
http_client,
coprocessor_url,
sdl,
Expand All @@ -323,11 +333,19 @@ impl RouterStage {
)
.await
.map_err(|error| {
succeeded = false;
tracing::error!(
"external extensibility: router response stage error: {error}"
);
error
})
});
tracing::info!(
monotonic_counter.apollo.router.operations.coprocessor = 1u64,
coprocessor.stage = %PipelineStep::RouterResponse,
coprocessor.succeeded = succeeded,
"Total operations with co-processors enabled"
);
result
}
})
});
Expand Down Expand Up @@ -400,7 +418,8 @@ impl SubgraphStage {
let request_config = request_config.clone();

async move {
process_subgraph_request_stage(
let mut succeeded = true;
let result = process_subgraph_request_stage(
http_client,
coprocessor_url,
service_name,
Expand All @@ -409,11 +428,19 @@ impl SubgraphStage {
)
.await
.map_err(|error| {
succeeded = false;
tracing::error!(
"external extensibility: subgraph request stage error: {error}"
);
error
})
});
tracing::info!(
monotonic_counter.apollo.router.operations.coprocessor = 1u64,
coprocessor.stage = %PipelineStep::SubgraphRequest,
coprocessor.succeeded = succeeded,
"Total operations with co-processors enabled"
);
result
}
})
});
Expand All @@ -430,7 +457,8 @@ impl SubgraphStage {
async move {
let response: subgraph::Response = fut.await?;

process_subgraph_response_stage(
let mut succeeded = true;
let result = process_subgraph_response_stage(
http_client,
coprocessor_url,
service_name,
Expand All @@ -439,11 +467,19 @@ impl SubgraphStage {
)
.await
.map_err(|error| {
succeeded = false;
tracing::error!(
"external extensibility: subgraph response stage error: {error}"
);
error
})
});
tracing::info!(
monotonic_counter.apollo.router.operations.coprocessor = 1u64,
coprocessor.stage = %PipelineStep::SubgraphResponse,
coprocessor.succeeded = succeeded,
"Total operations with co-processors enabled"
);
result
}
})
});
Expand Down
9 changes: 9 additions & 0 deletions docs/source/configuration/metrics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ All cache metrics listed above have the following attributes:
- `kind`: the cache being queried (`apq`, `query planner`, `introspection`)
- `storage`: The backend storage of the cache (`memory`, `redis`)

#### Coprocessor

- `apollo_router_operations_coprocessor_total` - Total operations with co-processors enabled.

The coprocessor operations metric has the following attributes:

- `coprocessor.stage`: string (`RouterRequest`, `RouterResponse`, `SubgraphRequest`, `SubgraphResponse`)
- `coprocessor.succeeded`: bool

#### Performance

- `apollo_router_processing_time` - Time spent processing a request (outside of waiting for external or subgraph requests) in seconds.
Expand Down