Skip to content

Conversation

@bizob2828
Copy link
Member

Description

This PR adds the reduced partial granularity logic: keep entry spans, llm spans, and any exit spans that have entity relationship attributes.

This is blocked until #3536 is done because this assumes that a sampling decision has been made and the transaction has assigned .isPartialTrace property signaling the span event logic to execute for a partial trace based on the type

Related Issues

Closes #3455

@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.09%. Comparing base (1535a82) to head (a4ac9a3).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3540      +/-   ##
==========================================
+ Coverage   89.73%   90.09%   +0.36%     
==========================================
  Files         426      412      -14     
  Lines       56229    55242     -987     
  Branches        1        1              
==========================================
- Hits        50457    49771     -686     
+ Misses       5772     5471     -301     
Flag Coverage Δ
integration-tests-cjs-20.x 74.02% <82.14%> (+<0.01%) ⬆️
integration-tests-cjs-22.x 74.06% <82.14%> (?)
integration-tests-cjs-24.x 74.80% <82.14%> (-0.01%) ⬇️
integration-tests-esm-20.x ?
integration-tests-esm-22.x 52.71% <43.57%> (?)
integration-tests-esm-24.x 53.90% <43.57%> (+0.01%) ⬆️
unit-tests-20.x 88.82% <100.00%> (?)
unit-tests-22.x 88.85% <100.00%> (?)
unit-tests-24.x 88.86% <100.00%> (?)
versioned-tests-20.x ?
versioned-tests-22.x ?
versioned-tests-24.x ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bizob2828 bizob2828 force-pushed the partial-reduced branch 2 times, most recently from dbcb533 to 69cd542 Compare December 2, 2025 19:40
@bizob2828 bizob2828 marked this pull request as ready for review December 2, 2025 19:44
@bizob2828 bizob2828 merged commit cfa8f41 into main Dec 2, 2025
51 of 52 checks passed
@github-project-automation github-project-automation bot moved this from Needs PR Review to Done: Issues recently completed in Node.js Engineering Board Dec 2, 2025
@bizob2828 bizob2828 deleted the partial-reduced branch December 2, 2025 20:55
Comment on lines +15 to +22
/**
* This keeps a static list of attributes that are used by
* one or more entity relationship rules to synthesize an entity relationship.
* Note: These attributes also have corresponding TraceSegment attributes
* as this list is checked before a span is made. The ones that are TraceSegment
* attributes are noted in the comments. Any new span attributes being added must
* be checked to ensure those are what is getting assigned to the TraceSegment as well.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this comment. Are we supposed to remember this list exists and add things to it as we support new features?

Copy link
Member Author

@bizob2828 bizob2828 Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, yes. I raised this from the beginning of the project and people don't seem to mind keeping hardcoded list of attributes that produce entity relationships.

The mapping of segment attrs to spans will get removed. The Java and python agent are synthesizing all spans first then applying partial granularity logic. Even though that seems inefficient, we might refactor this to be consistent and drop the mapping of segment entity relationship attrs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a documentation/internals/ doc that walks a developer through adding a new span type or whatever that would need to modify this list.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow. We seem to be adding more internal documentation to our repo. A code comment seems enough in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unlikely anyone is going to remember this list and comment exists the next time something is added which will need to touch it. I am suggesting we have documentation for adding a feature that calls out updating this. For example:

# Add A New Span Type

Spans represent blah blah stuff... To support a new span type we must:

1. Update file X with some code that looks like: <snippet>
2. Update the `SPAN_ENTITY_RELATIONSHIP_ATTRIBUTES` with new attributes that must be included regardless of sampler settings.
3. Etc
4. Etc

Maybe it's not a long document. But I think the whole team would benefit from easy to reference material that clearly shows how to make these rarely made changes.

Copy link
Member Author

@bizob2828 bizob2828 Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a span type. It's whenever new entity relationships are added that rely on new span attributes to make the relationship. The current process will be that our teams will be notified and have a story to address by adding new attributes to the list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done: Issues recently completed

Development

Successfully merging this pull request may close these issues.

Add support for sampler.partial_granularity, starting with "reduced" type

4 participants