ifcastle/open-telemetry
最新稳定版本:v0.1.1
Composer 安装命令:
composer require ifcastle/open-telemetry
包简介
Simplified library for OpenTelemetry.
README 文档
README
An alternative version of the library for the OpenTelemetry standard on PHP.
Why is this needed?
The original library for OpenTelemetry has a complex trace-building architecture, leading to an increase in supporting code. This library offers a simpler and flatter interface for generating telemetry.
Installation
Example
<?php declare(strict_types=1); require_once __DIR__ . '/vendor/autoload.php'; use IfCastle\OpenTelemetry\Tracer; $tracer = new Tracer(...); $span = $tracer->createSpan('example-span', SpanKindEnum::INTERNAL); try { $span->addEvent('event-name', ['key' => 'value']) ->setStatus(StatusCodeEnum::OK); } catch (Throwable $exception) { $span->registerException($exception); throw $e; } finally { $span->end(); }
Simplified diagram
The simplified diagram shows the structure used for creating traces:
-
TracerInterfaceis responsible for aggregating telemetry in the application. It is a factory class that creates aTrace. -
TraceInterfaceandSpanInterfacerepresent theTraceandSpanstructures, according to theOpenTelemetrydefinitions. They allow manipulating the data within the entities in a convenient way. -
To record telemetry, you can use only the
TracerInterface, or combine it with theSpanInterface.
@startuml class-diagram interface "TracerInterface" as TracerInterface { +newTelemetryContext() +createTrace() +endTrace(trace) +createSpan(spanName, spanKind, instrumentationScope, attributes) +endSpan(span) +registerLog(instrumentationScope, level, body, attributes) +registerException(throwable, attributes) } interface "SpanInterface" as SpanInterface { +addEvent(name, attributes, timestamp) +recordException(exception, attributes) +end(endEpochNanos) +addLink(link) } interface "TraceInterface" as TraceInterface { +newSpanId() +getTraceId() +getCurrentSpanId() +getCurrentSpan() +createSpan(spanName, spanKind, instrumentationScope, attributes) +endSpan(span) +end() } TraceInterface ..> SpanInterface TracerInterface ..> SpanInterface TracerInterface ..> TraceInterface @enduml
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-24