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

Remove SDK dependency from opentelemetry-instrumentation-grpc #2474

Merged
merged 4 commits into from
May 4, 2024

Conversation

aabmass
Copy link
Member

@aabmass aabmass commented Apr 29, 2024

Description

Fixes #2473

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@aabmass aabmass requested a review from a team April 29, 2024 18:48
Copy link
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sdk is used directly in tests, should this be documented in the pyproject.toml?

@xrmx
Copy link
Contributor

xrmx commented Apr 30, 2024

This appear to work here:

diff --git a/instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_server_interceptor.py b/instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_server_interceptor.py
index 7b31b085..06a919c4 100644
--- a/instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_server_interceptor.py
+++ b/instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_server_interceptor.py
@@ -39,10 +39,8 @@ from opentelemetry.instrumentation.grpc import (
     GrpcAioInstrumentorServer,
     aio_server_interceptor,
 )
-from opentelemetry.sdk import trace as trace_sdk
 from opentelemetry.semconv.trace import SpanAttributes
 from opentelemetry.test.test_base import TestBase
-from opentelemetry.trace import StatusCode
 
 from .protobuf.test_server_pb2 import Request, Response
 from .protobuf.test_server_pb2_grpc import (
@@ -391,7 +389,7 @@ class TestOpenTelemetryAioServerInterceptor(TestBase, IsolatedAsyncioTestCase):
 
         self.assertEqual(active_span_before_call, trace.INVALID_SPAN)
         self.assertEqual(active_span_after_call, trace.INVALID_SPAN)
-        self.assertIsInstance(active_span_in_handler, trace_sdk.Span)
+        self.assertIsInstance(active_span_in_handler, trace.Span)
         self.assertIsNone(active_span_in_handler.parent)
 
     async def test_sequential_server_spans(self):
@@ -536,7 +534,7 @@ class TestOpenTelemetryAioServerInterceptor(TestBase, IsolatedAsyncioTestCase):
         )
 
         # make sure this span errored, with the right status and detail
-        self.assertEqual(span.status.status_code, StatusCode.ERROR)
+        self.assertEqual(span.status.status_code, trace.StatusCode.ERROR)
         self.assertEqual(
             span.status.description,
             f"{grpc.StatusCode.INTERNAL}:{failure_message}",
@@ -601,7 +599,7 @@ class TestOpenTelemetryAioServerInterceptor(TestBase, IsolatedAsyncioTestCase):
         )
 
         # make sure this span errored, with the right status and detail
-        self.assertEqual(span.status.status_code, StatusCode.UNSET)
+        self.assertEqual(span.status.status_code, trace.StatusCode.UNSET)
         self.assertEqual(span.status.description, None)
 
         # Check attributes

@ocelotl
Copy link
Contributor

ocelotl commented Apr 30, 2024

The sdk is used directly in tests, should this be documented in the pyproject.toml?

Not really, the test dependencies are defined in the test-requirements-x.txt files, the package dependencies are defined in pyproject.toml.

@xrmx
Copy link
Contributor

xrmx commented Apr 30, 2024

The sdk is used directly in tests, should this be documented in the pyproject.toml?

Not really, the test dependencies are defined in the test-requirements-x.txt files, the package dependencies are defined in pyproject.toml.

yeah but we don't have the sdk in test-requirements

@ocelotl
Copy link
Contributor

ocelotl commented Apr 30, 2024

The sdk is used directly in tests, should this be documented in the pyproject.toml?

Not really, the test dependencies are defined in the test-requirements-x.txt files, the package dependencies are defined in pyproject.toml.

yeah but we don't have the sdk in test-requirements

Yeah, that's an unfortunate consequence of our testing being done against a particular commit of the core repo, not a released version of the core repo. We have some test requirements in the tox.ini file (the ones that are core repo packages) and some other test requirements in the test-requirements-x.txt file.

@ocelotl
Copy link
Contributor

ocelotl commented Apr 30, 2024

@aabmass what do you think about @xrmx diff above?

@aabmass
Copy link
Member Author

aabmass commented Apr 30, 2024

@xrmx I think since NonRecordingSpan extends the API Span, this change would always pass. I could ofc make it verify the span context is not empty/invalid.

That said, is there an issue with the tests using the SDK? That seems expected and the SDK is being installed in the test virtualenv

@xrmx
Copy link
Contributor

xrmx commented Apr 30, 2024

@xrmx I think since NonRecordingSpan extends the API Span, this change would always pass. I could ofc make it verify the span context is not empty/invalid.

That said, is there an issue with the tests using the SDK? That seems expected and the SDK is being installed in the test virtualenv

I don't think there's an issue in using the sdk, I think there's an issue in not declaring the dependency explicitly. Said that probably running just pytest after installing the test requirements is not working already so no big deal.

@aabmass
Copy link
Member Author

aabmass commented Apr 30, 2024

Said that probably running just pytest after installing the test requirements is not working already so no big deal.

Ya I think Diego's comment is right, since it's in tox.ini being installed from git HEAD, we don't want to add a hard requirement in the test-requirements.txt as a special case

grpc: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk

@ocelotl ocelotl merged commit 1d3dea0 into open-telemetry:main May 4, 2024
314 checks passed
shadchin pushed a commit to shadchin/opentelemetry-python-contrib that referenced this pull request May 29, 2024
…elemetry#2474)

Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opentelemetry-instrumentation-grpc depends on the SDK
3 participants