Documentation forSolarWinds Observability

Python Library instrumentation SDK

The SolarWinds Observability Python Library is a custom distro based on the OpenTelemetry Python agent, and therefore supports the standard OpenTelemetry API. You can use the standard API to manually instrument your applications.

Create a trace manually

To create a trace manually, import trace from opentelemetry, which is a global TracerProvider. Use trace to get_tracer, then start new span that will be set as the current span in the Tracer‘s context at execution.

Here is a simple example:

from opentelemetry import trace
# get Tracer from OpenTelemetry TracerProvider
tracer = trace.get_tracer(__name__)
# create a span using Tracer
with tracer.start_as_current_span("my_custom_span"):
    # do things
    my_cool_thing.do_stuff();
# span ends with the with-statement

The SolarWinds Observability APM OpenTelemetry extensions automatically hook into the auto-configured global trace object when the application starts up. You do not need to create your own trace object.

If you create and use a different trace object, the manual instrumentation spans will not be recognized by the SolarWinds Observability APM extensions or received by the SolarWinds APM collector.

More details

See Tracing in the OpenTelemetry Python Manual Instrumentation docs site and opentelemetry.trace package in the OpenTelemetry Python API documentation for more ways to use the API.

The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.