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

feat: add network context to logs #163

Merged
merged 2 commits into from
Aug 28, 2022
Merged

feat: add network context to logs #163

merged 2 commits into from
Aug 28, 2022

Conversation

marktoda
Copy link
Contributor

This commit adds an optional context object to MetricsLogger which can be used
to add network id and network name to all logs. This may help alerting services
differentiate and bucket errors by network

Example log after this change

{"name":"Uniswap Smart Order Router",
"hostname":"toda-XPS-15-9510",
"pid":157780,
"chainId":1,
"networkName":"mainnet",
"level":30,
"key":"FindBestSwapRoute",
"value":13,
"unit":"Milliseconds",
"msg":"[Metric]: FindBestSwapRoute: 13 | Milliseconds",
"time":"2022-08-17T19:40:45.340Z",
"v":0}

This commit adds an optional context object to MetricsLogger which can be used
to add network id and network name to all logs. This may help alerting services
differentiate and bucket errors by network

Example log after this change
```
{"name":"Uniswap Smart Order Router",
"hostname":"toda-XPS-15-9510",
"pid":157780,
"chainId":1,
"networkName":"mainnet",
"level":30,
"key":"FindBestSwapRoute",
"value":13,
"unit":"Milliseconds",
"msg":"[Metric]: FindBestSwapRoute: 13 | Milliseconds",
"time":"2022-08-17T19:40:45.340Z",
"v":0}
```
Copy link
Contributor

@willpote willpote left a comment

Choose a reason for hiding this comment

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

FYI- the MetricLogger is only used in the SOR package, and mainly just exists as a shim/replacement for emitting metrics to a real metric service like sentry or AWS Cloudwatch.

In the routing-API we implement IMetric such that it stores the metrics in AWS Cloudwatch.

For computing error rates per chain we actually need to emit completely new metrics for success and error by chain in the routing-api. We don't even have those base metrics being emitted yet, we just use the metrics which API Gateway emits automatically for every endpoint it runs.

@marktoda marktoda merged commit d686a14 into main Aug 28, 2022
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.

2 participants