summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/api/Trace/SpanBuilderInterface.php
blob: 52070933adc2ec23ef97dd023062eb18527405bb (plain)
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
<?php

declare(strict_types=1);

namespace OpenTelemetry\API\Trace;

use OpenTelemetry\Context\ContextInterface;

/**
 * Obtained from a {@see TracerInterface} and used to construct a {@see SpanInterface}.
 */
interface SpanBuilderInterface
{
    /**
     * Sets the parent `Context`.
     *
     * @param ContextInterface|false|null $context the parent context, null to use the
     *        current context, false to set no parent
     * @return SpanBuilderInterface this span builder
     *
     * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#span-creation
     */
    public function setParent($context): SpanBuilderInterface;

    public function addLink(SpanContextInterface $context, iterable $attributes = []): SpanBuilderInterface;
    public function setAttribute(string $key, $value): SpanBuilderInterface;
    public function setAttributes(iterable $attributes): SpanBuilderInterface;

    /**
     * Sets an explicit start timestamp for the newly created {@see SpanInterface}.
     * The provided *$timestamp* is assumed to be in nanoseconds.
     *
     * Defaults to the timestamp when {@see SpanBuilderInterface::startSpan} was called if not explicitly set.
     */
    public function setStartTimestamp(int $timestampNanos): SpanBuilderInterface;

    /**
     * @psalm-param SpanKind::KIND_* $spanKind
     */
    public function setSpanKind(int $spanKind): SpanBuilderInterface;

    /**
     * Starts and returns a new {@see SpanInterface}.
     *
     * The user _MUST_ manually end the span by calling {@see SpanInterface::end}.
     *
     * This method does _NOT_ automatically install the span into the current context.
     * The user is responsible for calling {@see SpanInterface::activate} when they wish to do so.
     */
    public function startSpan(): SpanInterface;
}