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

chore: metrics todo and naming #95

Merged
merged 11 commits into from
Oct 10, 2023
Merged

chore: metrics todo and naming #95

merged 11 commits into from
Oct 10, 2023

Conversation

mfw78
Copy link
Contributor

@mfw78 mfw78 commented Oct 6, 2023

Description

This PR addresses issues around naming conventions for the prometheus metrics. Best efforts have been followed to adhere to best practices.

Changes

  • Revised metric naming and labeling to be in accordance with best practices.
  • Removed custom API prometheus metrics and replaced with middleware.

How to test

  1. Run a sync from contract genesis.
  2. Observe via http://127.0.0.1:8080/metrics there respective metrics changing.

Related Issues

Related #78, #70

@mfw78 mfw78 added enhancement New feature or request infra Infra, devops, CI and related tasks E:1.2: Watch Tower Service https://github.com/cowprotocol/pm/issues/8 labels Oct 6, 2023
@mfw78 mfw78 requested review from anxolin, ahhda and a team October 6, 2023 04:58
@mfw78 mfw78 self-assigned this Oct 6, 2023
@socket-security
Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@types/express-prometheus-middleware 1.2.1 None +0 5.69 kB types
express-prometheus-middleware 1.2.0 None +5 196 kB joao-fontenele

@mfw78 mfw78 changed the title Chore metrics chore: metrics todo and naming Oct 6, 2023
src/utils/metrics.ts Outdated Show resolved Hide resolved
src/domain/addContract.ts Outdated Show resolved Hide resolved
@mfw78 mfw78 force-pushed the fix-drop-incompatible-orders branch from 4c2a197 to 4adace1 Compare October 6, 2023 12:08
@mfw78 mfw78 mentioned this pull request Oct 6, 2023
1 task
@mfw78 mfw78 force-pushed the fix-drop-incompatible-orders branch 3 times, most recently from 6c726bc to 034e35b Compare October 7, 2023 03:23
@mfw78 mfw78 force-pushed the chore-metrics branch 2 times, most recently from 7e80376 to e7b3d4e Compare October 7, 2023 03:41
Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

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

the metrics are great!

newContractsTotal,
singleOrdersTotal,
totalActiveOrders,
totalActiveOwners,
Copy link
Contributor

Choose a reason for hiding this comment

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

unsure about this, but should all of these have Metric.

It makes it more verbose, but in the other hand, this instrumentation is mixing a bit with the bussniess logic, hard to differenciate just by name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally, I'd prefer referencing the module as we've already called it metrics, so using metric.newContractsTotal etc. Let's look at refactoring this later 😃

src/domain/checkForAndPlaceOrder.ts Show resolved Hide resolved
src/utils/metrics.ts Outdated Show resolved Hide resolved
errorHandler?: (err: any) => T,
errorMetric?: client.Counter
): T {
const timer = durationMetric.labels(...labels).startTimer();
Copy link
Contributor

Choose a reason for hiding this comment

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

should we raise if the labels don't match the metric labels? (the size)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From looking at the API on prom-client, I don't think the labels may only be internal within the type, and not able to be checked against?

src/utils/metrics.ts Outdated Show resolved Hide resolved
src/utils/metrics.ts Outdated Show resolved Hide resolved
src/utils/metrics.ts Show resolved Hide resolved
Base automatically changed from fix-drop-incompatible-orders to main October 9, 2023 23:08
@mfw78 mfw78 merged commit 412192a into main Oct 10, 2023
3 checks passed
@mfw78 mfw78 deleted the chore-metrics branch October 10, 2023 01:19
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
E:1.2: Watch Tower Service https://github.com/cowprotocol/pm/issues/8 enhancement New feature or request infra Infra, devops, CI and related tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants