Skip to content

Commit 592ccbe

Browse files
authored
Change Span specification to focus more on capabilities. (open-telemetry#184)
* Change Span specification to focus more on capabilities. * Update specification/tracing-api.md Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update specification/tracing-api.md Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update specification/tracing-api.md Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update specification/tracing-api.md Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update specification/tracing-api.md Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update specification/tracing-api.md Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update specification/tracing-api.md Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update specification/tracing-api.md Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update specification/tracing-api.md Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update specification/tracing-api.md Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update specification/tracing-api.md Co-Authored-By: Armin Ruech <armin.ruech@gmail.com> * Update specification/tracing-api.md Co-Authored-By: Chris Kleinknecht <libc@google.com> * Update specification/tracing-api.md Co-Authored-By: Chris Kleinknecht <libc@google.com> * Fix comments from review. * Clarify that only one attribute,event,link is recorded.
1 parent 9c23051 commit 592ccbe

File tree

1 file changed

+56
-77
lines changed

1 file changed

+56
-77
lines changed

specification/tracing-api.md

+56-77
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,15 @@ Table of Content
2323
* [Span creation](#span-creation)
2424
* [StartSpan](#startspan)
2525
* [Span operations](#span-operations)
26-
* [GetContext](#getcontext)
26+
* [Get Context](#get-context)
2727
* [IsRecordingEvents](#isrecordingevents)
28-
* [SetAttribute](#setattribute)
29-
* [AddEvent](#addevent)
30-
* [AddLink](#addlink)
31-
* [SetStatus](#setstatus)
28+
* [Set Attributes](#set-attributes)
29+
* [Add Events](#add-events)
30+
* [Add Links](#add-links)
31+
* [Set Status](#set-status)
3232
* [UpdateName](#updatename)
3333
* [End](#end)
3434
* [Span lifetime](#span-lifetime)
35-
* [Link](#link)
36-
* [Link creation](#link-creation)
37-
* [GetContext](#getcontext-1)
38-
* [GetAttributes](#getattributes)
3935
* [Status](#status)
4036
* [StatusCanonicalCode](#statuscanonicalcode)
4137
* [Status creation](#status-creation)
@@ -49,7 +45,7 @@ Table of Content
4945
* [GetKind](#getkind)
5046
* [GetStartTimestamp](#getstarttimestamp)
5147
* [GetEndTimestamp](#getendtimestamp)
52-
* [GetContext](#getcontext-2)
48+
* [GetContext](#getcontext)
5349
* [GetParentSpanId](#getparentspanid)
5450
* [GetResource](#getresource)
5551
* [GetAttributes](#getattributes-1)
@@ -282,14 +278,12 @@ Returns the newly created `Span`.
282278
With the exception of the method to retrieve the `Span`'s `SpanContext` and
283279
recording status, none of the below may be called after the `Span` is finished.
284280

285-
#### GetContext
286-
287-
Retrieve the `Span`s `SpanContext`
281+
#### Get Context
288282

289-
There should be no parameter.
290-
291-
Returns the `SpanContext` for the given `Span`. The returned value may be
292-
used even after the `Span` is finished.
283+
The Span interface MUST provide:
284+
- An API that returns the `SpanContext` for the given `Span`. The returned value
285+
may be used even after the `Span` is finished. The returned value MUST be the
286+
same for the entire Span lifetime. This MAY be called `GetContext`.
293287

294288
#### IsRecordingEvents
295289

@@ -300,63 +294,76 @@ There should be no parameter.
300294
Returns true if this `Span` is active and recording information like events with
301295
the `AddEvent` operation and attributes using `SetAttributes`.
302296

303-
#### SetAttribute
297+
#### Set Attributes
304298

305-
Set the `Span`'s attribute.
299+
A `Span` MUST have the ability to set attributes associated with it.
306300

307-
Required parameters
301+
An `Attribute` is defined by the following properties:
302+
- (Required) The attribute key, which must be a string.
303+
- (Required) The attribute value, which must be either a string, a boolean
304+
value, or a numeric type.
308305

309-
- The attribute key, which must be a string.
310-
- The attribute value, which must be either a string, a boolean value, or a
311-
numeric type.
306+
The Span interface MUST provide:
307+
- An API to set a single `Attribute` where the attribute properties are passed
308+
as arguments. This MAY be called `SetAttribute`. To avoid extra allocations some
309+
implementations may offer a separate API for each of the possible value types.
312310

313311
Note that the OpenTelemetry project documents certain ["standard
314312
attributes"](../semantic-conventions.md) that have prescribed semantic meanings.
315313

316-
#### AddEvent
314+
#### Add Events
317315

318-
Add an `Event` to `Span`.
316+
A `Span` MUST have the ability to add events. Events have a time associated
317+
with the moment when they are added to the `Span`.
319318

320-
Required parameters:
319+
An `Event` is defined by the following properties:
320+
- (Required) Name of the event.
321+
- (Optional) One or more `Attribute`.
321322

322-
- Name of the event.
323+
The `Event` SHOULD be an immutable type.
323324

324-
Optional parameters:
325-
326-
- One or more key:value pairs, where the keys must be strings and the values may
327-
be string, booleans or numeric type.
325+
The Span interface MUST provide:
326+
- An API to record a single `Event` where the `Event` properties are passed as
327+
arguments. This MAY be called `AddEvent`.
328+
- An API to record a single lazily initialized `Event`. This can be implemented
329+
by providing an `Event` interface or a concrete `Event` definition and an
330+
`EventFormatter`. If the language supports overloads then this SHOULD be called
331+
`AddEvent` otherwise `AddLazyEvent` may be considered.
328332

329333
Note that the OpenTelemetry project documents certain ["standard event names and
330334
keys"](../semantic-conventions.md) which have prescribed semantic meanings.
331335

332-
#### AddLink
333-
334-
Adds a link to another `Span` from this `Span`. Linked `Span` can be from the
335-
same or different trace. See [Links description](../terminology.md#links-between-spans).
336+
#### Add Links
336337

337-
Required parameters
338+
A `Span` MUST have the ability to record links to other `Span`s. Linked `Span`s
339+
can be from the same or a different trace. See [Links
340+
description](../terminology.md#links-between-spans).
338341

339-
- `SpanContext` of the `Span` to link to
342+
A `Link` is defined by the following properties:
343+
- (Required) `SpanContext` of the `Span` to link to.
344+
- (Optional) One or more `Attribute`.
340345

341-
Optional parameters
346+
The `Link` SHOULD be an immutable type.
342347

343-
- Map of attributes associated with this link. Attributes are key:value pairs
344-
where hey is a string and value is one of string, boolean and numeric.
348+
The Span interface MUST provide:
349+
- An API to record a single `Link` where the `Link` properties are passed as
350+
arguments. This MAY be called `AddLink`.
351+
- An API to record a single lazily initialized `Link`. This can be implemented
352+
by providing a `Link` interface or a concrete `Link` definition and a
353+
`LinkFormatter`. If the language supports overloads then this MAY be called
354+
`AddLink` otherwise `AddLazyLink` MAY be consider.
345355

346-
API MUST also provide an overload that accepts a [`Link` interface](#link). This
347-
overload allows instrumentation to supply a lazily calculated `Link`.
356+
#### Set Status
348357

349-
#### SetStatus
350-
351-
Sets the `Status` to the `Span`. If used, this will override the default `Span`
352-
status. Default is `OK`.
358+
Sets the [`Status`](#status) of the `Span`. If used, this will override the
359+
default `Span` status, which is `OK`.
353360

354361
Only the value of the last call will be recorded, and implementations are free
355362
to ignore previous calls.
356363

357-
Required parameters
358-
359-
- New status for the span.
364+
The Span interface MUST provide:
365+
- An API to set the `Status` where the new status is the only argument. This
366+
SHOULD be called `SetStatus`.
360367

361368
#### UpdateName
362369

@@ -394,34 +401,6 @@ Start and end time as well as Event's timestamps MUST be recorded at a time of a
394401
calling of corresponding API and MUST not be passed as an argument. In order to
395402
record already completed span - [`SpanData`](#spandata) API HAVE TO be used.
396403

397-
## Link
398-
399-
`Link` interface represents the [link between
400-
spans](../terminology.md#links-between-spans). Interface only expose two
401-
getters. API also MUST provide a way to create a Link.
402-
403-
### Link creation
404-
405-
API MUST provide a way to create a new `Link`.
406-
407-
Required parameters
408-
409-
- `SpanContext` of the `Span` to link to
410-
411-
Optional parameters
412-
413-
- Map of attributes associated with this link. Attributes are key:value pairs
414-
where key is a string and value is one of string, boolean and numeric.
415-
416-
### GetContext
417-
418-
Returns the `SpanContext` of a linked span.
419-
420-
### GetAttributes
421-
422-
Returns the immutable collection of attributes associated with this `Link`.
423-
Order of attributes is not significant.
424-
425404
## Status
426405

427406
`Status` interface represents the status of a finished `Span`. It's composed of

0 commit comments

Comments
 (0)