@@ -4,7 +4,7 @@ linkTitle: API
4
4
5
5
# Tracing API
6
6
7
- ** Status** : [ Stable, Feature-freeze] ( ../document-status.md )
7
+ ** Status** : [ Stable, Feature-freeze] ( ../document-status.md ) , except where otherwise specified
8
8
9
9
<details >
10
10
<summary >Table of Contents</summary >
@@ -35,13 +35,15 @@ linkTitle: API
35
35
+ [ IsRecording] ( #isrecording )
36
36
+ [ Set Attributes] ( #set-attributes )
37
37
+ [ Add Events] ( #add-events )
38
+ + [ Add Link] ( #add-link )
38
39
+ [ Set Status] ( #set-status )
39
40
+ [ UpdateName] ( #updatename )
40
41
+ [ End] ( #end )
41
42
+ [ Record Exception] ( #record-exception )
42
43
* [ Span lifetime] ( #span-lifetime )
43
44
* [ Wrapping a SpanContext in a Span] ( #wrapping-a-spancontext-in-a-span )
44
45
- [ SpanKind] ( #spankind )
46
+ - [ Link] ( #link )
45
47
- [ Concurrency] ( #concurrency )
46
48
- [ Included Propagators] ( #included-propagators )
47
49
- [ Behavior of the API in the absence of an installed SDK] ( #behavior-of-the-api-in-the-absence-of-an-installed-sdk )
@@ -300,7 +302,7 @@ the entire operation and, optionally, one or more sub-spans for its sub-operatio
300
302
- A start timestamp
301
303
- An end timestamp
302
304
- [ ` Attributes ` ] ( ../common/README.md#attribute )
303
- - A list of [ ` Link ` s] ( #specifying-links ) to other ` Span ` s
305
+ - A list of [ ` Link ` s] ( #link ) to other ` Span ` s
304
306
- A list of timestamped [ ` Event ` s] ( #add-events )
305
307
- A [ ` Status ` ] ( #set-status ) .
306
308
@@ -386,7 +388,7 @@ The API MUST accept the following parameters:
386
388
to calling ` SetAttribute ` later, as samplers can only consider information
387
389
already present during span creation.
388
390
389
- - ` Link ` s - an ordered sequence of Links, see API definition [ here ] ( #specifying-links ) .
391
+ - ` Link ` s - an ordered sequence of Links, see [ API definition] ( #link ) .
390
392
- ` Start timestamp ` , default to current time. This argument SHOULD only be set
391
393
when span creation time has already passed. If API is called at a moment of
392
394
a Span logical start, API user MUST NOT explicitly set this argument.
@@ -423,27 +425,10 @@ For example, a `Propagator` performing context extraction may need this.
423
425
424
426
#### Specifying links
425
427
426
- During ` Span ` creation, a user MUST have the ability to record links to other
427
- ` Span ` s. Linked ` Span ` s can be from the same or a different trace -- see [ Links
428
- between spans] ( ../overview.md#links-between-spans ) . ` Link ` s cannot be added after
429
- Span creation.
430
-
431
- A ` Link ` is structurally defined by the following properties:
432
-
433
- - ` SpanContext ` of the ` Span ` to link to.
434
- - Zero or more [ ` Attributes ` ] ( ../common/README.md#attribute ) further describing
435
- the link.
436
-
437
- The Span creation API MUST provide:
438
-
439
- - An API to record a single ` Link ` where the ` Link ` properties are passed as
440
- arguments. This MAY be called ` AddLink ` . This API takes the ` SpanContext ` of
441
- the ` Span ` to link to and optional ` Attributes ` , either as individual
442
- parameters or as an immutable object encapsulating them, whichever is most
443
- appropriate for the language. Implementations MAY ignore links with an
444
- [ invalid] ( #isvalid ) ` SpanContext ` .
445
-
446
- Links SHOULD preserve the order in which they're set.
428
+ During ` Span ` creation, a user MUST have the ability to record links to other ` Span ` s.
429
+ Linked ` Span ` s can be from the same or a different trace -- see [ links] ( #link ) .
430
+ ` Link ` s added at ` Span ` creation may be considered by [ Samplers] ( sdk.md#sampler )
431
+ to make a sampling decision.
447
432
448
433
### Span operations
449
434
@@ -556,6 +541,13 @@ keys"](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/REA
556
541
Note that [ ` RecordException ` ] ( #record-exception ) is a specialized variant of
557
542
` AddEvent ` for recording exception events.
558
543
544
+ #### Add Link
545
+
546
+ ** Status** : [ Experimental] ( ../document-status.md )
547
+
548
+ A ` Span ` MUST have the ability to add ` Link ` s associated with it after its creation - see [ Links] ( #link ) .
549
+ ` Link ` s added after ` Span ` creation may not be considered by [ Samplers] ( sdk.md#sampler ) .
550
+
559
551
#### Set Status
560
552
561
553
Sets the ` Status ` of the ` Span ` . If used, this will override the default ` Span `
@@ -797,6 +789,38 @@ To summarize the interpretation of these kinds:
797
789
| ` CONSUMER ` | | yes | maybe | |
798
790
| ` INTERNAL ` | | | | |
799
791
792
+ ## Link
793
+
794
+ A user MUST have the ability to record links to other ` SpanContext ` s.
795
+ Linked ` SpanContext ` s can be from the same or a different trace -- see [ Links
796
+ between spans] ( ../overview.md#links-between-spans ) .
797
+
798
+ A ` Link ` is structurally defined by the following properties:
799
+
800
+ - ` SpanContext ` of the ` Span ` to link to.
801
+ - Zero or more [ ` Attributes ` ] ( ../common/README.md#attribute ) further describing
802
+ the link.
803
+
804
+ The API MUST provide:
805
+
806
+ - An API to record a single ` Link ` where the ` Link ` properties are passed as
807
+ arguments. This MAY be called ` AddLink ` . This API takes the ` SpanContext ` of
808
+ the ` Span ` to link to and optional ` Attributes ` , either as individual
809
+ parameters or as an immutable object encapsulating them, whichever is most
810
+ appropriate for the language. Implementations MAY ignore links with an
811
+ [ invalid] ( #isvalid ) ` SpanContext ` .
812
+
813
+ The Span interface MAY provide:
814
+
815
+ - An API to add multiple ` Link ` s at once, where the ` Link ` s are passed in a
816
+ single method call.
817
+
818
+ Span SHOULD preserve the order in which ` Link ` s are set.
819
+
820
+ The API documentation MUST state that adding links at span creation is preferred
821
+ to calling ` AddLink ` later, for contexts that are available during span creation,
822
+ because head sampling decisions can only consider information present during span creation.
823
+
800
824
## Concurrency
801
825
802
826
For languages which support concurrent execution the Tracing APIs provide
0 commit comments