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

fix: add get method to type definitions of metric classes #531

Merged
merged 2 commits into from
Mar 4, 2023

Conversation

nflaig
Copy link
Contributor

@nflaig nflaig commented Jan 17, 2023

Current Limitation

At the moment there is no clean way to get a single metric value programmatically while using typescript.

The following is not possible as it causes type issues as the getters are implemented in javascript but are missing from type definitions.

const metric = register.getSingleMetric("process_cpu_user_seconds_total");

// Property 'get' does not exist on type 'Metric<string>'
const {value} = (await metric.get()).values[0]

Solution

Add get method to type definitions of each metric classes and define MetricObjectWithValues type which is returned by getters.

@nflaig nflaig force-pushed the getter-type-definitions branch 4 times, most recently from 587d5f4 to 524e786 Compare January 17, 2023 12:58
@nflaig
Copy link
Contributor Author

nflaig commented Mar 4, 2023

@SimenB sorry for the ping but is there anything I can do to get this merged and released? 🙏

@SimenB SimenB merged commit 081d8a0 into siimon:master Mar 4, 2023
@SimenB
Copy link
Collaborator

SimenB commented Mar 4, 2023

Thanks!

This pull request was closed.
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