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

[META 497] Collecting statistics about dropped spans #2302

Closed
AlexanderWert opened this issue Aug 25, 2021 · 1 comment · Fixed by #2707
Closed

[META 497] Collecting statistics about dropped spans #2302

AlexanderWert opened this issue Aug 25, 2021 · 1 comment · Fixed by #2707
Assignees
Labels
agent-nodejs Make available for APM Agents project planning.
Milestone

Comments

@AlexanderWert
Copy link
Member

As described in this spec, agents should collect statistics on dropped spans.

Meta issue: issue details

@AlexanderWert AlexanderWert added this to the 7.16 milestone Aug 25, 2021
@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Aug 25, 2021
@AlexanderWert AlexanderWert removed this from the 7.16 milestone Aug 26, 2021
@estolfo estolfo modified the milestones: 8.1, 8.2 Jan 24, 2022
@trentm trentm modified the milestones: 8.2, 8.3 Mar 28, 2022
@astorm
Copy link
Contributor

astorm commented May 2, 2022

Looking at the spec and using the java agent's implementation as a reference, it looks like span statistics make the assumption that even a span that's not kept still exists for the lifetime of a transaction. Specifically, the statistics include data that's only avaiable at span end (the duration.sum.us property). The Node Agent's current implementation doesn't share this assumption.

ex. when the Node.js agent exceeds the transaction-max-spans limit, our createSpan method skips creating a span. However, in the same transaction-max-spans scenario in the java agent, we mark the span as not recorded (aka not sampled), and it's not until the tracer's endSpan method that the sampled flag is checked and an early return prevents the span from being sent. (you can also see the code calls captureDroppedSpan and that this method eventually records the stats for both count and duraction)

Therefore, in order to implement span statistics, we'll need to change our implementation such that spans are created but their context marked to indicate that recorded/sampled=false when transaction-max-span is exceeded and to not report spans that are unsampled.

Work to be done

  • Implement a setRecorded method for our TraceContext and TraceParent object(s) (using the traceparent flags)
  • Change transactionMaxSpans check to no longer return nullearly, instead create the the span but call setRecorded(false). Also, we'll add add an additional check in span end to prevent recording of unsampled spans (Risk/Unknown: Where to add this check? In span.end? or instrumentation.addEndedSpan? Or just block _encodeAndSendSpan? Or some other thing? What will the effect be now doing all the additional span ending work be?)
  • Implement logic to capture span statistics when sampling or dropping a span. Serialize these statistics on transaction end.

astorm added a commit that referenced this issue May 12, 2022
* feat: setRecorded for traceparent/tracecontext

Part of #2302
astorm added a commit that referenced this issue May 20, 2022
#2694)

feat: span statistics -- ensure dropped span objects are still created

Part of: #2302
astorm added a commit that referenced this issue Jun 6, 2022
* feat: track span statistics

#2302
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-nodejs Make available for APM Agents project planning.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants