Skip to content

Fix charge span leak in the payment service#3276

Open
ayoisaiah wants to merge 3 commits intoopen-telemetry:mainfrom
ayoisaiah:fix-charge-span-payment-service
Open

Fix charge span leak in the payment service#3276
ayoisaiah wants to merge 3 commits intoopen-telemetry:mainfrom
ayoisaiah:fix-charge-span-payment-service

Conversation

@ayoisaiah
Copy link
Copy Markdown

@ayoisaiah ayoisaiah commented Apr 17, 2026

Changes

Fix span lifecycle and exception attribution in the payment service charge span.

  • Wrap the body of charge() in a try/catch/finally so span.end() is always called, including on validation error paths where the span previously leaked.
  • Record the exception and set SpanStatusCode.ERROR on the charge span in the catch block, where the failure actually originates.
  • Remove span.recordException(err) from index.js. The gRPC span now only has its status set to ERROR with the error message, avoiding duplicate exception attribution.

Fixes #3275

Merge Requirements

For new features contributions, please make sure you have completed the following
essential items:

  • CHANGELOG.md updated to document new feature additions
  • Appropriate documentation updates in the [docs][]
  • Appropriate Helm chart updates in the [helm-charts][]

@ayoisaiah ayoisaiah requested a review from a team as a code owner April 17, 2026 11:08
Copy link
Copy Markdown
Contributor

@osullivandonal osullivandonal left a comment

Choose a reason for hiding this comment

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

Nice work on this, thanks for the contribution! Could we add a changelog entry to CHANGELOG.md.

Comment thread src/payment/charge.js
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes OpenTelemetry span lifecycle and error attribution in the payment service so the manually-created charge span is always ended and owns its own exceptions (instead of leaking or attributing exceptions to the parent gRPC span), addressing issue #3275.

Changes:

  • Wrap charge() logic in try/catch/finally to guarantee span.end() on all paths and to record exception + ERROR status on the charge span.
  • Remove explicit recordException() on the parent gRPC span and set its status to ERROR with the error message to avoid duplicate exception attribution.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/payment/index.js Stops recording exceptions on the parent gRPC span; sets ERROR status with message only.
src/payment/charge.js Ensures charge span is always ended and that exceptions/status are recorded on the charge span.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/payment/charge.js
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Payment service: charge span leaks and misattributes exceptions on validation errors

3 participants