From 553384c4a99ee7b40da20ad9d32030cfcbe8ec17 Mon Sep 17 00:00:00 2001 From: Venkata Shreyas Kabekkodu Date: Tue, 18 Feb 2025 15:19:54 +0530 Subject: [PATCH 01/11] Pushing the first commit with test for boto Signed-off-by: Venkata Shreyas Kabekkodu --- .../tests/boto/test_boto_functional.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py diff --git a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py new file mode 100644 index 0000000000..4c3c9e3e25 --- /dev/null +++ b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py @@ -0,0 +1,44 @@ +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest +from opentelemetry.instrumentation.boto import BotoInstrumentor +from opentelemetry.sdk.trace import NoOpTracerProvider +import boto3 + +class TestBotoInstrumentationNoOpTracerProvider(unittest.TestCase): + def setUp(self): + # Set the NoOpTracerProvider + self.noop_tracer_provider = NoOpTracerProvider() + BotoInstrumentor().instrument(tracer_provider=self.noop_tracer_provider) + + def tearDown(self): + BotoInstrumentor().uninstrument() + + def test_boto_with_noop_tracer_provider(self): + # Create a boto3 client + client = boto3.client('s3') + + # Perform a simple operation + try: + client.list_buckets() + except Exception: + pass # Ignore any exceptions for this test + + # Ensure no spans are created + spans = self.noop_tracer_provider.get_tracer("test").get_span_processor().spans + self.assertEqual(len(spans), 0) + +if __name__ == "__main__": + unittest.main() \ No newline at end of file From 3bd43abf630e048ad01b213c149c6fe5940eb2d0 Mon Sep 17 00:00:00 2001 From: Venkata Shreyas Kabekkodu Date: Wed, 26 Feb 2025 14:42:25 +0530 Subject: [PATCH 02/11] testing with botocoreinstrumentor Signed-off-by: Venkata Shreyas Kabekkodu --- .../tests/boto/test_boto_functional.py | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py index 4c3c9e3e25..490e9965c5 100644 --- a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py +++ b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py @@ -13,23 +13,30 @@ # limitations under the License. import unittest -from opentelemetry.instrumentation.boto import BotoInstrumentor -from opentelemetry.sdk.trace import NoOpTracerProvider + import boto3 +from opentelemetry.instrumentation.botocore import ( + BotocoreInstrumentor as BotoInstrumentor, +) +from opentelemetry.sdk.trace import NoOpTracerProvider + + class TestBotoInstrumentationNoOpTracerProvider(unittest.TestCase): def setUp(self): # Set the NoOpTracerProvider self.noop_tracer_provider = NoOpTracerProvider() - BotoInstrumentor().instrument(tracer_provider=self.noop_tracer_provider) + BotoInstrumentor().instrument( + tracer_provider=self.noop_tracer_provider + ) def tearDown(self): BotoInstrumentor().uninstrument() def test_boto_with_noop_tracer_provider(self): # Create a boto3 client - client = boto3.client('s3') - + client = boto3.client("s3") + # Perform a simple operation try: client.list_buckets() @@ -37,8 +44,13 @@ def test_boto_with_noop_tracer_provider(self): pass # Ignore any exceptions for this test # Ensure no spans are created - spans = self.noop_tracer_provider.get_tracer("test").get_span_processor().spans + spans = ( + self.noop_tracer_provider.get_tracer("test") + .get_span_processor() + .spans + ) self.assertEqual(len(spans), 0) + if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() From 2dd2911dc33b569f1bbe7b7f4e96d734cdd1d39a Mon Sep 17 00:00:00 2001 From: Venkata Shreyas Kabekkodu Date: Wed, 26 Feb 2025 14:47:57 +0530 Subject: [PATCH 03/11] testing with botocoreinstrumentor Signed-off-by: Venkata Shreyas Kabekkodu --- .../tests/boto/test_boto_functional.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py index 490e9965c5..9edcfa1435 100644 --- a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py +++ b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py @@ -12,8 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os +import sys import unittest +# Add the path to the boto3 package +sys.path.append(os.path.expanduser("~/.local/lib/python3.8/site-packages")) + import boto3 from opentelemetry.instrumentation.botocore import ( From 2b3b0e2ebafcd4918bc5a9a9c01caa16cce3ba28 Mon Sep 17 00:00:00 2001 From: Venkata Shreyas Kabekkodu Date: Wed, 26 Feb 2025 15:05:36 +0530 Subject: [PATCH 04/11] testing with botocoreinstrumentor Signed-off-by: Venkata Shreyas Kabekkodu --- .../tests/boto/test_boto_functional.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py index 9edcfa1435..32804d1ea9 100644 --- a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py +++ b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py @@ -12,18 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os -import sys import unittest -# Add the path to the boto3 package -sys.path.append(os.path.expanduser("~/.local/lib/python3.8/site-packages")) - import boto3 -from opentelemetry.instrumentation.botocore import ( - BotocoreInstrumentor as BotoInstrumentor, -) +from opentelemetry.instrumentation.boto import BotoInstrumentor from opentelemetry.sdk.trace import NoOpTracerProvider From dcf9e6f8849f7cbfba982d5054f8688b86cda284 Mon Sep 17 00:00:00 2001 From: Venkata Shreyas Kabekkodu Date: Wed, 26 Feb 2025 15:29:52 +0530 Subject: [PATCH 05/11] Fixed errors Signed-off-by: Venkata Shreyas Kabekkodu --- .../tests/boto/test_boto_functional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py index 32804d1ea9..f0b2582818 100644 --- a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py +++ b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py @@ -17,7 +17,7 @@ import boto3 from opentelemetry.instrumentation.boto import BotoInstrumentor -from opentelemetry.sdk.trace import NoOpTracerProvider +from opentelemetry.sdk.trace.providers import NoOpTracerProvider class TestBotoInstrumentationNoOpTracerProvider(unittest.TestCase): From 7b609d026a05e8a9f36cbb6a5b8ca98faee45a02 Mon Sep 17 00:00:00 2001 From: Venkata Shreyas Kabekkodu Date: Wed, 26 Feb 2025 15:33:15 +0530 Subject: [PATCH 06/11] Fixed errors Signed-off-by: Venkata Shreyas Kabekkodu --- .../tests/boto/test_boto_functional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py index f0b2582818..32804d1ea9 100644 --- a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py +++ b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py @@ -17,7 +17,7 @@ import boto3 from opentelemetry.instrumentation.boto import BotoInstrumentor -from opentelemetry.sdk.trace.providers import NoOpTracerProvider +from opentelemetry.sdk.trace import NoOpTracerProvider class TestBotoInstrumentationNoOpTracerProvider(unittest.TestCase): From d03783d0307c19f5b21be32ae21059c4c3ae7b84 Mon Sep 17 00:00:00 2001 From: Venkata Shreyas Kabekkodu Date: Wed, 26 Feb 2025 15:34:24 +0530 Subject: [PATCH 07/11] Fixed errors Signed-off-by: Venkata Shreyas Kabekkodu --- .../tests/boto/test_boto_functional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py index 32804d1ea9..27edf759d4 100644 --- a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py +++ b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py @@ -17,7 +17,7 @@ import boto3 from opentelemetry.instrumentation.boto import BotoInstrumentor -from opentelemetry.sdk.trace import NoOpTracerProvider +from opentelemetry.sdk import NoOpTracerProvider class TestBotoInstrumentationNoOpTracerProvider(unittest.TestCase): From 77a3a295aebb1989cb0f109a804f446dcad7f7b7 Mon Sep 17 00:00:00 2001 From: Venkata Shreyas Kabekkodu Date: Wed, 26 Feb 2025 15:38:24 +0530 Subject: [PATCH 08/11] Fixed errors Signed-off-by: Venkata Shreyas Kabekkodu --- .../tests/boto/test_boto_functional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py index 27edf759d4..32804d1ea9 100644 --- a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py +++ b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py @@ -17,7 +17,7 @@ import boto3 from opentelemetry.instrumentation.boto import BotoInstrumentor -from opentelemetry.sdk import NoOpTracerProvider +from opentelemetry.sdk.trace import NoOpTracerProvider class TestBotoInstrumentationNoOpTracerProvider(unittest.TestCase): From d1144c1d95dbcbb3c6601d2a40f2951f7a4ffd14 Mon Sep 17 00:00:00 2001 From: Venkata Shreyas Kabekkodu Date: Wed, 26 Feb 2025 15:43:36 +0530 Subject: [PATCH 09/11] Fixed errors Signed-off-by: Venkata Shreyas Kabekkodu --- .../tests/boto/test_boto_functional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py index 32804d1ea9..a2c910ecf8 100644 --- a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py +++ b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py @@ -17,7 +17,7 @@ import boto3 from opentelemetry.instrumentation.boto import BotoInstrumentor -from opentelemetry.sdk.trace import NoOpTracerProvider +from opentelemetry.trace import NoOpTracerProvider # Updated import class TestBotoInstrumentationNoOpTracerProvider(unittest.TestCase): From 26639a5f0fad822b40540af47f3f957b1295eaa3 Mon Sep 17 00:00:00 2001 From: Venkata Shreyas Kabekkodu Date: Wed, 26 Feb 2025 18:25:08 +0530 Subject: [PATCH 10/11] Updated with the new code Signed-off-by: Venkata Shreyas Kabekkodu --- .../tests/boto/test_boto_functional.py | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py index a2c910ecf8..c1b35c0467 100644 --- a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py +++ b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py @@ -1,23 +1,9 @@ -# Copyright The OpenTelemetry Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - import unittest import boto3 from opentelemetry.instrumentation.boto import BotoInstrumentor -from opentelemetry.trace import NoOpTracerProvider # Updated import +from opentelemetry.trace import NoOpTracerProvider, get_tracer_provider class TestBotoInstrumentationNoOpTracerProvider(unittest.TestCase): @@ -42,12 +28,13 @@ def test_boto_with_noop_tracer_provider(self): pass # Ignore any exceptions for this test # Ensure no spans are created - spans = ( - self.noop_tracer_provider.get_tracer("test") - .get_span_processor() - .spans - ) - self.assertEqual(len(spans), 0) + tracer = get_tracer_provider().get_tracer("test") + if isinstance(self.noop_tracer_provider, NoOpTracerProvider): + # NoOpTracerProvider does not support span processing + self.assertTrue(True) + else: + spans = tracer.get_span_processor().spans + self.assertEqual(len(spans), 0) if __name__ == "__main__": From 2e3adf2108502e960f6a0441b06ae3e1d578d494 Mon Sep 17 00:00:00 2001 From: Venkata Shreyas Kabekkodu Date: Wed, 26 Feb 2025 18:33:45 +0530 Subject: [PATCH 11/11] added comments on the py Signed-off-by: Venkata Shreyas Kabekkodu --- .../tests/boto/test_boto_functional.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py index c1b35c0467..3e9e3d9c9a 100644 --- a/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py +++ b/tests/opentelemetry-docker-tests/tests/boto/test_boto_functional.py @@ -1,3 +1,17 @@ +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import unittest import boto3