-
Notifications
You must be signed in to change notification settings - Fork 650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
botocore: sns set destination name attribute only if not phone number #3249
base: main
Are you sure you want to change the base?
Conversation
emdneto
commented
Feb 7, 2025
•
edited
Loading
edited
Signed-off-by: emdneto <[email protected]>
call_context | ||
) | ||
if not is_phone_number: | ||
attributes[SpanAttributes.MESSAGING_DESTINATION_NAME] = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also the same TODOs in the tests in opentelemetry-instrumentation-botocore/tests/test_botocore_sns.py
) | ||
if not is_phone_number: | ||
attributes[SpanAttributes.MESSAGING_DESTINATION_NAME] = ( | ||
cls._extract_input_arn(call_context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the issue here is that this should be set to destination_name
we got from cls._extract_destination_name
a few lines above instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, destination_name would be the phone number. I'm not sure if it's a "valid" destination name. According to the semantic convention, it should be used for ARNs, topic /queue names, or something like that 🤔 So I'm presuming if it's phone number there's no destination name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, I think we are being redundant here no?
MESSAGING_DESTINATION and MESSAGING_DESTINATION_NAME are the same thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you ok to drop L82 and keep only attributes[SpanAttributes.MESSAGING_DESTINATION_NAME] = destination_name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would break users though. Until we implement the stable opt-in config I would keep the redundancy. Said that there's another issue there we should not publish the phone number because it's PII. So I would reuse the same variable but redact the phone number in _extract_destination_name
. This way we can use it directly in the span name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this:
diff --git a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py
index 11761360..26388df4 100644
--- a/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py
+++ b/instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/sns.py
@@ -81,14 +81,8 @@ class _OpPublish(_SnsOperation):
MessagingDestinationKindValues.TOPIC.value
)
attributes[SpanAttributes.MESSAGING_DESTINATION] = destination_name
-
- # TODO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when opentelemetry-semantic-conventions 0.42b0 is released
- attributes["messaging.destination.name"] = cls._extract_input_arn(
- call_context
- )
- call_context.span_name = (
- f"{'phone_number' if is_phone_number else destination_name} send"
- )
+ attributes[SpanAttributes.MESSAGING_DESTINATION_NAME] = destination_name
+ call_context.span_name = f"{destination_name} send"
@classmethod
def _extract_destination_name(
@@ -101,7 +95,8 @@ class _OpPublish(_SnsOperation):
if cls._phone_arg_name:
phone_number = call_context.params.get(cls._phone_arg_name)
if phone_number:
- return phone_number, True
+ # phone number redacted because it's a PII
+ return "phone_number", True
return "unknown", False
Hopefully people won't have topics called "phone_number" :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍🏻