question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question of the span decorator

See original GitHub issue

Hi, I am confused with this code, why context.with use context.active ?

In my opinion it will cause parentSpan always be the rootSpan without context.with in the code.

const currentSpan = trace.getSpan(context.active());
const tracer = trace.getTracer('default')

return context.with(trace.setSpan(context.active(), currentSpan), () => {
  // ...
});

I think it should be

const tracer = trace.getTracer('default')
const span = tracer.startSpan(
  name || `${target.constructor.name}.${propertyKey}`,
);

return context.with(trace.setSpan(context.active(), span), () => {
  // ...
});

For example

class Test {
  @Span()
  f1() {
    // ...
  }

  @Span()
  f2() {
    this.f1();
  }
}

current Span decorator won’t let f1 be the child of f2

Thanks for your help.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pragmaticivancommented, Jan 3, 2022

Howdy! I will take a look at it today, sorry about the delay!

0reactions
mentos1386commented, Jan 4, 2022

@pragmaticivan i cant say if it only happens when not using controllers, but in my case yes.

It’s not called by “rest” or “graphql” but it’s part of AWS SQS in our case. So there is no instrumentation from controllers, but there is instrumentation by the aws-sdk (the first two spans on my previous comment with image).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Would be helpful to have function decorators for transactions ...
The current context managers for starting transactions and marking spans are great. However, there have been a few cases where having decorators for ......
Read more >
Zend Framework Zend_Form Decorators: <span> Inside ...
I have tried and, ultimately, failed to achieve this myself using the same approach. It would seem that the easiest way to do...
Read more >
TV or Not TV? It's Not Even an Honest Decorating Question ...
Judging from the typical shelter magazine or decorating book, you'd think the lucky few who occupy those to-die-for homes never watch TV.
Read more >
box-decoration-break - CSS: Cascading Style Sheets | MDN
The box-decoration-break CSS property specifies how an element's fragments should be rendered when broken across multiple lines, columns, ...
Read more >
Question modifiers - Docassemble
The decoration modifier adds an icon to the right of the question text. In the example above, kids has been defined in an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found