Skip to content

NH-125600 Add ServiceEntrySpanProcessor._on_ending implementation to reduce overall name pool registrations - #833

Draft
tammy-baylis-swi wants to merge 3 commits into
NH-125600-set-txn-name-testsfrom
NH-125600-txn-name-on-ending
Draft

NH-125600 Add ServiceEntrySpanProcessor._on_ending implementation to reduce overall name pool registrations#833
tammy-baylis-swi wants to merge 3 commits into
NH-125600-set-txn-name-testsfrom
NH-125600-txn-name-on-ending

Conversation

@tammy-baylis-swi

@tammy-baylis-swi tammy-baylis-swi commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Depends on #832.

Implements ServiceEntrySpanProcessor._on_ending, made available with OTel 1.40.0/0.61b0. This reduces total calls to pool.registered(transaction_name) from n + 1 to 1, uses the pool more efficiently (e.g. fewer intermediates taking spots). See ticket for more info.

Also includes accidental bugfix to 256 --> 255 char limit in integration tests.

API's set_transaction_name usage and behaviour are still the same; it will log fewer warning whenever pool capacity reached. Name setting and response time metrics attribute setting are also the same.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the SolarWinds APM OpenTelemetry distribution to defer transaction-name pool registration until span ending by implementing ServiceEntrySpanProcessor._on_ending (available in newer OTel SDKs), reducing repeated pool.registered(...) calls and improving pool utilization. It also updates unit/integration tests to match the new “set attribute first, register at ending” behavior and corrects truncation expectations to 255 characters.

Changes:

  • Add ServiceEntrySpanProcessor._on_ending to register the final sw.transaction value with the transaction name pool just before the span becomes immutable.
  • Update set_transaction_name() to only set (and truncate) the span attribute; pool registration is deferred to _on_ending.
  • Adjust unit/integration tests to reflect the new flow and the 255-character truncation limit.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
solarwinds_apm/trace/serviceentry_processor.py Defers pool registration to _on_ending and updates default transaction-name setting logic.
solarwinds_apm/api/__init__.py Stops pool registration in set_transaction_name() and truncates the attribute value to INTL_SWO_TRANSACTION_ATTR_MAX.
tests/unit/test_processors/test_serviceentry_processor.py Updates unit tests for new set_default_transaction_name signature and default span naming inputs.
tests/unit/test_api.py Updates set_transaction_name() unit tests to expect direct attribute setting (no pool registration).
tests/integration/test_set_transaction_name.py Corrects long-name truncation assertions to 255 characters.
Comments suppressed due to low confidence (1)

solarwinds_apm/trace/serviceentry_processor.py:162

  • _on_ending() introduces a new critical code path that performs the transaction name pool registration and applies the "other" fallback. There are unit tests for on_start()/on_end(), but none that assert _on_ending() registers exactly once for entry spans, skips non-entry spans, and updates the span attribute based on pool.registered(). Adding targeted unit tests would reduce regression risk for this behavior change.
    def _on_ending(self, span: Span) -> None:
        """
        Finalize transaction name by registering with pool.

        This is called before the span becomes immutable, allowing us to update
        the transaction name attribute with the pool-registered version.

Comment thread solarwinds_apm/api/__init__.py
Comment thread solarwinds_apm/trace/serviceentry_processor.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants