2020-03-24 07:41:10 +02:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2019-08-02 22:52:55 +02: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 23:08:55 +02:00
|
|
|
package trace // import "go.opentelemetry.io/otel/sdk/export/trace"
|
2019-08-02 22:52:55 +02:00
|
|
|
|
|
|
|
import (
|
2019-11-05 23:08:55 +02:00
|
|
|
"context"
|
2019-08-02 22:52:55 +02:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"google.golang.org/grpc/codes"
|
2019-08-26 18:41:15 +02:00
|
|
|
|
2019-11-01 20:40:29 +02:00
|
|
|
"go.opentelemetry.io/otel/api/core"
|
|
|
|
apitrace "go.opentelemetry.io/otel/api/trace"
|
2020-03-13 22:07:36 +02:00
|
|
|
"go.opentelemetry.io/otel/sdk/resource"
|
2019-08-02 22:52:55 +02:00
|
|
|
)
|
|
|
|
|
2019-11-05 23:08:55 +02:00
|
|
|
// SpanSyncer is a type for functions that receive a single sampled trace span.
|
|
|
|
//
|
|
|
|
// The ExportSpan method is called synchronously. Therefore, it should not take
|
|
|
|
// forever to process the span.
|
|
|
|
//
|
|
|
|
// The SpanData should not be modified.
|
|
|
|
type SpanSyncer interface {
|
|
|
|
ExportSpan(context.Context, *SpanData)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SpanBatcher is a type for functions that receive batched of sampled trace
|
|
|
|
// spans.
|
|
|
|
//
|
|
|
|
// The ExportSpans method is called asynchronously. However its should not take
|
|
|
|
// forever to process the spans.
|
|
|
|
//
|
|
|
|
// The SpanData should not be modified.
|
|
|
|
type SpanBatcher interface {
|
|
|
|
ExportSpans(context.Context, []*SpanData)
|
|
|
|
}
|
|
|
|
|
2019-08-02 22:52:55 +02:00
|
|
|
// SpanData contains all the information collected by a span.
|
|
|
|
type SpanData struct {
|
|
|
|
SpanContext core.SpanContext
|
2019-10-28 19:05:06 +02:00
|
|
|
ParentSpanID core.SpanID
|
2019-10-24 01:25:14 +02:00
|
|
|
SpanKind apitrace.SpanKind
|
2019-08-02 22:52:55 +02: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
|
2019-09-25 22:22:33 +02:00
|
|
|
Attributes []core.KeyValue
|
2019-09-09 23:59:39 +02:00
|
|
|
MessageEvents []Event
|
2019-09-21 09:26:20 +02:00
|
|
|
Links []apitrace.Link
|
2020-03-07 20:38:59 +02:00
|
|
|
StatusCode codes.Code
|
|
|
|
StatusMessage string
|
2019-08-02 22:52:55 +02: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 22:07:36 +02:00
|
|
|
|
|
|
|
// Resource contains attributes representing an entity that produced this span.
|
|
|
|
Resource *resource.Resource
|
2019-08-02 22:52:55 +02:00
|
|
|
}
|
2019-09-09 23:59:39 +02:00
|
|
|
|
|
|
|
// Event is used to describe an Event with a message string and set of
|
|
|
|
// Attributes.
|
|
|
|
type Event struct {
|
2019-12-18 20:13:05 +02:00
|
|
|
// Name is the name of this event
|
|
|
|
Name string
|
2019-09-09 23:59:39 +02:00
|
|
|
|
|
|
|
// Attributes contains a list of keyvalue pairs.
|
|
|
|
Attributes []core.KeyValue
|
|
|
|
|
|
|
|
// Time is the time at which this event was recorded.
|
|
|
|
Time time.Time
|
|
|
|
}
|