Download the PHP package penguin-seven/thinkphp-open-telemetry without Composer

On this page you can find all versions of the php package penguin-seven/thinkphp-open-telemetry. 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 thinkphp-open-telemetry

thinkphp-open-telemetry

ThinkPHP 的 OpenTelemetry 扩展包,用于接入 SigNoz 等可观测性平台。

功能特性

安装

配置

config/open_telemetry.php 中配置(如果没有该文件,请创建):

使用方法

1. HTTP 请求追踪

app/middleware.php 中注册中间件:

2. 队列任务追踪 (TraceQueueListener)

要开启队列任务的追踪,需要在项目的 config/event.php 中配置事件监听器。

TraceQueueListener 会自动监听任务的开始、结束和失败事件,并生成相应的 Span。

打开 config/event.php,在 listen 数组中添加以下配置:

配置完成后,ThinkPHP Queue Worker 在处理任务时会自动上报 Trace 数据。 由于使用了 HTTP 长连接,Worker 进程在长驻内存运行时会复用与 SigNoz 的连接,确保高性能。

3. 手动埋点

4. Infrastructure 监控对接

SigNoz 的 Infrastructure 监控需要采集服务器(主机)的指标(如 CPU、内存、磁盘 IO 等)。这不能仅通过 PHP 代码完成,需要在服务器上运行 OpenTelemetry Collector

本扩展包会自动上报 host.name 属性,使得 SigNoz 可以将 PHP 的 Trace 数据与 Infrastructure 指标关联起来。

对接步骤

  1. 部署 OpenTelemetry Collector (Host Metrics)

    为了方便部署,本项目提供了 Docker Compose 示例配置。

    请查看目录:examples/host-metrics/

    • otel-collector-config.yaml: 包含 hostmetrics 接收器的完整配置
    • docker-compose.yaml: 一键启动 Collector 的配置

    快速启动:

    该 Collector 会采集主机的 CPU、内存、磁盘等指标,并上报给 SigNoz。 注意:请修改 otel-collector-config.yaml 中的 endpoint 指向您的 SigNoz 服务地址。

  2. 确保 Host Name 一致

    SigNoz 通过 host.name 关联 Trace 和 Host Metrics。

    • Host Metrics Collector: 默认会上报宿主机的主机名。
    • PHP 应用: 默认使用 php_uname('n')

    如果 PHP 运行在 Docker 容器中,容器的主机名(Container ID)通常与宿主机不同。 为了实现关联,请在 config/open_telemetry.php 中配置 host_name,使其与宿主机一致:

  3. 应用层资源监控

    本扩展包会在每个 Root Span(请求入口)结束时,自动记录当前 PHP 进程的内存使用情况:

    • process.memory.usage: 当前分配的内存量 (bytes)
    • process.memory.peak_usage: 内存使用峰值 (bytes)

    您可以在 SigNoz 的 Trace 详情中查看这些属性,或基于这些属性创建自定义仪表盘。


All versions of thinkphp-open-telemetry with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0
ext-json Version *
guzzlehttp/guzzle Version ^6.3|^7.0
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 penguin-seven/thinkphp-open-telemetry contains the following files

Loading the files please wait ...