In T340552, the official PHP OpenTelemetry client was effectively rejected for inclusion in MediaWiki due to its size. Implement a minimal tracing library instead that eschews conformance with the OTEL client specification in favor of simplicity, while remaining capable of emitting trace data in OTLP format and thus retaining compatibility with any ingestion endpoint capable of handling OTLP. In its current state, the library supports a basic feature set that should be sufficient for basic tracing integration: * Span creation, inclusive span activation and automatic parent span assignment, * Span attributes and span kinds, * Basic resource (process/request)-level metadata generation, * Data export over OTLP. Additional functionality, such as trace propagation, can then be incrementally added to the library. Bug: T340552 Change-Id: Ibc3910058cd7ed064cad293a3cdc091344e66b86
49 lines
1.8 KiB
PHP
49 lines
1.8 KiB
PHP
<?php
|
|
namespace Wikimedia\Telemetry;
|
|
|
|
use Wikimedia\Assert\PreconditionException;
|
|
|
|
/**
|
|
* Base interface for an OpenTelemetry tracer responsible for creating spans.
|
|
* @since 1.43
|
|
*/
|
|
interface TracerInterface {
|
|
/**
|
|
* Create a span with the given name and the currently active span as the implicit parent.
|
|
* This requires a span to be already active and will throw an error otherwise.
|
|
*
|
|
* @param string $spanName The descriptive name of this span.
|
|
* Refer to the <a href="https://opentelemetry.io/docs/specs/otel/trace/api/#span">OTEL Tracing API
|
|
* spec</a> for recommended naming conventions.
|
|
* @return SpanInterface
|
|
* @throws PreconditionException If no span was active
|
|
*/
|
|
public function createSpan( string $spanName ): SpanInterface;
|
|
|
|
/**
|
|
* Create a new root span, i.e. a span with no parent that forms the basis for a new trace.
|
|
*
|
|
* @param string $spanName The descriptive name of this span.
|
|
* Refer to the <a href="https://opentelemetry.io/docs/specs/otel/trace/api/#span">OTEL Tracing API
|
|
* spec</a> for recommended naming conventions.
|
|
* @return SpanInterface
|
|
*/
|
|
public function createRootSpan( string $spanName ): SpanInterface;
|
|
|
|
/**
|
|
* Create a span with the given name and parent.
|
|
*
|
|
* @param string $spanName The descriptive name of this span.
|
|
* Refer to the <a href="https://opentelemetry.io/docs/specs/otel/trace/api/#span">OTEL Tracing API
|
|
* spec</a> for recommended naming conventions.
|
|
* @param SpanContext $parentSpanContext Context of the parent span this span should be associated with.
|
|
* @return SpanInterface
|
|
*/
|
|
public function createSpanWithParent( string $spanName, SpanContext $parentSpanContext ): SpanInterface;
|
|
|
|
/**
|
|
* Shut down this tracer and export collected trace data.
|
|
* @return void
|
|
*/
|
|
public function shutdown(): void;
|
|
}
|