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

feat(core): included wrappers and tests for opentelemetry instrumentation #4

Merged

Conversation

MatheusGeiger
Copy link
Member

Infos

Create DjangoStompInstrumentor to create wrapper from django-stomp code and instrument publisher, consumer, ack and nack traces. more details in README.md

DjangoStompInstrumentor

  • main instrument and uninstrument function to initialize django-stomp instrumentators;
  • The function DjangoStompInstrumentor.instrument() execute ConsumerInstrument.instrument() and PublisherInstrument.instrument();

ConsumerInstrument

  • consumer instrument and uninstrument function to create wrappers to trace "CONSUMER", "ACK" and "ACK";
  • wrappers on
wrapt.wrap_function_wrapper(Listener, "on_message", wrapper_on_message)
wrapt.wrap_function_wrapper(Listener, "_create_new_worker_executor", wrapper_create_new_worker_executor)
wrapt.wrap_function_wrapper(StompConnection11, "nack", wrapper_nack)
wrapt.wrap_function_wrapper(StompConnection11, "ack", wrapper_ack)

PublisherInstrument

  • publisher instrument and uninstrument function to create wrappers to trace "CONSUMER", "ACK" and "ACK";
  • wrappers on
wrapt.wrap_function_wrapper(Publisher, "_send_to_broker_without_retry_attempts", wrapper_publisher)
wrapt.wrap_function_wrapper(Publisher, "_send_to_broker", wrapper_publisher)

📁 Folder Structure with tests

opentelemetry_instrumentation_django_stomp
    └── opentelemetry_instrumentation_django_stomp
        ├── __init__.py
        ├── instrumentors
        │   ├── __init__.py
        │   ├── consumer_instrument.py
        │   └── publisher_instrument.py
        ├── package.py
        ├── utils
        │   ├── __init__.py
        │   ├── django_stomp_getter.py
        │   ├── shared_types.py
        │   ├── span.py
        │   └── traced_thread_pool_executor.py
        └── version.py
    └── tests
        ├── __init__.py
        ├── conftest.py
        ├── instrumentors
        │   ├── __init__.py
        │   ├── test_consumer_instrument.py
        │   └── test_publisher_instrument.py
        ├── resources
        │   └── custom-rabbitmq-conf
        │       ├── enabled_plugins
        │       └── rabbitmq.conf
        ├── support
        │   ├── __init__.py
        │   ├── helpers_tests.py
        │   └── otel_helpers.py
        └── utils
            ├── __init__.py
            ├── test_django_stomp_getter.py
            ├── test_span.py
            └── test_traced_thread_pool_executor.py

@MatheusGeiger MatheusGeiger requested a review from a team November 30, 2022 17:00
@MatheusGeiger MatheusGeiger self-assigned this Nov 30, 2022
@@ -0,0 +1,12 @@
[tox]
skipsdist=True
envlist = py310

Choose a reason for hiding this comment

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

issue: We should include the Python versions that are used by ours ecosystem. If we use 3.7 until 3.10, then this would be:

Suggested change
envlist = py310
envlist = py37,py38,py39,py310

Copy link
Member Author

Choose a reason for hiding this comment

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

great suggestion, initially we use only python version because tests with tox running inner docker container have a only python3.10 version. I'm created this issue to implement this feature.

@@ -0,0 +1 @@
__version__ = "0.0.1"

Choose a reason for hiding this comment

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

If we change the version, we should update it here also.

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch. The idea is update to the correct version of PR from release/first-version to main branch.

@MatheusGeiger MatheusGeiger merged commit 799f1f3 into release/first-version Dec 1, 2022
@MatheusGeiger MatheusGeiger deleted the feat/opentelemetry-instrumentation branch December 1, 2022 12:59
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.

2 participants