opentelemetry-php: Auto opentelemetry configuration not working for laravel and php 8.x

Describe your environment Describe any aspect of your environment relevant to the problem, including your php version (php -v will tell you your current version), version numbers of installed dependencies, information about your cloud hosting provider, etc. If you’re reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on master.

Laravel: 7.2x PHP: 8.x Guzzle: 6.3 Composer: 2.x

Steps to reproduce Describe exactly how to reproduce the error. Include a code sample if applicable.

Hi, trying to auto instrument a laravel application, following the documentation https://opentelemetry.io/docs/instrumentation/php/automatic/

Describing the steps taken for auto instrumenting the project:

  1. Base docker image

Using base image php:8.0-fpm-alpine

Installed required packages

RUN sudo apt-get install gcc make autoconf
  1. Install opentelemetry-beta in dockerfile
RUN pecl install opentelemetry-beta
  1. Add ini file in php config

telemetry.ini

[opentelemetry]
extension=opentelemetry.so
COPY config/telemetry.ini $PHP_INI_DIR/conf.d/

Post this I can confirm that package is installed in docker by

php -m | grep opentelemetry
opentelemetry
  1. Set discovery to true
composer config allow-plugins.php-http/discovery true

composer.json

"config": {
        "preferred-install": "dist",
        "platform-check": false,
        "allow-plugins": {
            "php-http/discovery": true
        }
    }
  1. Composer install guzzle7-adapter, open-telemetry/sdk and open-telemetry/opentelemetry-auto-slim

guzzle7-adapter does not install due to required php 7.x error, however open-telemetry/sdk and open-telemetry/opentelemetry-auto-slim gets installed successfully

  1. Add environment

.env file

OTEL_SERVIE_NAME=test
OTEL_PHP_AUTOLOAD_ENABLED=true
OTEL_TRACES_EXPORTER=otlp
OTEL_EXPORTER_OTLP_ENDPOINT=http://xxx.xx.xx.xx:xxxxx
OTEL_PHP_DETECTORS=all
OTEL_EXPORTER_OTLP_PROTOCOL=grpc

What is the expected behavior? What did you expect to see? Laravel application sends traces to the configured OTLP API in gRPC format and can be visualized in jaeger.

What is the actual behavior? What did you see instead? Application is not instrumented.

Additional context Add any other context about the problem here. Maybe I’m missing some steps in auto instrumentation, not really sure. I have other applications in spring boot framework which do send logs to the same OTLP API in gRPC format and can be visualized in jaeger.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 33 (1 by maintainers)

Most upvoted comments

Thank you for your response, this is a poc project. I use Sail for my local development and included some notes in .env.example.

https://github.com/budiprihhastomo/OpenTelemetry-Auto-Laravel

Oh and I kind of see what you mean, but I’m trying to use stderr as a log channel, so my expected is that the logs will appear there when I use the artisan command.

bad documentation with so many unworkable demo. 👎