2020-03-23 22:41:10 -07:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2019-08-02 13:52:55 -07:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2019-11-05 13:08:55 -08:00
|
|
|
package trace // import "go.opentelemetry.io/otel/sdk/export/trace"
|
2019-08-02 13:52:55 -07:00
|
|
|
|
|
|
|
import (
|
2019-11-05 13:08:55 -08:00
|
|
|
"context"
|
2019-08-02 13:52:55 -07:00
|
|
|
"time"
|
|
|
|
|
2020-10-05 11:36:03 -07:00
|
|
|
"go.opentelemetry.io/otel/codes"
|
2020-08-17 20:25:03 -07:00
|
|
|
"go.opentelemetry.io/otel/label"
|
2020-11-06 23:13:31 +01:00
|
|
|
"go.opentelemetry.io/otel/trace"
|
|
|
|
|
2020-06-09 22:15:53 -07:00
|
|
|
"go.opentelemetry.io/otel/sdk/instrumentation"
|
2020-03-13 13:07:36 -07:00
|
|
|
"go.opentelemetry.io/otel/sdk/resource"
|
2019-08-02 13:52:55 -07:00
|
|
|
)
|
|
|
|
|
2020-12-11 06:15:44 +01:00
|
|
|
// SpanExporter handles the delivery of SpanSnapshot structs to external
|
|
|
|
// receivers. This is the final component in the trace export pipeline.
|
2020-09-09 10:19:03 -07:00
|
|
|
type SpanExporter interface {
|
2020-12-11 06:15:44 +01:00
|
|
|
// ExportSpans exports a batch of SpanSnapshots.
|
2020-09-09 10:19:03 -07:00
|
|
|
//
|
|
|
|
// This function is called synchronously, so there is no concurrency
|
|
|
|
// safety requirement. However, due to the synchronous calling pattern,
|
|
|
|
// it is critical that all timeouts and cancellations contained in the
|
|
|
|
// passed context must be honored.
|
|
|
|
//
|
|
|
|
// Any retry logic must be contained in this function. The SDK that
|
|
|
|
// calls this function will not implement any retry logic. All errors
|
|
|
|
// returned by this function are considered unrecoverable and will be
|
|
|
|
// reported to a configured error Handler.
|
2020-12-11 06:15:44 +01:00
|
|
|
ExportSpans(ctx context.Context, ss []*SpanSnapshot) error
|
2020-09-09 10:19:03 -07:00
|
|
|
// Shutdown notifies the exporter of a pending halt to operations. The
|
|
|
|
// exporter is expected to preform any cleanup or synchronization it
|
|
|
|
// requires while honoring all timeouts and cancellations contained in
|
|
|
|
// the passed context.
|
2020-09-16 18:09:45 +02:00
|
|
|
Shutdown(ctx context.Context) error
|
2019-11-05 13:08:55 -08:00
|
|
|
}
|
|
|
|
|
2020-12-11 06:15:44 +01:00
|
|
|
// SpanSnapshot is a snapshot of a span which contains all the information
|
|
|
|
// collected by the span. Its main purpose is exporting completed spans.
|
|
|
|
// Although SpanSnapshot fields can be accessed and potentially modified,
|
|
|
|
// SpanSnapshot should be treated as immutable. Changes to the span from which
|
|
|
|
// the SpanSnapshot was created are NOT reflected in the SpanSnapshot.
|
|
|
|
type SpanSnapshot struct {
|
2020-11-06 23:13:31 +01:00
|
|
|
SpanContext trace.SpanContext
|
|
|
|
ParentSpanID trace.SpanID
|
|
|
|
SpanKind trace.SpanKind
|
2019-08-02 13:52:55 -07:00
|
|
|
Name string
|
|
|
|
StartTime time.Time
|
|
|
|
// The wall clock time of EndTime will be adjusted to always be offset
|
|
|
|
// from StartTime by the duration of the span.
|
2019-10-31 19:52:46 +02:00
|
|
|
EndTime time.Time
|
2020-08-17 20:25:03 -07:00
|
|
|
Attributes []label.KeyValue
|
2019-09-09 14:59:39 -07:00
|
|
|
MessageEvents []Event
|
2020-11-06 23:13:31 +01:00
|
|
|
Links []trace.Link
|
2020-03-07 10:38:59 -08:00
|
|
|
StatusCode codes.Code
|
|
|
|
StatusMessage string
|
2019-08-02 13:52:55 -07:00
|
|
|
HasRemoteParent bool
|
|
|
|
DroppedAttributeCount int
|
|
|
|
DroppedMessageEventCount int
|
|
|
|
DroppedLinkCount int
|
|
|
|
|
|
|
|
// ChildSpanCount holds the number of child span created for this span.
|
|
|
|
ChildSpanCount int
|
2020-03-13 13:07:36 -07:00
|
|
|
|
|
|
|
// Resource contains attributes representing an entity that produced this span.
|
|
|
|
Resource *resource.Resource
|
2020-06-09 22:15:53 -07:00
|
|
|
|
|
|
|
// InstrumentationLibrary defines the instrumentation library used to
|
2020-09-09 10:19:03 -07:00
|
|
|
// provide instrumentation.
|
2020-06-09 22:15:53 -07:00
|
|
|
InstrumentationLibrary instrumentation.Library
|
2019-08-02 13:52:55 -07:00
|
|
|
}
|
2019-09-09 14:59:39 -07:00
|
|
|
|
2020-09-09 10:19:03 -07:00
|
|
|
// Event is thing that happened during a Span's lifetime.
|
2019-09-09 14:59:39 -07:00
|
|
|
type Event struct {
|
2019-12-19 02:13:05 +08:00
|
|
|
// Name is the name of this event
|
|
|
|
Name string
|
2019-09-09 14:59:39 -07:00
|
|
|
|
2020-09-09 10:19:03 -07:00
|
|
|
// Attributes describe the aspects of the event.
|
2020-08-17 20:25:03 -07:00
|
|
|
Attributes []label.KeyValue
|
2019-09-09 14:59:39 -07:00
|
|
|
|
|
|
|
// Time is the time at which this event was recorded.
|
|
|
|
Time time.Time
|
|
|
|
}
|