Skip to content

Commit 553384c

Browse files
committed
Pushing the first commit with test for boto
Signed-off-by: Venkata Shreyas Kabekkodu <[email protected]>
1 parent 789bf86 commit 553384c

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import unittest
16+
from opentelemetry.instrumentation.boto import BotoInstrumentor
17+
from opentelemetry.sdk.trace import NoOpTracerProvider
18+
import boto3
19+
20+
class TestBotoInstrumentationNoOpTracerProvider(unittest.TestCase):
21+
def setUp(self):
22+
# Set the NoOpTracerProvider
23+
self.noop_tracer_provider = NoOpTracerProvider()
24+
BotoInstrumentor().instrument(tracer_provider=self.noop_tracer_provider)
25+
26+
def tearDown(self):
27+
BotoInstrumentor().uninstrument()
28+
29+
def test_boto_with_noop_tracer_provider(self):
30+
# Create a boto3 client
31+
client = boto3.client('s3')
32+
33+
# Perform a simple operation
34+
try:
35+
client.list_buckets()
36+
except Exception:
37+
pass # Ignore any exceptions for this test
38+
39+
# Ensure no spans are created
40+
spans = self.noop_tracer_provider.get_tracer("test").get_span_processor().spans
41+
self.assertEqual(len(spans), 0)
42+
43+
if __name__ == "__main__":
44+
unittest.main()

0 commit comments

Comments
 (0)