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

Refactor PromMetrics to use Collect functions #3607

Merged
merged 9 commits into from
May 9, 2024

Conversation

busma13
Copy link
Contributor

@busma13 busma13 commented May 8, 2024

This PR makes the following changes:

  • Refactor addMetric into individual functions for counter, gauge, and histogram.
  • Add collect() parameter to all add<metric> functions.
  • Update types:
    • import prom-client types into types package
    • remove duplicate types from terafoundation and job-components and import from types. This required some refactoring to not use context as a parameter, as the context type differs between terafoundation and job-components.
  • Move info metrics of slice, worker, and master into the setPromMetrics() functions.
  • Update PromClient docs and all relevant tests

@busma13 busma13 changed the title Collect functions prom metrics Reafctor PromMetrics to use Collect functions May 8, 2024
@busma13 busma13 changed the title Reafctor PromMetrics to use Collect functions Refactor PromMetrics to use Collect functions May 8, 2024
@busma13 busma13 requested review from godber and sotojn May 8, 2024 17:48
@busma13 busma13 marked this pull request as ready for review May 8, 2024 18:33
Copy link
Member

@godber godber left a comment

Choose a reason for hiding this comment

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

I think this looks good

@@ -326,6 +314,7 @@ export class WorkerExecutionContext
}

async onSliceFinished(): Promise<void> {
this.slicesFinished++;
Copy link
Member

Choose a reason for hiding this comment

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

I guess this will max out at 9quadrillion. We have jobs completing 2 million slices a day. I guess a job would have to run 4.5 billion days to hit that. Should be fine.

> Number.MAX_SAFE_INTEGER/2_000_000
4503599627.370496

logger: Logger,
) {
this.context = context;
this.name = name;
Copy link
Member

Choose a reason for hiding this comment

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

I am happy to see the removal of a context object passed in ...

name: string,
help: string,
labelsNames: Array<string>,
type: 'gauge' | 'counter' | 'histogram',
buckets: Array<number> = [0.1, 5, 15, 50, 100, 500]
Copy link
Member

Choose a reason for hiding this comment

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

In hindsight, the presence of this optional buckets argument should have been a clue that addMetric was too ambitious.

@godber
Copy link
Member

godber commented May 9, 2024

I would like to merge this but I would like @jsnoble to double check some of the lower level type changes. I think he's seen these recently but I didn't want to merge without an OK from him.

busma13 added 9 commits May 9, 2024 13:59
bump: (minor) @terascope/job-components@0.74.0, terafoundation@0.63.0

bump: (minor) @terascope/types@0.17.0, @terascope/utils@0.59.0

bump: (minor) @terascope/data-types@0.50.0, @terascope/data-mate@0.56.0

bump: (minor) elasticsearch-store@0.84.0, ts-transforms@0.85.0

bump: (minor) xlucene-parser@0.58.0, xlucene-translator@0.44.0

bump: (minor) @terascope/elasticsearch-api@3.20.0, @terascope/teraslice-state-storage@0.53.0
@busma13 busma13 force-pushed the collect-functions-prom-metrics branch from 563ff48 to 4871320 Compare May 9, 2024 21:03
@godber godber merged commit 1574226 into master May 9, 2024
40 checks passed
@godber godber deleted the collect-functions-prom-metrics branch May 9, 2024 21:54
@godber godber temporarily deployed to github-pages May 9, 2024 22:03 — with GitHub Actions Inactive
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