Skip to content

Commit c115d08

Browse files
authored
Add a Shutdown() method to *Provider SDK (#1074)
* Add a Shutdown() method to `*Provider` * Add more precise description * Update description of shutting down a provider * Update CHANGELOG & spec-compliance-matrix * Remove Shutdown function from API
1 parent f6d36c7 commit c115d08

File tree

5 files changed

+46
-4
lines changed

5 files changed

+46
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ New:
4747
([#994](https://github.com/open-telemetry/opentelemetry-specification/pull/994))
4848
- Add Metric SDK specification (partial): covering terminology and Accumulator component
4949
([#626](https://github.com/open-telemetry/opentelemetry-specification/pull/626))
50+
- Add `Shutdown` function to `*Provider` SDK ([#1074](https://github.com/open-telemetry/opentelemetry-specification/pull/1074))
5051

5152
Updates:
5253

spec-compliance-matrix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ status of the feature is not known.
1515
|Create TracerProvider | + | + | + | + | + | + | + | + | + | + |
1616
|Get a Tracer | + | + | + | + | + | + | + | + | + | + |
1717
|Safe for concurrent calls | + | + | + | [-](https://github.com/open-telemetry/opentelemetry-python/issues/392) | + | + | + | + | + | + |
18+
|Shutdown | | | | | | | | | | |
1819
|[Tracing Context Utilities](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#tracing-context-utilities)|
1920
|Get active Span | | | | + | | | | | | |
2021
|Set active Span | | | | + | | | | | | |

specification/metrics/sdk.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,24 @@ implementing the [`Meter` interface](api.md#meter-interface), and
154154
managing the SDK instrument, the Resource, and Instrumentation Library
155155
metadata.
156156

157+
#### MeterProvider
158+
159+
##### Shutdown
160+
161+
This method provides a way for provider to do any cleanup required.
162+
163+
`Shutdown` MUST be called only once for each `MeterProvider` instance. After
164+
the call to `Shutdown`, subsequent attempts to get a `Meter` are not allowed. SDKs
165+
SHOULD return a valid no-op Meter for these calls, if possible.
166+
167+
`Shutdown` SHOULD provide a way to let the caller know whether it succeeded,
168+
failed or timed out.
169+
170+
`Shutdown` SHOULD complete or abort within some timeout. `Shutdown` can be
171+
implemented as a blocking API or an asynchronous API which notifies the caller
172+
via a callback or an event. Language library authors can decide if they want to
173+
make the shutdown timeout configurable.
174+
157175
#### SDK: Instrument Registration
158176

159177
The OpenTelemetry SDK is responsible for ensuring that an individual

specification/trace/api.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ number of `TracerProvider` instances.
9191

9292
### TracerProvider operations
9393

94-
The `TracerProvider` MUST provide functions to:
94+
The `TracerProvider` MUST provide the following functions:
9595

9696
- Get a `Tracer`
9797

98-
That API MUST accept the following parameters:
98+
#### Get a Tracer
99+
100+
This API MUST accept the following parameters:
99101

100102
- `name` (required): This name must identify the [instrumentation library](../overview.md#instrumentation-libraries)
101103
(e.g. `io.opentelemetry.contrib.mongodb`) and *not* the instrumented library.

specification/trace/sdk.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<summary>Table of Contents</summary>
66

77
* [Sampling](#sampling)
8-
* [Tracer Creation](#tracer-creation)
8+
* [Tracer Provider](#tracer-provider)
99
* [Additional Span Interfaces](#additional-span-interfaces)
1010
* [Span Processor](#span-processor)
1111
* [Span Exporter](#span-exporter)
@@ -180,7 +180,9 @@ Optional parameters:
180180
|present|false|true|`localParentSampled()`|
181181
|present|false|false|`localParentNotSampled()`|
182182

183-
## Tracer Creation
183+
## Tracer Provider
184+
185+
### Tracer Creation
184186

185187
New `Tracer` instances are always created through a `TracerProvider` (see
186188
[API](api.md#tracerprovider)). The `name` and `version` arguments
@@ -201,6 +203,24 @@ Note: Implementation-wise, this could mean that `Tracer` instances have a
201203
reference to their `TracerProvider` and access configuration only via this
202204
reference.
203205

206+
### Shutdown
207+
208+
This method provides a way for provider to do any cleanup required.
209+
210+
`Shutdown` MUST be called only once for each `TracerProvider` instance. After
211+
the call to `Shutdown`, subsequent attempts to get a `Tracer` are not allowed. SDKs
212+
SHOULD return a valid no-op Tracer for these calls, if possible.
213+
214+
`Shutdown` SHOULD provide a way to let the caller know whether it succeeded,
215+
failed or timed out.
216+
217+
`Shutdown` SHOULD complete or abort within some timeout. `Shutdown` can be
218+
implemented as a blocking API or an asynchronous API which notifies the caller
219+
via a callback or an event. Language library authors can decide if they want to
220+
make the shutdown timeout configurable.
221+
222+
`Shutdown` MUST be implemented at least by invoking `Shutdown` within all internal processors.
223+
204224
## Additional Span Interfaces
205225

206226
The [API-level definition for Span's interface](api.md#span-operations)

0 commit comments

Comments
 (0)