Skip to content

Commit

Permalink
Remove metrics endpoints (microsoft#6283)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyashton authored Jun 20, 2024
1 parent 33a842a commit 647fbbd
Show file tree
Hide file tree
Showing 20 changed files with 267 additions and 549 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `::consensus` is now `ccf::consensus`
- `::tls` is now `ccf::tls`

### Removed

- Removed the existing metrics endpoint and API (`GET /api/metrics`, `get_metrics_v1`). Stats for request execution can instead be gathered by overriding the `EndpointRegistry::handle_event_request_completed()` method.

## [5.0.0-dev18]

[5.0.0-dev18]: https://github.com/microsoft/CCF/releases/tag/ccf-5.0.0-dev18
Expand Down
73 changes: 1 addition & 72 deletions doc/schemas/app_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,54 +37,6 @@
],
"type": "string"
},
"EndpointMetrics": {
"properties": {
"metrics": {
"$ref": "#/components/schemas/EndpointMetricsEntry_array"
}
},
"required": [
"metrics"
],
"type": "object"
},
"EndpointMetricsEntry": {
"properties": {
"calls": {
"$ref": "#/components/schemas/uint64"
},
"errors": {
"$ref": "#/components/schemas/uint64"
},
"failures": {
"$ref": "#/components/schemas/uint64"
},
"method": {
"$ref": "#/components/schemas/string"
},
"path": {
"$ref": "#/components/schemas/string"
},
"retries": {
"$ref": "#/components/schemas/uint64"
}
},
"required": [
"path",
"method",
"calls",
"errors",
"failures",
"retries"
],
"type": "object"
},
"EndpointMetricsEntry_array": {
"items": {
"$ref": "#/components/schemas/EndpointMetricsEntry"
},
"type": "array"
},
"GetCode__Out": {
"properties": {
"versions": {
Expand Down Expand Up @@ -311,7 +263,7 @@
"info": {
"description": "This CCF sample app implements a simple logging application, securely recording messages at client-specified IDs. It demonstrates most of the features available to CCF apps.",
"title": "CCF Sample Logging App",
"version": "2.3.0"
"version": "2.3.1"
},
"openapi": "3.0.0",
"paths": {
Expand All @@ -338,29 +290,6 @@
}
}
},
"/app/api/metrics": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/EndpointMetrics"
}
}
},
"description": "Default response description"
},
"default": {
"$ref": "#/components/responses/default"
}
},
"summary": "Usage metrics for endpoints",
"x-ccf-forwarding": {
"$ref": "#/components/x-ccf-forwarding/sometimes"
}
}
},
"/app/code": {
"get": {
"deprecated": true,
Expand Down
73 changes: 1 addition & 72 deletions doc/schemas/gov_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,54 +109,6 @@
},
"type": "array"
},
"EndpointMetrics": {
"properties": {
"metrics": {
"$ref": "#/components/schemas/EndpointMetricsEntry_array"
}
},
"required": [
"metrics"
],
"type": "object"
},
"EndpointMetricsEntry": {
"properties": {
"calls": {
"$ref": "#/components/schemas/uint64"
},
"errors": {
"$ref": "#/components/schemas/uint64"
},
"failures": {
"$ref": "#/components/schemas/uint64"
},
"method": {
"$ref": "#/components/schemas/string"
},
"path": {
"$ref": "#/components/schemas/string"
},
"retries": {
"$ref": "#/components/schemas/uint64"
}
},
"required": [
"path",
"method",
"calls",
"errors",
"failures",
"retries"
],
"type": "object"
},
"EndpointMetricsEntry_array": {
"items": {
"$ref": "#/components/schemas/EndpointMetricsEntry"
},
"type": "array"
},
"EndpointProperties": {
"properties": {
"authn_policies": {
Expand Down Expand Up @@ -1366,7 +1318,7 @@
"info": {
"description": "This API is used to submit and query proposals which affect CCF's public governance tables.",
"title": "CCF Governance API",
"version": "4.1.7"
"version": "4.1.8"
},
"openapi": "3.0.0",
"paths": {
Expand Down Expand Up @@ -1452,29 +1404,6 @@
}
}
},
"/gov/api/metrics": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/EndpointMetrics"
}
}
},
"description": "Default response description"
},
"default": {
"$ref": "#/components/responses/default"
}
},
"summary": "Usage metrics for endpoints",
"x-ccf-forwarding": {
"$ref": "#/components/x-ccf-forwarding/sometimes"
}
}
},
"/gov/code": {
"get": {
"deprecated": true,
Expand Down
85 changes: 9 additions & 76 deletions doc/schemas/node_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,54 +183,6 @@
],
"type": "object"
},
"EndpointMetrics": {
"properties": {
"metrics": {
"$ref": "#/components/schemas/EndpointMetricsEntry_array"
}
},
"required": [
"metrics"
],
"type": "object"
},
"EndpointMetricsEntry": {
"properties": {
"calls": {
"$ref": "#/components/schemas/uint64"
},
"errors": {
"$ref": "#/components/schemas/uint64"
},
"failures": {
"$ref": "#/components/schemas/uint64"
},
"method": {
"$ref": "#/components/schemas/string"
},
"path": {
"$ref": "#/components/schemas/string"
},
"retries": {
"$ref": "#/components/schemas/uint64"
}
},
"required": [
"path",
"method",
"calls",
"errors",
"failures",
"retries"
],
"type": "object"
},
"EndpointMetricsEntry_array": {
"items": {
"$ref": "#/components/schemas/EndpointMetricsEntry"
},
"type": "array"
},
"GetCode__Out": {
"properties": {
"versions": {
Expand Down Expand Up @@ -449,18 +401,22 @@
],
"type": "object"
},
"JWTMetrics": {
"JWTRefreshMetrics": {
"properties": {
"attempts": {
"$ref": "#/components/schemas/uint64"
},
"failures": {
"$ref": "#/components/schemas/uint64"
},
"successes": {
"$ref": "#/components/schemas/uint64"
}
},
"required": [
"attempts",
"successes"
"successes",
"failures"
],
"type": "object"
},
Expand Down Expand Up @@ -937,7 +893,7 @@
"info": {
"description": "This API provides public, uncredentialed access to service and node state.",
"title": "CCF Public Node API",
"version": "4.9.1"
"version": "4.9.2"
},
"openapi": "3.0.0",
"paths": {
Expand All @@ -964,29 +920,6 @@
}
}
},
"/node/api/metrics": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/EndpointMetrics"
}
}
},
"description": "Default response description"
},
"default": {
"$ref": "#/components/responses/default"
}
},
"summary": "Usage metrics for endpoints",
"x-ccf-forwarding": {
"$ref": "#/components/x-ccf-forwarding/sometimes"
}
}
},
"/node/backup": {
"get": {
"responses": {
Expand Down Expand Up @@ -1157,14 +1090,14 @@
}
}
},
"/node/jwt_metrics": {
"/node/jwt_keys/refresh/metrics": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/JWTMetrics"
"$ref": "#/components/schemas/JWTRefreshMetrics"
}
}
},
Expand Down
15 changes: 15 additions & 0 deletions include/ccf/app_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ namespace ccf
UserEndpointRegistry(ccfapp::AbstractNodeContext& context) :
CommonEndpointRegistry(get_actor_prefix(ActorsType::users), context)
{}

// Default behaviour is to do nothing - do NOT log summary of every request
// as it completes. Apps may override this if they wish.
void handle_event_request_completed(
const ccf::endpoints::RequestCompletedEvent& event) override
{}

void handle_event_dispatch_failed(
const ccf::endpoints::DispatchFailedEvent& event) override
{
// Log dispatch failures, as a coarse metric of some user errors, but do
// not log the raw path, which may contain confidential fields
// misformatted into the wrong url
CCF_APP_INFO("DispatchFailedEvent: {} {}", event.method, event.status);
}
};
}

Expand Down
5 changes: 0 additions & 5 deletions include/ccf/base_endpoint_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,5 @@ namespace ccf
/** Get untrusted time from the host of the currently executing node.
*/
ApiResult get_untrusted_host_time_v1(::timespec& time);

/** Get usage metrics from endpoints under the registry, including
* number of calls, errors, failures and retries.
*/
ApiResult get_metrics_v1(EndpointMetrics& endpoint_metrics);
};
}
Loading

0 comments on commit 647fbbd

Please sign in to comment.