# Source: https://docs.datadoghq.com/tracing/guide/injectors.md

---
title: Understanding Injector Behavior with Single Step Instrumentation
description: >-
  Learn how the injector works with Single Step Instrumentation to automatically
  instrument applications at runtime without manual configuration.
breadcrumbs: >-
  Docs > APM > Tracing Guides > Understanding Injector Behavior with Single Step
  Instrumentation
---

# Understanding Injector Behavior with Single Step Instrumentation

## Overview{% #overview %}

The injector is a shared library that automatically instruments applications at runtime. With [Single Step Instrumentation](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/single-step-apm), the injector automates environment setup and tracer initialization, eliminating the need for manual configuration.

## How the injector is loaded{% #how-the-injector-is-loaded %}

### Linux{% #linux %}

On Linux systems, the injector uses the `LD_PRELOAD` mechanismâa dynamic linking feature in Unix-like environmentsâto load itself into all dynamically linked processes. This can happen in two ways:

- Explicitly, by setting the `LD_PRELOAD` environment variable.
- Implicitly, by modifying the system-wide `/etc/ld.so.preload` file.

### Docker{% #docker %}

In Docker environments, the injector uses the same `LD_PRELOAD` mechanism as on Linux hosts to load into application processes at runtime. This allows it to initialize tracing logic and modify environment variables before the application starts.

To enable this, Datadog provides a custom `runc` shim that replaces Docker's default container runtime. The shim's purpose is to:

1. Inject the shared library (the injector) into the container.
1. Set the `LD_PRELOAD` environment variable, ensuring the injector is loaded into all dynamically linked processes inside the container.

### Kubernetes{% #kubernetes %}

In Kubernetes environments, injection is handled by the Datadog Admission Controller, which uses a mutating admission webhook. When a pod is scheduled, the controller:

1. Evaluates whether the pod should be instrumented based on configured selectors (such as namespaces, labels, or specific pod properties).
1. Mutates the pod spec to:
   - Add init containers to download injector and tracer libraries
   - Set environment variables (like `LD_PRELOAD`)
   - Mount volumes to persist injected libraries

## Injector behavior{% #injector-behavior %}

After the injector is loaded into a process's memory spaceâregardless of platformâit performs the following:

- Detects the application's runtime (such as Python, Node.js, PHP, Java, .NET, and Ruby).
- Modifies environment variables or command-line arguments to load the appropriate tracer SDK.
- Emits telemetry to report status and aid in debugging.
- Includes fallback logic to allow the application to continue running uninstrumented if injection fails.

## Further reading{% #further-reading %}

- [Single Step APM Instrumentation](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/single-step-apm)