OpenTelemetry middleware

OpenTelemetry middleware is a unified standard for the tracing, logging and metrics information. At the moment, only tracing information is stable and safe to use in production.

PHP Library

PHP library in the alpha stage at the moment: link.
Thanks to Brett McBride, he created a rr-otel PHP demo.

Original issue

Configuration

OT is a http plugin middleware, so, its configuration is located under the http plugin configuration.

version: "2.7"

rpc:
  listen: tcp://127.0.0.1:6001

server:
  command: "php otel_worker.php"
  env:
    - OTEL_SERVICE_NAME: php
    - OTEL_TRACES_EXPORTER: otlp
    - OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
    - OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:4318
    - OTEL_PHP_TRACES_PROCESSOR: simple
  relay: pipes

http:
  address: 127.0.0.1:15389
  middleware: [gzip, otel]
  pool:
    num_workers: 10
  otel:
    insecure: true
    compress: false
    client: http
    exporter: otlp
    service_name: rr_test
    service_version: 1.0.0
    endpoint: 127.0.0.1:4318


logs:
  encoding: console
  level: debug
  mode: production

otel contains the following keys:

  1. insecure: boolean, default false. Use insecure endpoints (http/https) or insecure gRPC.
  2. compress: boolean, default false. Use gzip to compress the spans.
  3. client: string, default http. Client to send the spans. Possible values: http, grpc.
  4. exporter: string, default otlp. Provides functionality to emit telemetry to consumers. Possible values: otlp (used for new_relic, datadog), zipkin, stdout, jaeger or jaeger_agent to use a Jaeger agent UDP endpoint.
  5. custom_url: string, default empty. Used for the http client to override the default URL.
  6. endpoint: string, default localhost:4318. Consumer's endpoint.
  7. service_name: string, default: RoadRunner. User's service name.
  8. service_version: string, default 1.0.0. User's service version.
  9. headers: key-values map, default empty. User defined headers. new_relic api-key should be here.

OpenTelemetry environment variables

Env variables are used for the PHP process and can be passed via the server env variables.

server:
  command: "php otel_worker.php"
  env:
    - OTEL_SERVICE_NAME: php
    - OTEL_TRACES_EXPORTER: otlp
    - OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
    - OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:4318
    - OTEL_PHP_TRACES_PROCESSOR: simple
  relay: pipes
Edit this page