Add additional OpenTelemetry Instrumentation

OpenTelemetry provides extensive instrumentation for many popular libraries and frameworks. During the installation of AppSignal and OpenTelemetry, you may have installed some instrumentation packages already, but you may need to add additional instrumentation packages to monitor specific libraries your application uses.

This guide explains how to identify, install, and configure additional OpenTelemetry instrumentation packages for better observability coverage.

Why Add Additional Instrumentation?

Your application might use libraries that aren't covered by the instrumentation packages you installed during setup, such as:

  • Database drivers
  • HTTP client libraries
  • Message queue systems
  • Custom or niche libraries

Adding instrumentation for these libraries provides a more complete monitoring setup for all components of your application.

General Steps

This section describes the steps that are needed for most languages to instrument additional library. Check the Language-Specific Instructions section for language specific steps.

1. Identify Libraries to Instrument

First, determine which libraries your application uses that you'd like to monitor. Common candidates include:

  • Database clients (MySQL, PostgreSQL, MongoDB, Redis)
  • HTTP clients
  • Message queues (RabbitMQ, Kafka, SQS)
  • Template engines

2. Find Instrumentation Packages

Look for instrumentation packages in this order of preference:

  1. Official OpenTelemetry packages - Maintained by the OpenTelemetry community
  2. OpenTelemetry contrib packages - Community-contributed instrumentation
  3. Third-party packages - Ensure you trust the maintainer and review the code

Check the OpenTelemetry Registry for available instrumentation packages.

Note that some libraries may include OpenTelemetry instrumentation on their own and no further setup is needed.

3. Install the Package

Once you've found a relevant instrumentation package, install the instrumentation package using your language's package manager.

For example:

Go
go get go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp

4. Initialize the Instrumentation

Depending on the language and SDK instrumentation method, instrumentation packages may require initialization in your application's startup code. This typically involves:

  • Importing the instrumentation package
  • Calling an initialization function
  • Configuring any package-specific options

For some languages, like PHP and Java using auto instrumentations, this step is not necessary. It will automatically set up the instrumentation, unless instructed otherwise.

5. Check Incoming Data

After installation, verify that the instrumentation is working:

  • Check that new spans about the instrumented library appear in your traces reported to AppSignal.com.
  • Confirm metrics about the instrumented library are being reported to AppSignal.com.
  • Test error scenarios to ensure errors are reported.

Language-Specific Instructions

For detailed instructions on adding instrumentation packages for specific languages:

Troubleshooting

Common Issues

  • Missing traces: Ensure the instrumentation is initialized before the library is used.
  • Incomplete data: Check if the instrumentation package supports your library version.
  • Duplicate spans: Avoid instrumenting the same library multiple times.

Getting Help

If you encounter issues:

  1. Check the instrumentation package documentation
  2. Contact AppSignal support for assistance