Skip to content

Feature request: Allow users to specify segment names for captured methods #1084

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
misterjoshua opened this issue Sep 8, 2022 · 3 comments · Fixed by #1092
Closed

Feature request: Allow users to specify segment names for captured methods #1084

misterjoshua opened this issue Sep 8, 2022 · 3 comments · Fixed by #1092
Assignees
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility tracer This item relates to the Tracer Utility

Comments

@misterjoshua
Copy link
Contributor

misterjoshua commented Sep 8, 2022

Description of the feature request

Problem statement

Tracer's capture decorators currently try to determine the name of the segment from the function it decorates. While this is fine for a small project, for a larger app, auto-generated names like ### render are not descriptive enough to identify which part of the code is represented by the segment.

Summary of the feature

I'd like the ability to specify the segment name when I capture methods.

Code examples

const tracer = new Tracer(); // aws lambda powertools

interface MyInterface {
   render(): Promise<string>;
}

class ImplA implements MyInterface {
  @tracer.captureMethod({ segmentName: '### ImplA.render' })
  async render() { ... }
}

class ImplB implements MyInterface {
  @tracer.captureMethod({ segmentName: '### ImplB.render' })
  async render() { ... }
}

Benefits for you and the wider AWS community

Allows developers to more clearly identify the sources of segments in larger codebases. This would make navigating a trace in the X-Ray console easier.

Describe alternatives you've considered

I've been putting metadata in the segments to help identify the source code associated with a segment, but this requires a lot of clicking in the X-Ray console to find what I'm looking for.

Additional context

In my example above, I named my segments to reference the corresponding concrete class names. In an ideal world, I'd want the automatic naming to replicate this. But I was unsure of two things:

  • Whether TypeScript can identify the class name; and
  • Whether we should consider changing the segment naming scheme a breaking change.

Related issues, RFCs

None

@misterjoshua misterjoshua added the triage This item has not been triaged by a maintainer, please wait label Sep 8, 2022
@saragerion
Copy link
Contributor

Thanks for opening this issue. I agree with you about the benefits highlighted and this is certainly a feature we could consider adding in the future.
Please allow us some time to discuss this and come back to you.

@dreamorosi dreamorosi self-assigned this Sep 19, 2022
@dreamorosi dreamorosi added tracer This item relates to the Tracer Utility and removed triage This item has not been triaged by a maintainer, please wait labels Sep 19, 2022
@dreamorosi dreamorosi linked a pull request Sep 19, 2022 that will close this issue
11 tasks
@misterjoshua
Copy link
Contributor Author

misterjoshua commented Sep 19, 2022

@dreamorosi Just as an aside, here's another interesting edge case where specifying subSegmentName will be useful.

image

In this case, the tracer tries to derive the name of the segment from the anonymous function returned by the @Retryable decorator - but the anonymous function will not have a name, so we get an empty segment name as shown in the trace.

image

And here's a workaround for now:

image

Edit: I've opened an issue for this edge case #1093, as I think it's a fixable problem.

@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 the pending-release This item has been merged and will be released soon label Oct 11, 2022
@dreamorosi dreamorosi removed the pending-release This item has been merged and will be released soon label Oct 27, 2022
@dreamorosi dreamorosi added the feature-request This item refers to a feature request for an existing or new utility label Nov 13, 2022
@dreamorosi dreamorosi changed the title Feature (Tracer): Allow users to specify segment names for captured methods Feature request: Allow users to specify segment names for captured methods Nov 14, 2022
@dreamorosi dreamorosi added the completed This item is complete and has been merged/shipped label Nov 14, 2022
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 feature-request This item refers to a feature request for an existing or new utility tracer This item relates to the Tracer Utility
Projects
None yet
3 participants