-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add opentelemetry callback plugin #3091
Add opentelemetry callback plugin #3091
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! I've added some first comments.
Please also check the failing sanity tests.
Also please note that all new plugins and modules must come with tests.
/rebuild_failed |
Codecov Report
@@ Coverage Diff @@
## main #3091 +/- ##
==========================================
- Coverage 43.56% 43.38% -0.18%
==========================================
Files 928 923 -5
Lines 89375 89069 -306
Branches 16284 16265 -19
==========================================
- Hits 38933 38646 -287
+ Misses 48737 48720 -17
+ Partials 1705 1703 -2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome! 👍
@v1v this PR contains the following merge commits: Please rebase your branch to remove these commits. |
This reverts commit 3a54c827c5472553a6baf5598bc76a0f63f020c1.
This reverts commit cab9d8648899c28c0345745690c4ec7a41f7e680.
Co-authored-by: flowerysong <[email protected]>
4130319
to
deb84a6
Compare
Backport to stable-3: 💚 backport PR created✅ Backport PR branch: Backported as #3373 🤖 @patchback |
* Add opentelemetry callback plugin * Apply suggestions from code review Co-authored-by: Felix Fontein <[email protected]> * Formatting (text), booleans and renamed env variables * This should be done in a future release * Remove insecure in favour of the OTEL env variable. Add descriptions * Use OpenTelemetrySource * Move generate_distributed_traces * Move update_span_data and set_span_attribute * Move finish_task * Move start_task * Refactor to support UTs * Add first UT * Fix codestyle * opentelemetry callback entry in the botmeta * Fix linting * Fix signature * Mock methods * Use MagicMock * Mock the methods * UT for transform_to_boolean_or_default * Fix linting * Set test data * Mock _time_ns * Exclude tests for python <= 3.6 * Remove obsoleted setup task type configuration * Remove unused docs * Apply suggestions from code review Co-authored-by: Felix Fontein <[email protected]> * Fix docs * unrequired logic that was originally took from https:/ansible/ansible/blob/devel/lib/ansible/plugins/callback/junit.py\#L226 * Use raise_from for the required dependencies * Fix linting * Add requirements for the UTs * add missing dependency for the opentelemetry plugin in the UTs * Add ANSIBLE_ prefix for the ansible specific options * Add more context in the docs and remove duplicated docs * As suggested in the code review * Verify if the OTEL env variables for the endpoint were set * Fix docs typo * Fix linting * Revert "Fix linting" This reverts commit 3a54c827c5472553a6baf5598bc76a0f63f020c1. * Revert "Verify if the OTEL env variables for the endpoint were set" This reverts commit cab9d8648899c28c0345745690c4ec7a41f7e680. * Remove console_output as suggested * Apply suggestions from code review Co-authored-by: flowerysong <[email protected]> * Delegate the definition of OTEL_EXPORTER_OTLP_INSECURE to the user * Move definitions above, close to the class that uses them Co-authored-by: Felix Fontein <[email protected]> Co-authored-by: flowerysong <[email protected]> (cherry picked from commit 517570a)
@v1v thanks for contributing this plugin! |
* Add opentelemetry callback plugin * Apply suggestions from code review Co-authored-by: Felix Fontein <[email protected]> * Formatting (text), booleans and renamed env variables * This should be done in a future release * Remove insecure in favour of the OTEL env variable. Add descriptions * Use OpenTelemetrySource * Move generate_distributed_traces * Move update_span_data and set_span_attribute * Move finish_task * Move start_task * Refactor to support UTs * Add first UT * Fix codestyle * opentelemetry callback entry in the botmeta * Fix linting * Fix signature * Mock methods * Use MagicMock * Mock the methods * UT for transform_to_boolean_or_default * Fix linting * Set test data * Mock _time_ns * Exclude tests for python <= 3.6 * Remove obsoleted setup task type configuration * Remove unused docs * Apply suggestions from code review Co-authored-by: Felix Fontein <[email protected]> * Fix docs * unrequired logic that was originally took from https:/ansible/ansible/blob/devel/lib/ansible/plugins/callback/junit.py\#L226 * Use raise_from for the required dependencies * Fix linting * Add requirements for the UTs * add missing dependency for the opentelemetry plugin in the UTs * Add ANSIBLE_ prefix for the ansible specific options * Add more context in the docs and remove duplicated docs * As suggested in the code review * Verify if the OTEL env variables for the endpoint were set * Fix docs typo * Fix linting * Revert "Fix linting" This reverts commit 3a54c827c5472553a6baf5598bc76a0f63f020c1. * Revert "Verify if the OTEL env variables for the endpoint were set" This reverts commit cab9d8648899c28c0345745690c4ec7a41f7e680. * Remove console_output as suggested * Apply suggestions from code review Co-authored-by: flowerysong <[email protected]> * Delegate the definition of OTEL_EXPORTER_OTLP_INSECURE to the user * Move definitions above, close to the class that uses them Co-authored-by: Felix Fontein <[email protected]> Co-authored-by: flowerysong <[email protected]> (cherry picked from commit 517570a) Co-authored-by: Victor Martinez <[email protected]>
SUMMARY
Send distributed traces for the ansible runs with OpenTelemetry
ISSUE TYPE
COMPONENT NAME
plugins/callback/opentelemetry.py
ADDITIONAL INFORMATION
You can configure this plugin and then run your playbook with the below environment variables. Those environment variables are the ones defined by the opentelemetry project (see https://opentelemetry-python.readthedocs.io/en/latest/exporter/otlp/otlp.html)
In order to configure this plugins is requried to install the below python libs:
Then you can start sending traces to your OTEL endpoint:
Or even you can see the distributed traces in the console:
This is vendor agnostic, as long as the OpenTelemetry is supported those traces are sent, for instance, when running the
molecule test
theconverge
stage produced the below traces for one of our roles.Molecule was configured with something like:
Questions
Tasks
Follow ups
The below follow ups will be tackle in future PRs after merging this