Skip to content

fix(boto3sqs): release the received-message span state on uninstrument - #28

Open
ocelotl wants to merge 2 commits into
mainfrom
issue_1704_boto3sqs_span_registry
Open

ocelotl wants to merge 2 commits into
mainfrom
issue_1704_boto3sqs_span_registry

Conversation

@ocelotl

@ocelotl ocelotl commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Description

received_messages_spans, current_span_related_to_token and current_context_token are declared
in the Boto3SQSInstrumentor class body, and _uninstrument never touched them. Two consequences:

  • Every processing span whose message was not deleted stays in the dictionary after instrumentation
    is turned off.
  • The context token that ContextableList.__getitem__ attached stays attached, so a span started
    after uninstrument() is parented to a retained span that is never exported.

_uninstrument now detaches the outstanding token and clears the three attributes. The existing
tests already worked around this by resetting those attributes by hand between cases
(_reset_instrumentor).

This covers the uninstrument part of open-telemetry#1704. It does not address the main report in that issue,
that entries accumulate while instrumentation is active because SQS issues a new receipt handle on
every receive, so the removal attempt in the receive_message wrapper never matches an earlier
copy of the same message. That needs a decision on an eviction policy and belongs in its own
change.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I am a human and not a bot
  • I have run the relevant tests and linting tox environments

received_messages_spans, current_span_related_to_token and
current_context_token are declared in the Boto3SQSInstrumentor class
body, and _uninstrument never touched them. Every processing span whose
message was not deleted stayed in the dictionary after instrumentation
was turned off, and the context token that ContextableList.__getitem__
attached stayed attached, so a span started afterwards was parented to a
retained span that is never exported.

Detach the outstanding token and clear the three in _uninstrument. The
tests already worked around this by resetting the three attributes by
hand between cases.

Refs open-telemetry#1704
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.

1 participant