open-telemetry / opentelemetry-php

The OpenTelemetry PHP Library
https://opentelemetry.io/docs/instrumentation/php/
Apache License 2.0
718 stars 181 forks source link

Laravel metrics can't be generated #1363

Closed strelok29 closed 1 month ago

strelok29 commented 1 month ago

Describe your environment

We are encountering an issue when trying to implement OTEL on our Laravel app, and we are trying to get the traces and metrics from our app using auto instrumentation. The traces part works fine, but the metrics seem to be empty or not working

  1. Are metrics being tracked for Laravel? if yes: how can we debug this?
  2. If not, what are the options we have for metrics? we want to get "All requests" count / duration / status code

Below are the details of our conditions.

Environment:

We are using these OTEL packages

"open-telemetry/detector-container": "^1.0",
"open-telemetry/exporter-otlp": "^1.0",
"open-telemetry/gen-otlp-protobuf": "^1.1",
"open-telemetry/opentelemetry-auto-guzzle": "^1.0",
"open-telemetry/opentelemetry-auto-laravel": "^0.0.26",
"open-telemetry/sdk": "^1.0",
"open-telemetry/transport-grpc": "^1.0",
"open-telemetry/api":"^1.0"

Environment variables on our app

OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
OTEL_SERVICE_NAME=app
OTEL_PHP_AUTOLOAD_ENABLED=true;
OTEL_TRACES_EXPORTER=otlp;
OTEL_METRICS_EXPORTER=otlp;
OTEL_LOGS_EXPORTER=none;
OTEL_EXPORTER_OTLP_PROTOCOL=grpc;
OTEL_PROPAGATORS=tracecontext,baggage;
OTEL_TRACES_SAMPLER=parentbased_traceidratio;
OTEL_PHP_RESOURCE_DETECTORS=all;

Steps to reproduce deploy Laravel app using the given details

What is the expected behavior? I can find the metrics on Prometheus https://opentelemetry.io/docs/specs/semconv/http/http-metrics/

What is the actual behavior? I can't find the metrics on my Prometheus server

brettmc commented 1 month ago

Auto-instrumentation doesn't generate metrics. Usually the types of metrics you're after are generated from spans (traces). Most APM products do this, but you can also use the opentelemetry collector's spanmetrics connector