Download the PHP package cascata/hyperf-opentelemetry without Composer

On this page you can find all versions of the php package cascata/hyperf-opentelemetry. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hyperf-opentelemetry

cascata/hyperf-opentelemetry

Drop-in OpenTelemetry integration for Hyperf 3.1+ — traces, metrics and logs via OTLP, with sensible Swoole defaults.

Out of the box you get:


Requirements

PHP >= 8.1
Hyperf ~3.1.0
Swoole >= 5.0
ext-grpc not required (uses OTLP HTTP)

Install

Register the tracing middleware in config/autoload/middlewares.php:

Add the Monolog handler to config/autoload/logger.php (your existing config):

Set environment variables:

Clear the DI proxy cache and you're done:


Usage

Annotate methods you want traced

Span kinds:

Aspects only work on methods that:

Methods called via new ClassName() won't be intercepted.

Custom metrics


Publish optional resources

The package ships an optional config file and a complete Docker Compose stack.

The published stack lives at BASE_PATH/observability/. Bring it up with:

Grafana: http://localhost:3000 (anonymous Admin).


Architecture

The application only ever speaks OTLP to the collector. Swapping Tempo for Jaeger, or Loki for Elasticsearch, only changes the collector config — your code does not change.


Configuration reference

All values can be set via env or by publishing opentelemetry.php.

Env var Default Purpose
OTEL_ENABLED true Master switch
OTEL_SERVICE_NAME hyperf-app service.name resource attribute
OTEL_SERVICE_NAMESPACE default service.namespace
OTEL_SERVICE_VERSION 1.0.0 service.version
OTEL_DEPLOYMENT_ENV dev deployment.environment.name
OTEL_EXPORTER_OTLP_ENDPOINT http://otel-collector:4318 OTLP HTTP base URL
OTEL_TRACES_SAMPLER_ARG 1.0 TraceID-ratio sampler (0.0 – 1.0)

Troubleshooting

No spans / logs / metrics arriving in Grafana

Verify the collector is reachable from inside the app container:

Enable internal debug logging:

Span::getCurrent() returns no-op span in exception handlers

That's why this package also stores trace_id/span_id in Hyperf\Context — logs emitted after a span closes still correlate. No action needed on your side.

Changes to #[Traced] annotations don't take effect

The Hyperf DI proxy cache must be regenerated:

Batch processor doesn't flush in Swoole

This package uses SimpleSpanProcessor / SimpleLogRecordProcessor by default — they export synchronously, which is the safe choice in long-running Swoole workers. For very high-throughput services, consider implementing a periodic flush listener instead.


Versioning

Branch Hyperf OTel SDK
1.x ~3.1.0 ^1.1

Follows SemVer.


License

MIT


All versions of hyperf-opentelemetry with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
hyperf/context Version ~3.1.0
hyperf/di Version ~3.1.0
hyperf/event Version ~3.1.0
hyperf/framework Version ~3.1.0
hyperf/http-server Version ~3.1.0
hyperf/logger Version ~3.1.0
open-telemetry/api Version ^1.1
open-telemetry/sdk Version ^1.1
open-telemetry/exporter-otlp Version ^1.1
open-telemetry/sem-conv Version ^1.27
php-http/guzzle7-adapter Version ^1.0
guzzlehttp/guzzle Version ^7.8
monolog/monolog Version ^3.0
ramsey/uuid Version ^4.7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cascata/hyperf-opentelemetry contains the following files

Loading the files please wait ...