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

Access function args in @Span decorator #470

Open
dan-cooke opened this issue Mar 12, 2024 · 1 comment
Open

Access function args in @Span decorator #470

dan-cooke opened this issue Mar 12, 2024 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@dan-cooke
Copy link

First of all ,thanks for the great library! Its been a joy to work with so far

One pattern that I have noticed myself duplicating almost everywhere is this

  @Span('DocumentsService.create')
  async create(userId: string, orgId: string, dto: CreateDocumentDto) {
    this.traceService.getSpan().setAttributes({
      orgId,
      userId,
      dto: JSON.stringify(dto),
    });
// --- snip

Where I annotate a function with Span, and then immediately set the function args into the span attributes.

Question

Is it possible with reflect-metadata to roll that code into @span , maybe something like this

@Span('DocumentsService.create', ['userId', 'orgId', 'dto'])

Where users have to explicitly set the fields they want to attach to attributes

I am used to this in rust, but I'm not sure if the TS compiler is capable of something like that

@pragmaticivan
Copy link
Owner

pragmaticivan commented May 8, 2024

Hey! this is a reasonable ask, PRs are welcome but it will be quite hard if you want to customize the attribute names. You might need to think about a more customizable interface

@pragmaticivan pragmaticivan added help wanted Extra attention is needed enhancement New feature or request labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants