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

opentelemetry: send logs #4175

Merged
merged 9 commits into from
Oct 10, 2022

Conversation

v1v
Copy link
Contributor

@v1v v1v commented Feb 8, 2022

SUMMARY

Enable shipping logs with OpenTelemetry in order to allow logs correlations with traces.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

opentelemetry

ADDITIONAL INFORMATION

More context with some questions :)

I decided to call self._dump_results in each callback function and store the object in the TaskData. I don't know if this could be problematic and it's worthy to use a different approach, like calling _dump_results when needed. In fact, that's how the logstash and some other plugins work.

As far as I see the output from self._dump_results looks a good candidate since the data structure is ansible based, and therefore there is no need to reinvent any new format but use the one from Ansible core.

From the implementation details I used add_event since Logs/Events are the same in OpenTelemetry -> event and logs with OTEL.

Given

---
- name: MyPlabook
  hosts: localhost
  connection: local

  roles:
  - role: myrole
  tasks:
  - name: MyTask2
    uri:
      url: https://www.elastic.co
      return_content: yes
    register: webpage

And if I run without the logs:

ANSIBLE_OPENTELEMETRY_DISABLE_LOGS=true OTEL_SERVICE_NAME=ansible-logs \
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 \
OTEL_EXPORTER_OTLP_INSECURE=true \
ansible-playbook -i hosts my-playbook.yml

Produces

image

While if I run with the logs:

OTEL_SERVICE_NAME=ansible-logs \
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 \
OTEL_EXPORTER_OTLP_INSECURE=true \
ansible-playbook -i hosts my-playbook.yml

produces

image

Kapture 2022-10-07 at 09 58 24

@ansibullbot ansibullbot added WIP Work in progress callback callback plugin feature This issue/PR relates to a feature request plugins plugin (any type) labels Feb 8, 2022
@felixfontein felixfontein added backport-4 check-before-release PR will be looked at again shortly before release and merged if possible. labels Feb 8, 2022
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

(This also needs a changelog fragment before leaving draft status.)

@v1v
Copy link
Contributor Author

v1v commented Feb 10, 2022

I'll put this implementation on-hold since OTEL span events might eventually become deprecated, and OTEL logs will be the long term approach to put in place, I'll work on this

@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label Feb 18, 2022
@v1v v1v force-pushed the feature/support-logs branch from 80f6370 to 843d04a Compare May 19, 2022 20:55
v1v added a commit to v1v/cicd-demo-2022 that referenced this pull request May 19, 2022
@ansibullbot ansibullbot removed the stale_ci CI is older than 7 days, rerun before merging label May 19, 2022
@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label May 28, 2022
v1v added 3 commits October 7, 2022 09:42
* upstream/main: (203 commits)
  Make pfexec become usable for illumos (ansible-collections#3889)
  znode: add options for authentication (ansible-collections#5306)
  keycloak_user_federation: add explanation and example to vendor option (ansible-collections#4893)
  Next expected release is 5.8.0.
  Allow terraform module to specify complex variable structures (ansible-collections#4797)
  Fix ansible-collections#5313: redhat_subscription module is not idempotent when pool_ids (ansible-collections#5319)
  bitwarden: Add field to search for all item attributes, instead of on… (ansible-collections#5297)
  New Module: Keycloak User Rolemapping (ansible-collections#4898)
  chore: Update lxc_container to support py3 (ansible-collections#5304)
  terraform: run `init` with no-color, too (ansible-collections#5147)
  nmcli: fix error when setting previously unset mac address (ansible-collections#5291)
  [feat] proxmox_snap: snapshot containers with configured mountpoints (ansible-collections#5274)
  machinectl: include the success command (ansible-collections#5287)
  Add SetSessionService to redfish_config (ansible-collections#5009)
  locale_gen: fix UbuntuMode (ansible-collections#5282)
  ini_file: fix lint error (ansible-collections#5307)
  netcup_dnsapi: Add timeout paramter (ansible-collections#5301)
  stable-2.14 is now default.
  Add stable-2.14 to CI, adjust to devel version bump (ansible-collections#5298)
  Try to run reuse workflow without explicitly allowing it for new contributors. (ansible-collections#5296)
  ...
@v1v v1v marked this pull request as ready for review October 7, 2022 09:09
@ansibullbot
Copy link
Collaborator

@v1v this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@ansibullbot ansibullbot added merge_commit This PR contains at least one merge commit. Please resolve! needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html and removed WIP Work in progress stale_ci CI is older than 7 days, rerun before merging labels Oct 7, 2022
@github-actions
Copy link

github-actions bot commented Oct 7, 2022

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

@ansibullbot ansibullbot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Oct 7, 2022
This was referenced Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
callback callback plugin feature This issue/PR relates to a feature request merge_commit This PR contains at least one merge commit. Please resolve! needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants