OpenTelemetry
Last updated
Last updated
RoadRunner offers OTEL (OpenTelemetry) plugin, which provides a unified standard for tracing, logging, and metrics information. This plugin allows you to send tracing data from RoadRunner to tracing collectors like New Relic, Zipkin, Jaeger, Datadog, and more. Starting with v2023.3
, the Jaeger
exporter is deprecated. Please use OTLP
instead: docs.
Read more about OpenTelemetry on the official site.
The OpenTelemetry plugin is designed to integrate with various tracing collectors to provide end-to-end tracing of requests across multiple services. The plugin is built to support the OpenTelemetry standard, which provides a unified way of collecting telemetry data across various languages and frameworks.
The plugin supports tracing, logging, and metrics data, but currently only tracing information is stable and safe to use in production.
Here is an example configuration file:
Note, that you may also use OTEL envs in the OTEL
plugin configuration using Shell-Parameter-Expansion syntax. For example:
Once the plugin is activated, the grpc
and jobs
plugins will use the configuration to send tracing data to the collector. The http
plugin requires the otel
middleware to be added to the middleware list.
Here is an example:
The otel
section of the configuration file contains the following options:
The OpenTelementy OTLP endpoint can be used with 2 different ports: 4318
and 4317
, docs. In general, port 4317
is used for the gRPC
traces (with the gRPC
OTLP client). While port 4318
is used for the http
OTLP client. Keep in mind that having a gRPC
collector with an http
endpoint will cause a send error.
The OpenTelemetry Collector offers a vendor-agnostic implementation of how to receive, process and export telemetry data. It removes the need to run, operate, and maintain multiple agents/collectors. This works with improved scalability and supports open-source observability data formats (e.g. Jaeger, Prometheus, Fluent Bit, etc.) sending to one or more open-source or commercial back-ends. The local Collector agent is the default location to which instrumentation libraries export their telemetry data.
To start the collector, you can use the official Docker container otel/opentelemetry-collector-contrib
.
Here is an example docker-compose.yaml
:
Read more about the OpenTelemetry Collector on the official site.
The collector is started with the otel-collector-config.yml
configuration file, which specifies how the collector should receive, process, and export the tracing data.
Here is an example configuration file that sends data to Zipkin and Datadog:
Read more about the OpenTelemetry Collector configuration on the official site.
The official PHP SDK for OpenTelemetry provides support for the OpenTelemetry standard on the PHP side.
To configure your PHP application to use the RoadRunner OpenTelemetry plugin, you need to use environment variables.
Here is an example of the required environment variables:
You can pass these environment variables to your PHP application from the RoadRunner configuration using the server.env
option:
Here is the list of currently supported plugin
Thanks to Brett McBride, he created a rr-otel PHP demo.
If you have problems with setting endpoints via OTEL envs, read this comment: link
Option | Description |
---|---|
Option | Description |
---|---|
Plugin/Driver | Description |
---|---|
insecure
a boolean that determines whether to use insecure endpoints (HTTP/HTTPS) or insecure gRPC. The default value is false
.
compress
a boolean that determines whether to use gzip to compress the spans. The default value is false
.
exporter
a string that provides functionality to emit telemetry to consumers. Possible values are otlp
(used for New Relic, Datadog, Jaeger), zipkin
, stdout
or stderr
. The default value is otlp
.
custom_url
a string that is used for the http client to override the default URL. The default value is empty
.
client
a string that determines the client to send the spans. Possible values are http and grpc. The default value is http
.
endpoint
a string that specifies the consumer's endpoint. The default value is 127.0.0.1:4318
.
service_name
a string that specifies the user's service name. The default value is RoadRunner
.
service_version
a string that specifies the user's service version. The default value is 1.0.0
.
headers
a key-value map that contains user-defined headers. The api-key
for New Relic should be here.
resource
a key-value map that contains OTEL resource (https://github.com/open-telemetry/opentelemetry-specification/blob/v1.25.0/specification/resource/semantic_conventions/README.md)
receivers
a key-value map that specifies the protocols the collector should use to receive the tracing data.
processors
a key-value map that specifies the processors to apply to the tracing data before exporting it. In this example, it uses the batch processor, which batches tracing data before exporting it.
exporters
a key-value map that specifies the destination collectors to which the tracing data should be exported. In this example, it exports the tracing data to zipkin
, datadog
, otlp
, and logging
.
service
a key-value map that specifies the service name and the pipelines through which the tracing data flows. In this example, the traces pipeline includes the otlp receiver, batch processor, and zipkin, datadog, otlp, and logging exporters.
Redis
Redis driver, e.g.: link
Memcached
Memcached driver. Native OTEL integration.
In-Memory
In-Memory KV/Jobs driver.
BoltDB
Jobs and KV drivers.
KV
KV PRC layer.
HTTP
HTTP plugin with all HTTP middleware (gzip, http_tracing, headers, etc).
JOBS
JOBS plugin RPC layer.
AMQP
AMQP driver.
SQS
SQS driver.
Kafka
Kafka driver.
NATS
NATS driver.
Beanstalk
Beanstalk driver.