Copyright The OpenTelemetry Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

package trace

import (
	
	

	
	
)

Tracer creates an implementation of the Tracer interface. The instrumentationName must be the name of the library providing instrumentation. This name may be the same as the instrumented code only if that code provides built-in instrumentation. If the instrumentationName is empty, then a implementation defined default name will be used instead.
	Tracer(instrumentationName string, opts ...TracerOption) Tracer
}
TODO (MrAlias): unify this API option design: https://github.com/open-telemetry/opentelemetry-go/issues/536
TracerConfig contains options for a Tracer.
TracerOption configures a TracerConfig option.
WithInstrumentationVersion sets the instrumentation version for a Tracer.
func ( string) TracerOption {
	return func( *TracerConfig) {
		.InstrumentationVersion = 
	}
}

Start a span.
	Start(ctx context.Context, spanName string, opts ...StartOption) (context.Context, Span)
}
EndConfig provides options to set properties of span at the time of ending the span.
type EndConfig struct {
	EndTime time.Time
}
EndOption applies changes to EndConfig that sets options when the span is ended.
type EndOption func(*EndConfig)
WithEndTime sets the end time of the span to provided time t, when it is ended.
func ( time.Time) EndOption {
	return func( *EndConfig) {
		.EndTime = 
	}
}
ErrorConfig provides options to set properties of an error event at the time it is recorded.
ErrorOption applies changes to ErrorConfig that sets options when an error event is recorded.
WithErrorTime sets the time at which the error event should be recorded.
func ( time.Time) ErrorOption {
	return func( *ErrorConfig) {
		.Timestamp = 
	}
}
WithErrorStatus indicates the span status that should be set when recording an error event.
func ( codes.Code) ErrorOption {
	return func( *ErrorConfig) {
		.StatusCode = 
	}
}

Tracer returns tracer used to create this span. Tracer cannot be nil.
	Tracer() Tracer
End completes the span. No updates are allowed to span after it ends. The only exception is setting status of the span.
	End(options ...EndOption)
AddEvent adds an event to the span.
AddEventWithTimestamp adds an event with a custom timestamp to the span.
	AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...label.KeyValue)
IsRecording returns true if the span is active and recording events is enabled.
	IsRecording() bool
RecordError records an error as a span event.
	RecordError(ctx context.Context, err error, opts ...ErrorOption)
SpanContext returns span context of the span. Returned SpanContext is usable even after the span ends.
	SpanContext() SpanContext
SetStatus sets the status of the span in the form of a code and a message. SetStatus overrides the value of previous calls to SetStatus on the Span. The default span status is OK, so it is not necessary to explicitly set an OK status on successful Spans unless it is to add an OK message or to override a previous status on the Span.
	SetStatus(codes.Code, string)
SetName sets the name of the span.
	SetName(name string)
Set span attributes
	SetAttributes(...label.KeyValue)
Set singular span attribute, with type inference.
	SetAttribute(string, interface{})
}
StartOption applies changes to StartConfig that sets options at span start time.
StartConfig provides options to set properties of span at the time of starting a new span.
Link is used to establish relationship between two spans within the same Trace or across different Traces. Few examples of Link usage. 1. Batch Processing: A batch of elements may contain elements associated with one or more traces/spans. Since there can only be one parent SpanContext, Link is used to keep reference to SpanContext of all elements in the batch. 2. Public Endpoint: A SpanContext in incoming client request on a public endpoint is untrusted from service provider perspective. In such case it is advisable to start a new trace with appropriate sampling decision. However, it is desirable to associate incoming SpanContext to new trace initiated on service provider side so two traces (from Client and from Service Provider) can be correlated.
SpanKind represents the role of a Span inside a Trace. Often, this defines how a Span will be processed and visualized by various backends.
As a convenience, these match the proto definition, see opentelemetry/proto/trace/v1/trace.proto The unspecified value is not a valid `SpanKind`. Use `ValidateSpanKind()` to coerce a span kind to a valid value.
ValidateSpanKind returns a valid span kind value. This will coerce invalid values into the default value, SpanKindInternal.
valid
		return 
	default:
		return SpanKindInternal
	}
}
String returns the specified name of the SpanKind in lower-case.
func ( SpanKind) () string {
	switch  {
	case SpanKindInternal:
		return "internal"
	case SpanKindServer:
		return "server"
	case SpanKindClient:
		return "client"
	case SpanKindProducer:
		return "producer"
	case SpanKindConsumer:
		return "consumer"
	default:
		return "unspecified"
	}
}
WithStartTime sets the start time of the span to provided time t, when it is started. In absence of this option, wall clock time is used as start time. This option is typically used when starting of the span is delayed.
func ( time.Time) StartOption {
	return func( *StartConfig) {
		.StartTime = 
	}
}
WithAttributes sets attributes to span. These attributes provides additional data about the span. Multiple `WithAttributes` options appends the attributes preserving the order.
func ( ...label.KeyValue) StartOption {
	return func( *StartConfig) {
		.Attributes = append(.Attributes, ...)
	}
}
WithRecord specifies that the span should be recorded. Note that the implementation may still override this preference, e.g., if the span is a child in an unsampled trace.
func () StartOption {
	return func( *StartConfig) {
		.Record = true
	}
}
WithNewRoot specifies that the current span or remote span context in context passed to `Start` should be ignored when deciding about a parent, which effectively means creating a span with new trace ID. The current span and the remote span context may be added as links to the span by the implementation.
func () StartOption {
	return func( *StartConfig) {
		.NewRoot = true
	}
}
LinkedTo allows instantiating a Span with initial Links.
func ( SpanContext,  ...label.KeyValue) StartOption {
	return func( *StartConfig) {
		.Links = append(.Links, Link{, })
	}
}
WithSpanKind specifies the role a Span on a Trace.
func ( SpanKind) StartOption {
	return func( *StartConfig) {
		.SpanKind = 
	}