File: SpanInterface.php

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (95 lines) | stat: -rw-r--r-- 2,871 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace Wikimedia\Telemetry;

/**
 * Represents an OpenTelemetry span, i.e. a single operation within a trace.
 *
 * @since 1.43
 * @see https://opentelemetry.io/docs/specs/otel/trace/api/#span
 */
interface SpanInterface {
	/**
	 * Default value. Indicates that the span represents an internal operation within an application,
	 * as opposed to an operations with remote parents or children.
	 */
	public const SPAN_KIND_INTERNAL = 1;

	/**
	 * Indicates that the span covers server-side handling of a synchronous RPC or other remote request.
	 */
	public const SPAN_KIND_SERVER = 2;

	/**
	 * Indicates that the span describes a request to some remote service.
	 */
	public const SPAN_KIND_CLIENT = 3;

	/**
	 * Indicates that the span describes the initiators of an asynchronous request.
	 */
	public const SPAN_KIND_PRODUCER = 4;

	/**
	 * Indicates that the span describes a child of an asynchronous
	 * {@link SpanInterface::SPAN_KIND_PRODUCER} request.
	 */
	public const SPAN_KIND_CONSUMER = 5;

	/**
	 * Get the context holding data for this span.
	 * @return SpanContext
	 */
	public function getContext(): SpanContext;

	/**
	 * Set attributes (arbitrary metadata) for this span.
	 *
	 * When deciding on the set of attributes to register as well as their naming, consider following
	 * <a href="https://opentelemetry.io/docs/specs/semconv/general/trace/">Semantic Conventions</a> where
	 * applicable.
	 *
	 * @param array $attributes key-value mapping of attribute names to values
	 * @return SpanInterface fluent interface
	 */
	public function setAttributes( array $attributes ): SpanInterface;

	/**
	 * Set the kind of this span, which describes how it relates to its parent and children
	 * within the overarching trace.
	 *
	 * @param int $spanKind One of the SpanInterface::SPAN_KIND_** constants
	 * @see https://opentelemetry.io/docs/specs/otel/trace/api/#spankind
	 * @return SpanInterface fluent interface
	 */
	public function setSpanKind( int $spanKind ): SpanInterface;

	/**
	 * Start this span, optionally specifying an override for its start time.
	 * @param int|null $epochNanos The start time to use, or `null` to use the current time.
	 * @return SpanInterface
	 */
	public function start( ?int $epochNanos = null ): SpanInterface;

	/**
	 * End this span, optionally specifying an override for its end time.
	 * @param int|null $epochNanos The end time to use, or `null` to use the current time.
	 * @return void
	 */
	public function end( ?int $epochNanos = null ): void;

	/**
	 * Make this span the active span.
	 *
	 * This will cause any spans started without specifying an explicit parent to automatically
	 * become children of this span as long as it remains active.
	 *
	 * @return void
	 */
	public function activate(): void;

	/**
	 * Deactivate this span.
	 * @return void
	 */
	public function deactivate(): void;
}