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"
|
|
|
|
|
|
|
|
"google.golang.org/grpc/codes"
|
2019-08-27 01:41:15 +09:00
|
|
|
|
2020-05-14 07:06:03 +08:00
|
|
|
"go.opentelemetry.io/otel/api/kv"
|
2019-11-01 11:40:29 -07:00
|
|
|
apitrace "go.opentelemetry.io/otel/api/trace"
|
2020-03-13 13:07:36 -07:00
|
|
|
"go.opentelemetry.io/otel/sdk/resource"
|
2019-08-02 13:52:55 -07:00
|
|
|
)
|
|
|
|
|
2019-11-05 13:08:55 -08: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 13:52:55 -07:00
|
|
|
// SpanData contains all the information collected by a span.
|
|
|
|
type SpanData struct {
|
2020-05-02 20:17:11 +08:00
|
|
|
SpanContext apitrace.SpanContext
|
|
|
|
ParentSpanID apitrace.SpanID
|
2019-10-23 20:25:14 -03:00
|
|
|
SpanKind apitrace.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-05-14 07:06:03 +08:00
|
|
|
Attributes []kv.KeyValue
|
2019-09-09 14:59:39 -07:00
|
|
|
MessageEvents []Event
|
2019-09-21 00:26:20 -07:00
|
|
|
Links []apitrace.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
|
2019-08-02 13:52:55 -07:00
|
|
|
}
|
2019-09-09 14:59:39 -07:00
|
|
|
|
|
|
|
// Event is used to describe an Event with a message string and set of
|
|
|
|
// Attributes.
|
|
|
|
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-05-14 07:06:03 +08:00
|
|
|
// Attributes contains a list of kv pairs.
|
|
|
|
Attributes []kv.KeyValue
|
2019-09-09 14:59:39 -07:00
|
|
|
|
|
|
|
// Time is the time at which this event was recorded.
|
|
|
|
Time time.Time
|
|
|
|
}
|