community.general.opentelemetry – Create distributed traces with OpenTelemetry

Note

This plugin is part of the community.general collection (version 3.8.1).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.opentelemetry.

New in version 3.7.0: of community.general

Synopsis

Requirements

The below requirements are needed on the local controller node that executes this callback.

  • opentelemetry-api (Python library)
  • opentelemetry-exporter-otlp (Python library)
  • opentelemetry-sdk (Python library)

Parameters

Parameter Choices/Defaults Configuration Comments
enable_from_environment
string
added in 3.8.0 of community.general
env:ANSIBLE_OPENTELEMETRY_ENABLE_FROM_ENVIRONMENT
Whether to enable this callback only if the given environment variable exists and it is set to true.
This is handy when you use Configuration as Code and want to send distributed traces if running in the CI rather when running Ansible locally.
For such, it evaluates the given enable_from_environment value as environment variable and if set to true this plugin will be enabled.
hide_task_arguments
boolean
    Choices:
  • no
  • yes
env:ANSIBLE_OPENTELEMETRY_HIDE_TASK_ARGUMENTS
Hide the arguments for a task.
otel_service_name
string
Default:
"ansible"
env:OTEL_SERVICE_NAME
The service name resource attribute.
traceparent
string
Default:
"None"
env:TRACEPARENT

Examples

examples: |
  Enable the plugin in ansible.cfg:
    [defaults]
    callbacks_enabled = community.general.opentelemetry

  Set the environment variable:
    export OTEL_EXPORTER_OTLP_ENDPOINT=<your endpoint (OTLP/HTTP)>
    export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer your_otel_token"
    export OTEL_SERVICE_NAME=your_service_name

Authors

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/opentelemetry_callback.html