1// Copyright The OpenTelemetry Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package trace // import "go.opentelemetry.io/otel/trace"
5
6import (
7 "context"
8
9 "go.opentelemetry.io/otel/trace/embedded"
10)
11
12// Tracer is the creator of Spans.
13//
14// Warning: Methods may be added to this interface in minor releases. See
15// package documentation on API implementation for information on how to set
16// default behavior for unimplemented methods.
17type Tracer interface {
18 // Users of the interface can ignore this. This embedded type is only used
19 // by implementations of this interface. See the "API Implementations"
20 // section of the package documentation for more information.
21 embedded.Tracer
22
23 // Start creates a span and a context.Context containing the newly-created span.
24 //
25 // If the context.Context provided in `ctx` contains a Span then the newly-created
26 // Span will be a child of that span, otherwise it will be a root span. This behavior
27 // can be overridden by providing `WithNewRoot()` as a SpanOption, causing the
28 // newly-created Span to be a root span even if `ctx` contains a Span.
29 //
30 // When creating a Span it is recommended to provide all known span attributes using
31 // the `WithAttributes()` SpanOption as samplers will only have access to the
32 // attributes provided when a Span is created.
33 //
34 // Any Span that is created MUST also be ended. This is the responsibility of the user.
35 // Implementations of this API may leak memory or other resources if Spans are not ended.
36 Start(ctx context.Context, spanName string, opts ...SpanStartOption) (context.Context, Span)
37}