Skip to content

Commit

Permalink
clean: Remove auto-instrumentation support for Kinesis Stream Consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyuan-he committed Sep 26, 2024
1 parent f05d295 commit b0c266c
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
AWS_SQS_QUEUE_URL: str = "aws.sqs.queue.url"
AWS_SQS_QUEUE_NAME: str = "aws.sqs.queue.name"
AWS_KINESIS_STREAM_NAME: str = "aws.kinesis.stream.name"
AWS_KINESIS_STREAM_CONSUMERNAME: str = "aws.kinesis.stream.consumer_name"
AWS_BEDROCK_DATA_SOURCE_ID: str = "aws.bedrock.data_source.id"
AWS_BEDROCK_KNOWLEDGE_BASE_ID: str = "aws.bedrock.knowledge_base.id"
AWS_BEDROCK_AGENT_ID: str = "aws.bedrock.agent.id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
AWS_BEDROCK_GUARDRAIL_ID,
AWS_BEDROCK_KNOWLEDGE_BASE_ID,
AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER,
AWS_KINESIS_STREAM_CONSUMERNAME,
AWS_KINESIS_STREAM_NAME,
AWS_LAMBDA_FUNCTION_ARN,
AWS_LAMBDA_FUNCTION_NAME,
Expand Down Expand Up @@ -398,9 +397,6 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri
elif is_key_present(span, AWS_KINESIS_STREAM_NAME):
remote_resource_type = _NORMALIZED_KINESIS_SERVICE_NAME + "::Stream"
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_KINESIS_STREAM_NAME))
elif is_key_present(span, AWS_KINESIS_STREAM_CONSUMERNAME):
remote_resource_type = _NORMALIZED_KINESIS_SERVICE_NAME + "::StreamConsumer"
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_KINESIS_STREAM_CONSUMERNAME))
elif is_key_present(span, _AWS_BUCKET_NAME):
remote_resource_type = _NORMALIZED_S3_SERVICE_NAME + "::Bucket"
remote_resource_identifier = _escape_delimiters(span.attributes.get(_AWS_BUCKET_NAME))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import importlib

from amazon.opentelemetry.distro._aws_attribute_keys import (
AWS_KINESIS_STREAM_CONSUMERNAME,
AWS_KINESIS_STREAM_NAME,
AWS_LAMBDA_FUNCTION_ARN,
AWS_LAMBDA_FUNCTION_NAME,
Expand Down Expand Up @@ -249,6 +248,3 @@ def extract_attributes(self, attributes: _AttributeMapT):
stream_name = self._call_context.params.get("StreamName")
if stream_name:
attributes[AWS_KINESIS_STREAM_NAME] = stream_name
consumer_name = self._call_context.params.get("ConsumerName")
if consumer_name:
attributes[AWS_KINESIS_STREAM_CONSUMERNAME] = consumer_name
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
AWS_BEDROCK_GUARDRAIL_ID,
AWS_BEDROCK_KNOWLEDGE_BASE_ID,
AWS_CONSUMER_PARENT_SPAN_KIND,
AWS_KINESIS_STREAM_CONSUMERNAME,
AWS_KINESIS_STREAM_NAME,
AWS_LAMBDA_FUNCTION_NAME,
AWS_LAMBDA_RESOURCEMAPPING_ID,
Expand Down Expand Up @@ -1144,27 +1143,6 @@ def test_sdk_client_span_with_remote_resource_attributes(self):
)
self._mock_attribute([AWS_STEPFUNCTIONS_ACTIVITY_ARN], [None])

# Validate behaviour of AWS_KINESIS_STREAM_CONSUMERNAME present, then remove it.
self._mock_attribute(
[AWS_KINESIS_STREAM_CONSUMERNAME],
["aws_stream_consumername"],
keys,
values,
)
self._validate_remote_resource_attributes("AWS::Kinesis::StreamConsumer", "aws_stream_consumername")
self._mock_attribute([AWS_KINESIS_STREAM_CONSUMERNAME], [None])

# Validate behaviour with both AWS_KINESIS_STREAM_NAME and AWS_KINESIS_STREAM_CONSUMERNAME
# present, then remove it.
self._mock_attribute(
[AWS_KINESIS_STREAM_NAME, AWS_KINESIS_STREAM_CONSUMERNAME],
["aws_stream_name", "aws_stream_consumername"],
keys,
values,
)
self._validate_remote_resource_attributes("AWS::Kinesis::Stream", "aws_stream_name")
self._mock_attribute([AWS_KINESIS_STREAM_NAME, AWS_KINESIS_STREAM_CONSUMERNAME], [None, None])

# Validate behaviour of AWS_LAMBDA_FUNCTION_NAME attribute, then remove it.
self._mock_attribute([AWS_LAMBDA_FUNCTION_NAME], ["aws_lambda_function_name"], keys, values)
self._validate_remote_resource_attributes("AWS::Lambda::Function", "aws_lambda_function_name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from opentelemetry.trace.span import Span

_STREAM_NAME: str = "streamName"
_CONSUMER_NAME: str = "consumerName"
_BUCKET_NAME: str = "bucketName"
_QUEUE_NAME: str = "queueName"
_QUEUE_URL: str = "queueUrl"
Expand Down Expand Up @@ -181,8 +180,6 @@ def _test_patched_botocore_instrumentation(self):
kinesis_attributes: Dict[str, str] = _do_extract_kinesis_attributes()
self.assertTrue("aws.kinesis.stream.name" in kinesis_attributes)
self.assertEqual(kinesis_attributes["aws.kinesis.stream.name"], _STREAM_NAME)
self.assertTrue("aws.kinesis.stream.consumer_name" in kinesis_attributes)
self.assertEqual(kinesis_attributes["aws.kinesis.stream.consumer_name"], _CONSUMER_NAME)

# S3
self.assertTrue("s3" in _KNOWN_EXTENSIONS)
Expand Down Expand Up @@ -372,7 +369,7 @@ def _reset_mocks(self):

def _do_extract_kinesis_attributes() -> Dict[str, str]:
service_name: str = "kinesis"
params: Dict[str, str] = {"StreamName": _STREAM_NAME, "ConsumerName": _CONSUMER_NAME}
params: Dict[str, str] = {"StreamName": _STREAM_NAME}
return _do_extract_attributes(service_name, params)


Expand Down

0 comments on commit b0c266c

Please sign in to comment.