Skip to content

chore(metrics): improve metrics types and typedocs #1417

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

Merged
merged 3 commits into from
Apr 24, 2023

Conversation

dreamorosi
Copy link
Contributor

@dreamorosi dreamorosi commented Apr 24, 2023

Description of your changes

This PR introduces some improvements to the types and to the docstrings of the Metrics utility, as suggested in the linked issue by @niko-achilles (thank you).

The changes are:

  • added docstrings to all methods of the Metrics class and reviewed existing ones
  • partially revisited, and hopefully simplified/clarified, the implementation of the serializeMetrics method of Metrics
  • changed EmfOutput type Readonly
  • changed StoredMetrics type to Record<string, StoredMetrics>
  • changed Dimensions type to Record<string, string>

Finally, the PR also addresses two housekeeping items unrelated to the linked issue:

  • add @aws-sdk/client-cloudwatch as devDependency of the Metrics package/workspace continuing the work started in chore(ci): phase out aws-sdk usage #1405
  • change the integration tests and related helpers to use @aws-sdk/client-cloudwatch over aws-sdk
  • add jest spies to console.log and console.warn in the Metrics.test.ts file to avoid polluting the test output

Once merged, this PR closes #1373

Related issues, RFCs

Issue number: #1373

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding changes to the examples
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published
  • The PR title follows the conventional commit semantics

Breaking change checklist

Is it a breaking change?: NO

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@dreamorosi dreamorosi self-assigned this Apr 24, 2023
@dreamorosi dreamorosi linked an issue Apr 24, 2023 that may be closed by this pull request
2 tasks
@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Apr 24, 2023
@github-actions github-actions bot added the internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) label Apr 24, 2023
@dreamorosi
Copy link
Contributor Author

private getEnvVarsService(): EnvironmentVariablesService {
return <EnvironmentVariablesService> this.envVarsService;
}

private isHigh(resolution: StoredMetric['resolution']): resolution is typeof MetricResolution['High'] {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed this as it was used both as type guard and runtime check. This is not a major issue in itself, however there are no other usages of this pattern elsewhere in the codebase and since the method that used it has also been simplified the method was now redundant.

@dreamorosi dreamorosi marked this pull request as ready for review April 24, 2023 21:01
@dreamorosi dreamorosi merged commit 50beee2 into main Apr 24, 2023
@dreamorosi dreamorosi deleted the 1373-maintenance-metrics-types branch April 24, 2023 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) size/L PRs between 100-499 LOC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maintenance: Metrics types and Implementation
1 participant