Skip to content

Record origin of client requests in metrics #2382

Closed
@jpraynaud

Description

@jpraynaud

Why

We need to record the origin of the requests which are done on the aggregator REST API in order to have a fine grain monitoring of its usage. This will help separate benchmark traffic, traffic from selected partners,...

How

Implement a feature to optionally record an origin tag requests made to the aggregator and compute the metrics in Grafana and/or protocol dashboard.

What

  • Create a list of authorized origin tag:
    • One part is hard-coded: EXPLORER, BENCHMARK, CI, NA
    • The other is done with configuration
  • In the client library/WASM, use an optional origin tag set with a specific option (this options adds an HTTP header mithril-origin-tag)
  • In the client cli, add an optional command parameter for the origin tag
  • In the aggregator benchmarks, use the origin tag BENCHMARK
  • In the explorer, use the origin tag EXPLORER
  • In the CI, use the origin tag CI for the manual/nightly workflows calling external aggregators
  • In the aggregator, add a middleware to the HTTP routes for computing the origin tag:
    • If it is not in the white list: fallback to NA
    • Otherwise use the white listed value
    • Use the computed origin tag in the metrics recording inside the handlers of the routes
    • Update EventMessage with the origin tag when needed
  • In the aggregator, extend the metrics:
    • Support recording of a metric with an optional origin tag (and keep supporting metrics without origin tag)
    • Update all the calls to the metrics to support an optional origin tag
    • In the state machine, the calls to the metrics should not be modified (as there is no origin tag in that case)
  • Migrations to use the origin tag:
    • ~~event table ( ~800K rows today, is it needed?)~~
    • metrics_per_day view
    • check that there is no degradation in the performances of the metrics_per_day view
  • Documentation:
    • How to specify an origin tag in the clients (examples, website)
    • How to setup an aggregator with custom white list of origin tags (website)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions