Skip to content
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

NoOpTracerProvider test case for botocore instrumentation #2846

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,19 @@ def test_traced_client(self):

request_id = "fdcdcab1-ae5c-489e-9c33-4637c5dda355"
self.assert_span("EC2", "DescribeInstances", request_id=request_id)

@mock_aws
def test_no_op_tracer_provider_ec2(self):
BotocoreInstrumentor().uninstrument()
BotocoreInstrumentor().instrument(
tracer_provider=trace_api.NoOpTracerProvider()
)

ec2 = self._make_client("ec2")
ec2.describe_instances()

spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 0)
@mock_aws
def test_not_recording(self):
mock_tracer = Mock()
Expand Down Expand Up @@ -147,6 +159,20 @@ def test_s3_client(self):

s3.list_buckets()
self.assert_span("S3", "ListBuckets")


@mock_aws
def test_no_op_tracer_provider_s3(self):
BotocoreInstrumentor().uninstrument()
BotocoreInstrumentor().instrument(
tracer_provider=trace_api.NoOpTracerProvider()
)

s3 = self._make_client("s3")
s3.list_buckets()

spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 0)

@mock_aws
def test_s3_put(self):
Expand Down Expand Up @@ -177,6 +203,18 @@ def test_sqs_client(self):
)

@mock_aws
def test_no_op_tracer_provider_sqs(self):
BotocoreInstrumentor().uninstrument()
BotocoreInstrumentor().instrument(
tracer_provider=trace_api.NoOpTracerProvider()
)

sqs = self._make_client("sqs")
sqs.list_queues()

spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 0)
@mock_aws
def test_sqs_send_message(self):
sqs = self._make_client("sqs")
test_queue_name = "test_queue_name"
Expand Down Expand Up @@ -204,6 +242,19 @@ def test_kinesis_client(self):
kinesis.list_streams()
self.assert_span("Kinesis", "ListStreams")

@mock_aws
def test_no_op_tracer_provider_kinesis(self):
BotocoreInstrumentor().uninstrument()
BotocoreInstrumentor().instrument(
tracer_provider=trace_api.NoOpTracerProvider()
)

kinesis = self._make_client("kinesis")
kinesis.list_streams()

spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 0)

@mock_aws
def test_unpatch(self):
kinesis = self._make_client("kinesis")
Expand Down Expand Up @@ -257,6 +308,18 @@ def test_kms_client(self):
self.assertEqual(expected, dict(span.attributes))

@mock_aws
def test_no_op_tracer_provider_kms(self):
BotocoreInstrumentor().uninstrument()
BotocoreInstrumentor().instrument(
tracer_provider=trace_api.NoOpTracerProvider()
)

kms = self._make_client("kms")
kms.list_keys(Limit=21)

spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 0)
@mock_aws
def test_sts_client(self):
sts = self._make_client("sts")

Expand All @@ -267,7 +330,18 @@ def test_sts_client(self):
expected["aws.request_id"] = ANY
# check for exact attribute set to make sure not to leak any sts secrets
self.assertEqual(expected, dict(span.attributes))
@mock_aws
def test_no_op_tracer_provider_sts(self):
BotocoreInstrumentor().uninstrument()
BotocoreInstrumentor().instrument(
tracer_provider=trace_api.NoOpTracerProvider()
)

sts = self._make_client("sts")
sts.get_caller_identity()

spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 0)
@mock_aws
def test_propagator_injects_into_request(self):
headers = {}
Expand Down Expand Up @@ -334,7 +408,18 @@ def test_suppress_instrumentation_xray_client(self):
xray_client.put_trace_segments(TraceSegmentDocuments=["str1"])
xray_client.put_trace_segments(TraceSegmentDocuments=["str2"])
self.assertEqual(0, len(self.get_finished_spans()))
@mock_aws
def test_no_op_tracer_provider_xray(self):
BotocoreInstrumentor().uninstrument()
BotocoreInstrumentor().instrument(
tracer_provider=trace_api.NoOpTracerProvider()
)

xray_client = self._make_client("xray")
xray_client.put_trace_segments(TraceSegmentDocuments=["str1"])

spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 0)
@mock_aws
def test_suppress_http_instrumentation_xray_client(self):
xray_client = self._make_client("xray")
Expand Down
Loading