Debian Codegraph @

includes/libs/telemetry/SpanInterface.php

raw symbols SCIP
1 <?php
2 namespace Wikimedia\Telemetry;
3
4 /**
5 * Represents an OpenTelemetry span, i.e. a single operation within a trace.
6 *
7 * @since 1.43
8 * @see https://opentelemetry.io/docs/specs/otel/trace/api/#span
9 */
10 interface SpanInterface {
11 /**
12 * Default value. Indicates that the span represents an internal operation within an application,
13 * as opposed to an operations with remote parents or children.
14 */
15 public const SPAN_KIND_INTERNAL = 1;
16
17 /**
18 * Indicates that the span covers server-side handling of a synchronous RPC or other remote request.
19 */
20 public const SPAN_KIND_SERVER = 2;
21
22 /**
23 * Indicates that the span describes a request to some remote service.
24 */
25 public const SPAN_KIND_CLIENT = 3;
26
27 /**
28 * Indicates that the span describes the initiators of an asynchronous request.
29 */
30 public const SPAN_KIND_PRODUCER = 4;
31
32 /**
33 * Indicates that the span describes a child of an asynchronous
34 * {@link SpanInterface::SPAN_KIND_PRODUCER} request.
35 */
36 public const SPAN_KIND_CONSUMER = 5;
37
38 /**
39 * Get the context holding data for this span.
40 * @return SpanContext
41 */
42 public function getContext(): SpanContext;
43
44 /**
45 * Set attributes (arbitrary metadata) for this span.
46 *
47 * When deciding on the set of attributes to register as well as their naming, consider following
48 * <a href="https://opentelemetry.io/docs/specs/semconv/general/trace/">Semantic Conventions</a> where
49 * applicable.
50 *
51 * @param array $attributes key-value mapping of attribute names to values
52 * @return SpanInterface fluent interface
53 */
54 public function setAttributes( array $attributes ): SpanInterface;
55
56 /**
57 * Set the kind of this span, which describes how it relates to its parent and children
58 * within the overarching trace.
59 *
60 * @param int $spanKind One of the SpanInterface::SPAN_KIND_** constants
61 * @see https://opentelemetry.io/docs/specs/otel/trace/api/#spankind
62 * @return SpanInterface fluent interface
63 */
64 public function setSpanKind( int $spanKind ): SpanInterface;
65
66 /**
67 * Start this span, optionally specifying an override for its start time.
68 * @param int|null $epochNanos The start time to use, or `null` to use the current time.
69 * @return SpanInterface
70 */
71 public function start( ?int $epochNanos = null ): SpanInterface;
72
73 /**
74 * End this span, optionally specifying an override for its end time.
75 * @param int|null $epochNanos The end time to use, or `null` to use the current time.
76 * @return void
77 */
78 public function end( ?int $epochNanos = null ): void;
79
80 /**
81 * Make this span the active span.
82 *
83 * This will cause any spans started without specifying an explicit parent to automatically
84 * become children of this span as long as it remains active.
85 *
86 * @return void
87 */
88 public function activate(): void;
89
90 /**
91 * Deactivate this span.
92 * @return void
93 */
94 public function deactivate(): void;
95 }