Skip to content

Docs: Tracer examples for addMetadata and addAnnotation don't work #1699

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

Closed
1 task done
perpil opened this issue Sep 20, 2023 · 3 comments · Fixed by #1704
Closed
1 task done

Docs: Tracer examples for addMetadata and addAnnotation don't work #1699

perpil opened this issue Sep 20, 2023 · 3 comments · Fixed by #1704
Assignees
Labels
completed This item is complete and has been merged/shipped documentation Improvements or additions to documentation

Comments

@perpil
Copy link

perpil commented Sep 20, 2023

What were you searching in the docs?

I was trying to add my own metadata to the xray traces.

Is this related to an existing documentation section?

https://docs.powertools.aws.dev/lambda/typescript/latest/core/tracer/#annotations-metadata

How can we improve?

These examples don't actually work, the result in errors like this:

You cannot add metadata to the main segment in a Lambda execution environment
You cannot annotate the main segment in a Lambda execution environment

Either document that you need to start new segment before you can use addMetadata and addAnnotation with an admonition or wrap these examples with code to start a new segment, switch to it, addMetadata/addAnnotation close the segment and switch back.

Got a suggestion in mind?

No response

Acknowledgment

  • I understand the final update might be different from my proposed suggestion, or refused.
@perpil perpil added documentation Improvements or additions to documentation triage This item has not been triaged by a maintainer, please wait labels Sep 20, 2023
@dreamorosi dreamorosi self-assigned this Sep 21, 2023
@dreamorosi dreamorosi added confirmed The scope is clear, ready for implementation and removed triage This item has not been triaged by a maintainer, please wait labels Sep 21, 2023
dreamorosi added a commit that referenced this issue Sep 21, 2023
<!---
Instructions:
1. Make sure you follow our Contributing Guidelines: https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/CONTRIBUTING.md
2. Please follow the template, and do not remove any section/item. If something is not applicable leave it empty, but leave it in the PR.
3. -->

## Description of your changes

<!---
Include here a summary of the change.

Please include also relevant motivation and context.

Add any applicable code snippets, links, screenshots, or other resources
that can help us verify your changes.
-->

This PR introduces changes to the code snippets found in the Tracer documentation and related to adding annotations and metadata to a segment.

The original snippets were mistakenly not handling the opening and closing of a custom subsegment and were instead suggesting to attempt annotating the `facade` segment.

This is a mistake because that segment is managed by the service and cannot be modified, resulting in an error.

The PR fixes this and shows the full code snippet.

### Related issues, RFCs

<!---
Add here the number (i.e. #42) to the Github Issue or RFC that is related to this PR.

Don't include any other text, otherwise the Github Issue will not be detected.

Note: If no issue is present the PR might get blocked and not be reviewed.
-->
**Issue number:** #1699

## Checklist

- [x] [My changes meet the tenets criteria](https://docs.powertools.aws.dev/lambda-typescript/#tenets)
- [x] I have performed a *self-review* of my own code
- [x] I have *commented* my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
- [x] I have made corresponding changes to the *documentation*
- [x] My changes generate *no new warnings*
- [ ] I have *added tests* that prove my change is effective and works
- [x] The PR title follows the [conventional commit semantics](https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/.github/semantic.yml#L2)

### 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 linked a pull request Sep 21, 2023 that will close this issue
9 tasks
@dreamorosi
Copy link
Contributor

Hi @perpil thanks for reporting this, I'm working on a PR to make some changes to these sections and address your issue.

@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (TypeScript) Sep 21, 2023
@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added pending-release This item has been merged and will be released soon and removed confirmed The scope is clear, ready for implementation labels Sep 21, 2023
@github-actions
Copy link
Contributor

This is now released under v1.13.1 version!

@github-actions github-actions bot added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon labels Sep 21, 2023
@dreamorosi dreamorosi moved this from Coming soon to Shipped in Powertools for AWS Lambda (TypeScript) Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped documentation Improvements or additions to documentation
Projects
2 participants