PHPackages                             opencodeco/hyperf-opentelemetry - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. opencodeco/hyperf-opentelemetry

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

opencodeco/hyperf-opentelemetry
===============================

OpenTelemetry instrumentation for Hyperf framework

v0.3.4(2mo ago)52.1k↓22%1MITPHPPHP &gt;=8.1

Since Sep 23Pushed 2mo agoCompare

[ Source](https://github.com/opencodeco/hyperf-opentelemetry)[ Packagist](https://packagist.org/packages/opencodeco/hyperf-opentelemetry)[ RSS](/packages/opencodeco-hyperf-opentelemetry/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (42)Versions (14)Used By (0)

hyperf-opentelemetry
====================

[](#hyperf-opentelemetry)

![Status](https://camo.githubusercontent.com/082b425492dbf50c8b5c72b97436d58c537749fca7435cd719c87a2c975a584e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617475732d626574612d79656c6c6f77) ![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667) ![PHP](https://camo.githubusercontent.com/3608d890c37c9e9ae69ac64569003e8d2a062365f349a59cd0d6459b2217196d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d3737376262342e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465) ![Hyperf](https://camo.githubusercontent.com/e30eb27717f839c2e2752956179fa27334cde912d14c3192623d98e6b17266e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6672616d65776f726b2d4879706572662d677265656e) ![OpenTelemetry](https://camo.githubusercontent.com/4b1b7201cbdd928c84ddd85c648a73f52b4cc7df2f2479899e579fc853b7acce/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f62736572766162696c6974792d4f70656e54656c656d657472792d6f72616e6765)

Instrumentation library for Hyperf applications with OpenTelemetry support.

This library enables instrumentation of Hyperf-based applications for exporting metrics, traces, and logs compatible with the OpenTelemetry standard.

---

✨ Features
----------

[](#-features)

- 📦 Ready-to-use with Swoole and Coroutine
- 📊 Custom metrics support via Meter
- 📈 Trace instrumentation for:
    - HTTP requests (Hyperf\\HttpServer)
    - Redis
    - Guzzle
    - SQL queries (Hyperf\\Database)
    - MongoDB (GoTask)
- ♻️ Integration with Swoole ContextStorage

---

📦 Installation
--------------

[](#-installation)

```
composer require opencodeco/hyperf-opentelemetry
```

---

⚙️ Configuration
----------------

[](#️-configuration)

1. Publish the configuration file

```
php bin/hyperf.php vendor:publish opencodeco/hyperf-opentelemetry
```

Edit the file config/autoload/open-telemetry.php to adjust settings (enable/disable features, OTLP endpoints, resource attributes, etc).

2. Configure environment variables

Example .env:

```
OTEL_TRACES_ENDPOINT=http://otelcol:4318/v1/traces
OTEL_METRICS_ENDPOINT=http://otelcol:4318/v1/metrics
```

3. Add instrumentation middlewares

config/autoload/middlewares.php:

```
