Skip to content

Commit 18358d7

Browse files
ZieglerWolfgangSergeyKanzhelev
authored andcommitted
Named Tracers and Meters (open-telemetry#264)
* Extended spec with "Named Tracers/Meters" concept. * Implement feedback about wording. * Restore the "runtimes with multiple deployments paragraph" * Update documentation about the "name" argument in Tracer/Meter creation. * Implement PR feedback
1 parent e5c1a22 commit 18358d7

4 files changed

Lines changed: 54 additions & 17 deletions

File tree

specification/api-metrics.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,22 @@ aggregation](overview.md#recording-metrics-with-predefined-aggregation).
3737

3838
### Meter creation
3939

40-
TODO: follow the spec for the Tracer. See work in progress:
41-
https://github.com/open-telemetry/opentelemetry-specification/issues/39
40+
New `Meter` instances can be created via a `MeterFactory` and its `getMeter`
41+
method. This method expects two string arguments:
42+
43+
- `name` (required): This name must identify the instrumentation library (also
44+
referred to as integration, e.g. `io.opentelemetry.contrib.mongodb`) and *not*
45+
the instrumented library.
46+
In case an invalid name (null or empty string) is specified, a working
47+
default Meter implementation as a fallback is returned rather than returning
48+
null or throwing an exception.
49+
A library, implementing the OpenTelemetry API *may* also ignore this name and
50+
return a default instance for all calls, if it does not support "named"
51+
functionality (e.g. an implementation which is not even observability-related).
52+
A MeterFactory could also return a no-op Meter here if application owners configure
53+
the SDK to suppress telemetry produced by this library.
54+
- `version` (optional): Specifies the version of the instrumentation library
55+
(e.g. `semver:1.0.0`).
4256

4357
### Create Metric
4458

specification/api-tracing.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,27 +81,40 @@ Some applications may require multiple `Tracer` instances, e.g. to create
8181
`Span`s on behalf of other applications. Implementations MAY provide a global
8282
registry of `Tracer`s for such applications.
8383

84-
### Obtaining a tracer
85-
86-
`Tracer` object construction and registration will vary by implementation.
87-
`Tracer`s may be explicitly created and registered from user code, or resolved
88-
from linked dependencies using the provider pattern.
84+
### Obtaining a Tracer
85+
86+
New `Tracer` instances can be created via a `TracerFactory` and its `getTracer`
87+
method. This method expects two string arguments:
88+
89+
- `name` (required): This name must identify the instrumentation library (also
90+
referred to as integration, e.g. `io.opentelemetry.contrib.mongodb`) and *not*
91+
the instrumented library.
92+
In case an invalid name (null or empty string) is specified, a working
93+
default Tracer implementation as a fallback is returned rather than returning
94+
null or throwing an exception.
95+
A library, implementing the OpenTelemetry API *may* also ignore this name and
96+
return a default instance for all calls, if it does not support "named"
97+
functionality (e.g. an implementation which is not even observability-related).
98+
A TracerFactory could also return a no-op Tracer here if application owners configure
99+
the SDK to suppress telemetry produced by this library.
100+
- `version` (optional): Specifies the version of the instrumentation library
101+
(e.g. `semver:1.0.0`).
89102

90103
Implementations might require the user to specify configuration properties at
91-
`Tracer` creation time, or rely on external configuration, e.g. when using the
104+
`TracerFactory` creation time, or rely on external configuration, e.g. when using the
92105
provider pattern.
93106

94107
##### Runtimes with multiple deployments/applications
95108

96109
Runtimes that support multiple deployments or applications might need to
97-
provide a different `Tracer` instance to each deployment. To support this,
98-
99-
the global `Tracer` registry may delegate calls to create new `Tracer`s to a
100-
separate `Provider` component, and the runtime may include its own `Provider`
101-
implementation which returns a different `Tracer` for each deployment.
102-
103-
`Provider`s are registered with the API via some language-specific mechanism,
104-
for instance the `ServiceLoader` class in Java.
110+
provide a different `TracerFactory` instance to each deployment. To support this,
111+
the global `TracerFactory` registry may delegate calls to create new instances of
112+
`TracerFactory` to a separate `Provider` component, and the runtime may include
113+
its own `Provider` implementation which returns a different `TracerFactory` for
114+
each deployment.
115+
116+
`Provider` instances are registered with the API via some language-specific
117+
mechanism, for instance the `ServiceLoader` class in Java.
105118

106119
### Tracer operations
107120

specification/data-semantic-conventions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Depending on the protocol and the type of operation, additional information
1111
is needed to represent and analyze a span correctly in monitoring systems. It is
1212
also important to unify how this attribution is made in different languages.
1313
This way, the operator will not need to learn specifics of a language and
14-
telemetry collected from multi-language micro-services can still be easily
14+
telemetry collected from multi-language micro-service can still be easily
1515
correlated and cross-analyzed.
1616

1717
## HTTP client

specification/sdk-tracing.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22

33
<details><summary>Table of Contents</summary>
44

5+
* [Tracer Creation](#tracer-creation)
56
* [Span Processor](#span-processor)
67
* [Span Exporter](#span-exporter)
78

89
</details>
910

11+
# Tracer Creation
12+
13+
New `Tracer` instances are always created through a `TracerFactory` (see [API](api-tracing.md#obtaining-a-tracer)).
14+
The `name` and `version` arguments supplied to the `TracerFactory` must be used
15+
to create a `Resource` instance which is stored on the created `Tracer`.
16+
The readable representations of all `Span` instances created by a `Tracer` must
17+
provide a `getLibraryResource` method that returns this `Resource` information
18+
held by the `Tracer`.
19+
1020
## Span processor
1121

1222
Span processor is an interface which allows hooks for span start and end method

0 commit comments

Comments
 (0)