Description
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