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

docs(metrics): extract Metrics code snippets in separate files #1245

Merged
merged 2 commits into from
Jan 17, 2023

Conversation

niko-achilles
Copy link
Contributor

Description of your changes

The code snippets are extracted to their own separate files, placed under docs/snippets/metrics.
And project documentation in docs/core/metrics.md references the code snippets, which are extracted to their own separate files.

Code snippets of metrics created, in path docs/snippets/metrics:

  1. basicUsage.ts
  2. sam.ts
  3. createMetrics.ts
  4. customDimensions.ts
  5. multiValueMetrics.ts
  6. defaultDimensions.ts
  7. defaultDimensionsMiddy.ts
  8. setDefaultDimensions.ts
  9. defaultDimensionsDecorator.ts
  10. middy.ts
  11. decorator.ts
  12. manual.ts
  13. throwOnEmptyMetrics.ts
  14. captureColdStartMetricMiddy.ts
  15. captureColdStartMetricDecorator.ts
  16. addMetadata.ts
  17. singleMetricDifferentDimsMiddy.ts
  18. singleMetricDifferentDimsDecorator.ts

Each code snippet is referenced as --8<-- "docs/snippets/metrics/.ts" in docs/core/metrics.md .

TODO items:

  1. Lint code snippets created in path docs/snippets/metrics by using current eslint rules that are used for packages managed by monorepo as workspaces
  2. Correct code snippets by consulting the eslint findings.
  3. May Adjust the eslint configuration to documentation needs, e.g. allow any type or adjust the code snippets by removing event and context from the handler signature .
  4. introduce docs/snippets/metrics as workspace in package.json managed by monorepo . This will enable to reuse the .tsconfig.es.json used by workspaces in monorepo or to identify the need to improve .tsconfig.es.json, e.g. introducing noEmit: true which signals to a dev. that the tsconfig.es.json file is used for linting/dev. purposes only. Also the tsconfig file used for linting should have the experimentalDecorators: true .

How to verify this change

Modified docs/core/metrics.md
Added code snippets as .ts files in path docs/snippets/metrics

Related issues, RFCs

Issue number: #1221 #729

PR status

Is this ready for review?: YES
Is it a breaking change?: NO

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

  • 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.

@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Jan 13, 2023
@niko-achilles niko-achilles changed the title docs(metrics): extract Metrics code snippets in separate files #1221 docs(metrics): extract Metrics code snippets in separate files Jan 13, 2023
@niko-achilles
Copy link
Contributor Author

@dreamorosi please review this commit and read the TODO items described in the comment.
Have documented the TODOS for continuation to our work in context of code snippets and docs.

this PR solves issue #1221

@dreamorosi dreamorosi self-requested a review January 14, 2023 13:13
@dreamorosi dreamorosi linked an issue Jan 14, 2023 that may be closed by this pull request
1 task
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jan 14, 2023
@@ -156,16 +126,7 @@ You can call `addMetric()` with the same name multiple times. The values will be
=== "addMetric() with the same name"

```typescript hl_lines="8 10"
import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
Copy link
Contributor

@dreamorosi dreamorosi Jan 16, 2023

Choose a reason for hiding this comment

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

Could you please change the line above (L128) to:

    ```typescript hl_lines="7 9"

this is not an error you introduced but I just noticed that the highlighted lines are not correct, so let's fix it.

Copy link
Contributor Author

@niko-achilles niko-achilles Jan 16, 2023

Choose a reason for hiding this comment

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

@dreamorosi , sure, take a look .

@pull-request-size pull-request-size bot added size/XL PRs between 500-999 LOC, often PRs that grown with feedback and removed size/L PRs between 100-499 LOC labels Jan 16, 2023
@dreamorosi dreamorosi self-requested a review January 17, 2023 10:16
@dreamorosi
Copy link
Contributor

@niko-achilles could you please rebase the branch before we merge it? I see the diff from other commits are here.

git checkout main
git fetch origin
git pull origin main
git checkout my_branch_name
git rebase main
... 
git push origin my_branch_name -f

Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the comments, could you please rebase the branch (see previous message).

@pull-request-size pull-request-size bot added size/L PRs between 100-499 LOC and removed size/XL PRs between 500-999 LOC, often PRs that grown with feedback labels Jan 17, 2023
@niko-achilles
Copy link
Contributor Author

@dreamorosi now we have 2 commits as expected , thanks for the command tips

@dreamorosi dreamorosi merged commit 86d31c3 into aws-powertools:main Jan 17, 2023
@niko-achilles niko-achilles deleted the metrics-code-snippets branch January 17, 2023 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation size/L PRs between 100-499 LOC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: extract Metrics code snippets in separate files
2 participants