Skip to content

Commit

Permalink
add docs for metric pruning routine
Browse files Browse the repository at this point in the history
  • Loading branch information
galxy25 committed Oct 27, 2023
1 parent a6101b2 commit 0759816
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
9 changes: 4 additions & 5 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,11 @@ METRIC_PRUNING_ROUTINE_INTERVAL_SECONDS=10
# how long (after the proxy service starts) it will wait
# to run the first iteration of the metric pruning routine
METRIC_PRUNING_ROUTINE_DELAY_FIRST_RUN_SECONDS=5
# The maximum number of days of request metrics that should
# be preserved starting from
# the end of the current day each time
# the pruning routine runs
# The maximum number of days of request metrics
# that should be preserved measured
# from the time the pruning routine runs
# all metrics for earlier days will be truncated
METRIC_PRUNING_MAX_REQUEST_METRICS_HISTORY_DAYS=1
METRIC_PRUNING_MAX_REQUEST_METRICS_HISTORY_DAYS=45
# CACHE_ENABLED specifies if cache should be enabled. By default cache is disabled.
CACHE_ENABLED=true
# REDIS_ENDPOINT_URL is an url of redis
Expand Down
28 changes: 27 additions & 1 deletion architecture/METRIC_COMPACTION_ROUTINE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
# Metric Compaction Routine
# Metric Compaction Routines

In order to keep the size and cost of the `proxied_request_metrics` table from growing infinitely, and to provide useful aggregated metrics for endpoint operators to analyze traffic patterns, the proxy service runs several processes to routinely compact that table

![Metric Compaction Routine Conceptual Overview](./images/metric_compaction_routine_conceptual.jpg)

## Metric Pruning Routine

The Metric Pruning routine is responsible for deleting any metrics that are older than `N` specified days from the `proxied_request_metrics` table. It is controlled via the following environment variables

```bash
# Whether metric pruning routines should run on the configured interval, defaults to true
METRIC_PRUNING_ENABLED=true
# How frequenlty metric pruning routines should run
# defaults to 1 day
METRIC_PRUNING_ROUTINE_INTERVAL_SECONDS=10
# how long (after the proxy service starts) it will wait
# to run the first iteration of the metric pruning routine
METRIC_PRUNING_ROUTINE_DELAY_FIRST_RUN_SECONDS=5
# The maximum number of days of request metrics
# that should be preserved measured
# from the time the pruning routine runs
# all metrics for earlier days will be truncated
METRIC_PRUNING_MAX_REQUEST_METRICS_HISTORY_DAYS=45
```

## Metric Aggregation Routine

`#TODO`
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Config struct {
MetricPruningRoutineDelayFirstRun time.Duration
MetricPruningMaxRequestMetricsHistoryDays int
CacheEnabled bool
CacheIndefinitely bool
RedisEndpointURL string
RedisPassword string
CacheTTL time.Duration
Expand Down Expand Up @@ -90,7 +91,7 @@ const (
METRIC_PRUNING_ROUTINE_DELAY_FIRST_RUN_SECONDS_ENVIRONMENT_KEY = "METRIC_PRUNING_ROUTINE_DELAY_FIRST_RUN_SECONDS"
DEFAULT_METRIC_PRUNING_ROUTINE_DELAY_FIRST_RUN_SECONDS = 10
METRIC_PRUNING_MAX_REQUEST_METRICS_HISTORY_DAYS_ENVIRONMENT_KEY = "METRIC_PRUNING_MAX_REQUEST_METRICS_HISTORY_DAYS"
DEFAULT_METRIC_PRUNING_MAX_REQUEST_METRICS_HISTORY_DAYS = 1
DEFAULT_METRIC_PRUNING_MAX_REQUEST_METRICS_HISTORY_DAYS = 45
EVM_QUERY_SERVICE_ENVIRONMENT_KEY = "EVM_QUERY_SERVICE_URL"
DATABASE_MAX_IDLE_CONNECTIONS_ENVIRONMENT_KEY = "DATABASE_MAX_IDLE_CONNECTIONS"
DEFAULT_DATABASE_MAX_IDLE_CONNECTIONS = 20
Expand Down

0 comments on commit 0759816

Please sign in to comment.