Skip to content

Commit

Permalink
Adds linting and updates changelog
Browse files Browse the repository at this point in the history
Signed-off-by: Shwejan Bhupathi <[email protected]>
  • Loading branch information
shwejanraj committed Jun 18, 2024
1 parent 9adf9f0 commit b2b1d22
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-instrumentation-asgi`, `opentelemetry-instrumentation-fastapi`, `opentelemetry-instrumentation-starlette` Use `tracer` and `meter` of originating components instead of one from `asgi` middleware
([#2580](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2580))

### Added

- `opentelemtry-instrumentation-botocore` Adds test case for NoOpTracerProvider ([#2586](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2586))

### Fixed

- `opentelemetry-instrumentation-httpx` Ensure httpx.get or httpx.request like methods are instrumented
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,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,14 +160,20 @@ def test_s3_client(self):

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

@mock_aws
def test_no_op_tracer_provider_s3(self):
BotocoreInstrumentor().uninstrument()
BotocoreInstrumentor().instrument(
tracer_provider = trace_api.NoOpTracerProvider()
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):
s3 = self._make_client("s3")
Expand Down Expand Up @@ -183,6 +202,19 @@ def test_sqs_client(self):
"SQS", "ListQueues", request_id=_REQUEST_ID_REGEX_MATCH
)

@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")
Expand Down Expand Up @@ -210,12 +242,12 @@ def test_kinesis_client(self):

kinesis.list_streams()
self.assert_span("Kinesis", "ListStreams")
@mock_kinesis

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

kinesis = self._make_client("kinesis")
Expand Down Expand Up @@ -276,6 +308,19 @@ def test_kms_client(self):
# check for exact attribute set to make sure not to leak any kms secrets
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 @@ -288,6 +333,19 @@ def test_sts_client(self):
# 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 @@ -355,6 +413,19 @@ def test_suppress_instrumentation_xray_client(self):
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

0 comments on commit b2b1d22

Please sign in to comment.