承接 shish/microotlp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shish/microotlp

最新稳定版本:v0.0.11

Composer 安装命令:

composer require shish/microotlp

包简介

A minimal OpenTelemetry logging library

README 文档

README

Because I don't want my logging framework to require a specific web serving framework @_@

MicroOTLP is a minimalistic OpenTelemetry Protocol (OTLP) client library for sending telemetry data (traces, metrics, and logs) to an OTLP collector or backend. It is designed to be lightweight and easy to integrate into various applications without the need for a full-fledged OpenTelemetry SDK.

Benefits

  • Zero dependencies
  • 40x faster than the official OpenTelemetry SDK for PHP
  • No assumption for PSR-7/15/18/etc, frameworks, or logging libraries

Differences

  • Simpler API -- less flexible, but covers all the common cases with much less code

Limitations

  • Only supports HTTP transport for sending data
  • Assumes one Trace per request (though you can create multiple Clients if you want multiple traces)
  • Assumes metrics, logs, and traces are sent to the same Collector

Example

use MicroOTLP\Client;

$c = new Client('http://localhost:4318');

$topSpan = $c->startSpan('my-span');
  $childSpan1 = $c->startSpan('initialising-stuff');
    $c->logMessage("Initialising stuff");
  $childSpan1->end();
  $childSpan2 = $c->startSpan('doing-stuff');
    $c->logMessage("Doing stuff");
    $c->logCounter("number.of.things.done", 1);
    $c->logGauge("current.thing.in.progress", 42);
  $childSpan2->end();
$topSpan->end();

$c->flush();

Performance

This is probably an unfair comparison because I don't have the OTLP SDK native extension installed (PRs to update the benchmark setup are welcome)

A loop of 10,000 x "create span, log message, end span":

No instrumentation :   5ms
MicroOTLP          :  20ms
OpenTelemetry SDK  : 800ms

In a more real-world use case, response times for my image gallery were typically around 50ms -- when I added OTSDK logging, that added 50ms of overhead; microotlp adds 1ms of overhead.

统计信息

  • 总下载量: 1.71k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-04