Skip to content

opentelemetry-instrumentation-boto3sqs: migrate to current messaging semantic conventions - #4920

Open
anneheartrecord wants to merge 4 commits into
open-telemetry:mainfrom
anneheartrecord:fix/boto3sqs-semconv
Open

opentelemetry-instrumentation-boto3sqs: migrate to current messaging semantic conventions#4920
anneheartrecord wants to merge 4 commits into
open-telemetry:mainfrom
anneheartrecord:fix/boto3sqs-semconv

Conversation

@anneheartrecord

Copy link
Copy Markdown
Contributor

Description

Migrates the boto3sqs instrumentation off the deprecated opentelemetry.semconv.trace.SpanAttributes (schema 1.11.0) onto the current incubating messaging attributes, following the pattern already used by the aiokafka instrumentation:

  • messaging.system: aws.sqsaws_sqs (MessagingSystemValues.AWS_SQS)
  • messaging.destinationmessaging.destination.name
  • messaging.operationmessaging.operation.name (send/receive/process) + messaging.operation.type; send spans now carry operation attributes too
  • dropped messaging.destination_kind and messaging.url (removed from the spec)
  • dropped messaging.conversation_id, which was being set to the send_message_batch entry Id (not a conversation/message-group id per spec)
  • tracer schema_url: 1.11.0 → Schemas.V1_27_0 (same as aiokafka)

Span names are intentionally left as {queue} {operation} to match the existing aiokafka naming and avoid an extra breaking change; happy to adjust if you'd rather move to {operation} {queue} here as well.

Fixes #1639

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — emitted span attribute names/values change

How Has This Been Tested?

  • Updated tests/test_boto3sqs_instrumentation.py to assert the new attributes; full suite passes locally (16 passed) with boto3/botocore 1.34.44 (the pinned test versions), plus ruff check / ruff format --check.

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@anneheartrecord
anneheartrecord requested a review from a team as a code owner August 3, 2026 05:29

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 778f72b085

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +140 to +141
operation_name: str,
operation_type: MessagingOperationTypeValues,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the SQS endpoint in the new convention

Removing queue_url from _enrich_span drops the previous endpoint information without replacing it with the current convention's server.address (and server.port for non-default ports), even though every instrumented call already supplies the queue URL. As a result, spans for AWS endpoints and especially LocalStack/custom endpoints can no longer identify the server that handled the operation, and the declared v1.27 messaging telemetry is incomplete; retain and parse the URL using the generated server attribute constants.

AGENTS.md reference: AGENTS.md:L84-L87

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — added server.address (and server.port when the URL carries an explicit port, e.g. LocalStack) parsed from the queue URL in _enrich_span, replacing the endpoint info the old messaging.url attribute provided. Covered by the updated default-attrs assertions plus a new custom-endpoint test. 5804e8c

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5804e8c649

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +162 to +163
if parsed_url.port:
span.set_attribute(SERVER_PORT, parsed_url.port)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle malformed queue URLs without changing application errors

When a custom QueueUrl contains a nonnumeric or out-of-range port, accessing parsed_url.port raises ValueError before the wrapped botocore operation runs. Previously this value was forwarded so botocore could produce its own validation or request error; the instrumentation now changes application behavior instead of preserving the underlying exception. Skip the server attributes when URL parsing fails.

AGENTS.md reference: AGENTS.md:L80-L82

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, this one was a real behaviour change — urlparse(...).port raises for http://localhost:not-a-port/... (and urlparse itself raises on an unclosed IPv6 bracket), so the instrumentation was failing the call before botocore could report the bad URL. Fixed in 5348926: parsing is wrapped and both server attributes are skipped when it fails, with tests for the malformed-port and unparsable-URL cases.

Comment on lines +162 to +163
if parsed_url.port:
span.set_attribute(SERVER_PORT, parsed_url.port)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Omit default ports from server.port

When a valid queue URL explicitly includes its scheme's default port, such as https://host:443/... or http://host:80/..., this truthiness check emits server.port. The current server semantic convention requires omitting the attribute for the default port, so the newly added endpoint enrichment produces nonconforming telemetry for these URLs; compare the parsed scheme and only set non-default ports.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I went the other way here. For messaging spans server.port is Recommended with no condition attached to the default port — the omit-if-default requirement is the HTTP client convention, not the server registry one. And the AWS sibling in this repo emits it unconditionally: botocore/utils.py:get_server_attributes sets parsed.port or 443.

What the previous version did get wrong is that the attribute depended on how the caller spelled the endpoint — https://host:443/q got a port and https://host/q did not, for the same server. 5348926 makes it uniform instead: explicit port when present, otherwise the scheme default (443/80), so boto3sqs spans carry the same server.port as the botocore spans for the same call. If you would rather omit defaults here, I am happy to flip it — it is a one-line change either way.

I did not reuse botocore's helper on purpose: opentelemetry-instrumentation-boto3sqs does not depend on the botocore instrumentation package (deps are api, instrumentation, semconv, wrapt), so sharing it would mean adding one.

Reading the port of a malformed queue URL raised before the wrapped
botocore call ran, so a bad QueueUrl surfaced as a ValueError from the
instrumentation instead of botocore's own error. Fall back to no server
attributes in that case, and derive the port from the scheme when the
URL omits it so it no longer depends on how the caller spelled the
endpoint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Make sure boto3sqs instrumentation follows semantic conventions

1 participant