LogDrop
Backend TracingPHP

Kubernetes

Add the LogDrop PHP agent to your pods with the LogDrop Helm chart and one pod annotation.

The LogDrop Helm chart installs a small admission webhook, the trace injector. When a pod whose template carries the annotation logdrop.io/trace: php is created, the injector adds an init container that copies the LogDrop PHP agent into the pod, adds the agent's ini directory to PHP_INI_SCAN_DIR and sets the LOGDROP_* settings on your container. Your images and code stay unchanged.

You need a traces ingest key and the other items in Before you start, and the PHP requirements. Java, Node.js, Python, .NET, Go, PHP and Rust services use the same chart, the same values and the same key Secret: if you already trace services in another language, upgrade the chart to 0.1.1-alpha15 and go to step 3.

1. Store the ingest key in each namespace you trace

The traces ingest key is the credential the agent sends traces to LogDrop with. On Kubernetes it lives in a Secret named logdrop-trace-ingest-key in each traced namespace. Create the Secret with:

printf 'Traces key (paste it once, then press Enter): ' && read -rs LOGDROP_TRACE_KEY && echo
if [[ $LOGDROP_TRACE_KEY == ldtk_* && ${#LOGDROP_TRACE_KEY} -eq 71 ]]; then
  kubectl -n <namespace> create secret generic logdrop-trace-ingest-key \
    --from-literal=trace-ingest-key="$LOGDROP_TRACE_KEY"
else
  echo 'That is not one traces key (it starts with ldtk_ and has 71 characters). Paste it once.'
fi
unset LOGDROP_TRACE_KEY

read -rs keeps the key out of your shell history and off the screen, so nothing appears while you paste: paste once. The check refuses a key pasted twice or cut short; LogDrop answers such a key with 401. The commands work in bash and zsh. The Secret must exist in every traced namespace; the chart never creates it. A pod in a namespace without the Secret still starts, but sends nothing (its log says LogDrop ingest key file is missing or invalid).

The key never appears in pod specs or logs: the injector mounts the Secret as a read-only file and the agent reads it from there. With a GitOps tool, keep the Secret in your usual secret workflow (for example Sealed Secrets, External Secrets or SOPS), never as plain text in Git.

2. Install the LogDrop chart with tracing on

The LogDrop Helm chart installs the trace injector in your cluster. The values below turn tracing on and set where traces go, which namespaces are traced and the environment shown in APM.

logdrop-values.yaml
enabled: true
clusterName: <a name for this cluster, for example shop-prod>
cluster:
  uid: <kube-system namespace UID>     # optional; adds the cluster identity to every trace
tracing:
  enabled: true
  endpoint: https://otel.logdrop.io
  namespaces: [<namespace>]           # every namespace whose pods you want to trace
  environment: production
  requirePodLabel: true               # only labelled pods ever reach the injector
networkPolicy:
  apiServerCIDRs: [<API server address>/32]

Find the API server addresses and the cluster UID with:

kubectl get endpointslices -n default -l kubernetes.io/service-name=kubernetes \
  -o jsonpath='{.items[*].endpoints[*].addresses[*]}'                          # API server addresses
kubectl get namespace kube-system -o jsonpath='{.metadata.uid}'                # cluster UID

Managed control planes that call webhooks through an in-cluster proxy also need that proxy as a source. On DigitalOcean Kubernetes, for example, the calls come from the konnectivity agents:

tracing:
  injector:
    sourcePeers:
      - namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: kube-system}}
        podSelector: {matchLabels: {k8s-app: konnectivity-agent}}

Install the chart:

helm upgrade --install logdrop oci://registry.logdrop.io/charts/logdrop-infrastructure --version 0.1.1-alpha15 \
  --namespace logdrop-system --create-namespace -f logdrop-values.yaml

The chart pulls the agent image (registry.logdrop.io/logdrop-php-agent) and the injector's runtime from registry.logdrop.io by digest; see Verify what you install. One image serves PHP 8.1 to 8.5, in Debian-based and Alpine application images. The 0.1.0-alpha2 agent image is built for linux/amd64 only: pods on arm64 nodes are not supported yet. With these values the chart installs one small webhook pod, the trace injector, and nothing else. The same chart also installs the infrastructure metrics agent, which links each trace to its cluster and pod: add its values to this release (Infrastructure Monitoring).

On DigitalOcean Kubernetes with Helm 4, a later helm upgrade can stop with a conflict on the injector webhook's objectSelector, because the platform adds its own rule there. Run the upgrade again with --server-side=true --force-conflicts.

ValueDefaultMeaning
tracing.endpointnoneThe traces endpoint, https://otel.logdrop.io: an HTTPS base URL without path, query or credentials
tracing.namespacesnoneNamespaces whose annotated pods are instrumented. Pods in other namespaces are never sent to the webhook
tracing.environmentproductionEnvironment shown in APM
tracing.serviceNamespaceemptyDefault service group in APM. The pod annotation logdrop.io/service-namespace overrides it
tracing.requirePodLabelfalseAlso require the pod label logdrop.io/trace: php (or java, nodejs, python, dotnet, go, rust), so other pods in a traced namespace never reach the webhook. Recommended
tracing.ingestKeySecret.name / .keylogdrop-trace-ingest-key / trace-ingest-keyThe key Secret in each traced namespace
tracing.caSecret / tracing.caSecretKeyempty / ca.crtA Secret with a private CA. Only needed for an on-premises LogDrop installation with its own CA
tracing.php.imageLogDrop's published agent, by digestSet your own repository and digest (or tag) when you mirror images. Do not clear it: pods are then skipped with php agent image not configured
tracing.php.imagePullSecretsemptyPull Secrets for the agent image. They must exist in every traced namespace
tracing.php.resourcesrequests 10m / 16Mi, limits 100m / 64MiThe init container that copies the agent. Your container keeps its own resources
tracing.injector.timeoutSeconds5How long the API server waits for the injector. After that the pod is created without tracing
tracing.injector.sourceCIDRs / sourcePeersemptyExtra webhook callers besides networkPolicy.apiServerCIDRs
tracing.injector.tls.existingSecret / caBundleemptyYour own webhook certificate (for example from cert-manager) and the CA that signed it. Empty: the chart generates one, reuses it on upgrades and renews it 60 days before it expires
networkPolicy.apiServerCIDRsnoneThe API server addresses allowed to call the injector. Required while networkPolicy.enabled is true, the default
clusterName, cluster.uidemptyThe cluster name and UID added to every trace

With Argo CD or helm template (no cluster access while rendering), the generated webhook certificate changes on every render. Give the chart a certificate with tracing.injector.tls.existingSecret and the CA that signed it in tracing.injector.tls.caBundle.

3. Opt a workload in

A pod annotation is a key and value in a pod's metadata. The injector adds the agent only to pods whose template carries the annotation logdrop.io/trace: php, so you choose which workloads are traced.

Add the label and the annotations to the pod template and roll the workload:

spec:
  template:
    metadata:
      labels:
        logdrop.io/trace: php                 # needed with requirePodLabel: true
      annotations:
        logdrop.io/trace: php
        logdrop.io/service: orders            # optional
        logdrop.io/release: "1.4.2"           # optional
        logdrop.io/libc: musl                 # only for Alpine-based images
AnnotationMeaning
logdrop.io/trace: phpOpts the pod in. php, java, nodejs, python, dotnet, go and rust are supported; any other value is skipped with a status
logdrop.io/libcglibc (the default) or musl. Set musl for Alpine-based images
logdrop.io/serviceService name. Default: the label app.kubernetes.io/name, then the owning Deployment, StatefulSet, DaemonSet or Job, then the container name
logdrop.io/service-namespaceService group in APM. Default: tracing.serviceNamespace
logdrop.io/releaseRelease shown in APM. Default: the label app.kubernetes.io/version
logdrop.io/containerThe container to trace. Default: the first container
logdrop.io/trace-statusWritten by the injector: injected or skipped: <reason>

Annotation values are at most 128 characters, without control characters. Pods that already run are not changed: the agent is added when a pod is created.

The injector sets these on the container:

  • PHP_INI_SCAN_DIR: the agent's ini directory /logdrop-agent/php/ini is added after the directories already listed. When the container does not set the variable, it becomes :/logdrop-agent/php/ini; the leading : keeps PHP's own scan directory, so your image's ini files still load.
  • LOGDROP_SPOOL_DIR and a small writable volume at /var/run/logdrop.io/spool: PHP keeps nothing between requests, so the container's workers batch their spans there and send them together, about once a second (see Limits).
  • The LOGDROP_* settings. The agent's ini reads them when PHP starts, so php-fpm workers get them although php-fpm hides the environment from its workers (clear_env).

Alpine images need logdrop.io/libc: musl

The agent's extension is built for one C library. Debian and Ubuntu images use glibc, the default; Alpine images use musl and need the annotation logdrop.io/libc: musl. With the wrong one, PHP cannot load the extension: your service runs normally, but untraced, and PHP logs Unable to load dynamic library '/logdrop-agent/php/opentelemetry_php_distro_loader.so' when it starts. Check the image's base before you opt the workload in:

docker run --rm --entrypoint cat <image> /etc/os-release | grep '^ID='

ID=alpine needs the annotation; debian or ubuntu does not.

A PHP_INI_SCAN_DIR set only in your image (ENV PHP_INI_SCAN_DIR=… in a Dockerfile) is not seen by the injector and is replaced: set it in the container's env instead, and the injector keeps your directories.

4. Check it

Check that the injector added the agent to the new pods. It records the result in the pod annotation logdrop.io/trace-status:

kubectl -n <namespace> get pod <pod> -o jsonpath='{.metadata.annotations.logdrop\.io/trace-status}'

injected means the agent is in. The container log then shows one line from the agent, once per PHP worker process:

[logdrop-agent] INFO LogDrop PHP agent 0.1.0-alpha2 is tracing service "orders" (environment "production") to otel.logdrop.io.

Send a request to the service. The trace appears in Trace Explorer within about a minute; the service, its endpoints and dependencies appear in Services and the Dependency map within about two minutes. See Tracing & APM.

trace-statusMeaning
injectedThe agent was added
skipped: unsupported languageThe annotation value is not php, java, nodejs, python, dotnet, go or rust. On a php pod: the installed chart is older than 0.1.1-alpha14; upgrade it
skipped: php agent image not configuredYour values clear tracing.php.image. Remove that override
skipped: invalid logdrop.io/libcUse glibc (the default) or musl
skipped: container not foundlogdrop.io/container names no container of the pod
skipped: no containers, skipped: invalid container nameThe pod spec cannot be instrumented
skipped: invalid logdrop.io/service (or service-namespace, release)The annotation value is empty, longer than 128 characters or has control characters
skipped: PHP_INI_SCAN_DIR uses valueFromThe container takes PHP_INI_SCAN_DIR from a ConfigMap or Secret, which the injector never rewrites. Set it as a literal value
skipped: volume name conflict, skipped: mount path conflictThe pod already uses the injector's volume names, or the paths /logdrop-agent, /var/run/logdrop.io/spool or /var/run/secrets/logdrop.io/trace
missingThe webhook did not see the pod: its namespace is not in tracing.namespaces, the pod label is missing with requirePodLabel: true, the pod was created before the chart was installed, or the injector was unavailable

Network and disk

This section lists the network access the injector and the traced pods need, and the storage tracing uses in each pod. Check it when your cluster restricts network traffic, or when pods get no trace-status annotation.

The injector runs in the pod network. The chart gives it a NetworkPolicy that admits only the API server addresses in networkPolicy.apiServerCIDRs, plus tracing.injector.sourceCIDRs and sourcePeers, on the webhook port, and allows it no egress. It has no access to the Kubernetes API. If pods are created without a logdrop.io/trace-status annotation after you install the chart, the control plane probably reaches the webhook from an address you have not listed.

Traced pods send to the traces endpoint on port 443 and need DNS. In namespaces with a default-deny egress policy, allow it:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: {name: allow-logdrop-trace-export, namespace: <namespace>}
spec:
  podSelector:
    matchLabels: {logdrop.io/trace: php}      # without the pod label: podSelector: {}
  policyTypes: [Egress]
  egress:
    - to: [{ipBlock: {cidr: <traces endpoint address>/32}}]
      ports: [{protocol: TCP, port: 443}]

A NetworkPolicy matches IP addresses, not host names. Allow the addresses that otel.logdrop.io resolves to, and check them again if the agent starts to log LogDrop is not reachable.

Disk. Tracing uses no node directories and no persistent volumes. Each traced pod gets an emptyDir volume, limited to 160 MiB, that holds the agent's files (about 90 MB: the extension for every PHP version from 8.1 to 8.5), and one limited to 16 MiB for the spool, which holds at most about a second of spans.

When the injector is unavailable

The webhook never blocks a deploy. When the injector is down, slow or unreachable, pods are created without tracing and without a trace-status annotation; restart them once the injector is back. The injector never refuses a pod: a pod it cannot instrument is created unchanged except for trace-status: skipped: <reason>.

Things to know

These points describe how the injected agent fits into your pods. Check them before you opt production workloads in.

  • LOGDROP_* variables that the container already sets win over the injected ones.
  • The agent sends traces only. The distro's own exporters, metrics and logs stay off, also where the container sets OTEL_* variables for them.
  • A Laravel request gets one server span, Laravel's, named by its route; queries are Laravel's query spans. Other applications get the request span the agent opens, named by the method alone (GET), because the raw path can carry IDs or personal data.
  • Spans leave the process from a background thread: an unreachable endpoint never slows your requests down.
  • Containers added by webhooks that run after the injector are not instrumented.
  • The webhook receives the full spec of every pod created in the traced namespaces (with requirePodLabel: true, only of labelled pods). Its logs carry only the pod name, the namespace and the result, never environment values.

Upgrade, roll back, remove

helm upgrade keeps the webhook certificate and restarts the injector when its configuration changes. Running pods keep the agent they started with until they are restarted, so roll your workloads to pick up a new agent version. helm rollback restores the previous webhook, configuration and certificate together.

helm uninstall removes the injector; instrumented pods keep their copy of the agent until they restart. To stop tracing one workload, remove the annotation and roll it out.

On this page