mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-02 08:52:21 +02:00
update type style (#29)
This commit is contained in:
parent
f5ec719fbd
commit
36f51385ff
138
api/core/core.go
138
api/core/core.go
@ -24,98 +24,96 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/api/unit"
|
||||
)
|
||||
|
||||
type (
|
||||
ScopeID struct {
|
||||
EventID
|
||||
SpanContext
|
||||
}
|
||||
type ScopeID struct {
|
||||
EventID
|
||||
SpanContext
|
||||
}
|
||||
|
||||
SpanContext struct {
|
||||
TraceIDHigh uint64
|
||||
TraceIDLow uint64
|
||||
SpanID uint64
|
||||
}
|
||||
type SpanContext struct {
|
||||
TraceIDHigh uint64
|
||||
TraceIDLow uint64
|
||||
SpanID uint64
|
||||
}
|
||||
|
||||
EventID uint64
|
||||
type EventID uint64
|
||||
|
||||
BaseMeasure interface {
|
||||
Name() string
|
||||
Description() string
|
||||
Unit() unit.Unit
|
||||
type BaseMeasure interface {
|
||||
Name() string
|
||||
Description() string
|
||||
Unit() unit.Unit
|
||||
|
||||
DefinitionID() EventID
|
||||
}
|
||||
DefinitionID() EventID
|
||||
}
|
||||
|
||||
Measure interface {
|
||||
BaseMeasure
|
||||
type Measure interface {
|
||||
BaseMeasure
|
||||
|
||||
M(float64) Measurement
|
||||
V(float64) KeyValue
|
||||
}
|
||||
M(float64) Measurement
|
||||
V(float64) KeyValue
|
||||
}
|
||||
|
||||
Measurement struct {
|
||||
// NOTE: If we add a ScopeID field this can carry
|
||||
// pre-aggregated measures via the stats.Record API.
|
||||
Measure Measure
|
||||
Value float64
|
||||
ScopeID ScopeID
|
||||
}
|
||||
type Measurement struct {
|
||||
// NOTE: If we add a ScopeID field this can carry
|
||||
// pre-aggregated measures via the stats.Record API.
|
||||
Measure Measure
|
||||
Value float64
|
||||
ScopeID ScopeID
|
||||
}
|
||||
|
||||
Key interface {
|
||||
BaseMeasure
|
||||
type Key interface {
|
||||
BaseMeasure
|
||||
|
||||
Value(ctx context.Context) KeyValue
|
||||
Value(ctx context.Context) KeyValue
|
||||
|
||||
Bool(v bool) KeyValue
|
||||
Bool(v bool) KeyValue
|
||||
|
||||
Int(v int) KeyValue
|
||||
Int32(v int32) KeyValue
|
||||
Int64(v int64) KeyValue
|
||||
Int(v int) KeyValue
|
||||
Int32(v int32) KeyValue
|
||||
Int64(v int64) KeyValue
|
||||
|
||||
Uint(v uint) KeyValue
|
||||
Uint32(v uint32) KeyValue
|
||||
Uint64(v uint64) KeyValue
|
||||
Uint(v uint) KeyValue
|
||||
Uint32(v uint32) KeyValue
|
||||
Uint64(v uint64) KeyValue
|
||||
|
||||
Float32(v float32) KeyValue
|
||||
Float64(v float64) KeyValue
|
||||
Float32(v float32) KeyValue
|
||||
Float64(v float64) KeyValue
|
||||
|
||||
String(v string) KeyValue
|
||||
Bytes(v []byte) KeyValue
|
||||
}
|
||||
String(v string) KeyValue
|
||||
Bytes(v []byte) KeyValue
|
||||
}
|
||||
|
||||
KeyValue struct {
|
||||
Key Key
|
||||
Value Value
|
||||
}
|
||||
type KeyValue struct {
|
||||
Key Key
|
||||
Value Value
|
||||
}
|
||||
|
||||
ValueType int
|
||||
type ValueType int
|
||||
|
||||
Value struct {
|
||||
Type ValueType
|
||||
Bool bool
|
||||
Int64 int64
|
||||
Uint64 uint64
|
||||
Float64 float64
|
||||
String string
|
||||
Bytes []byte
|
||||
type Value struct {
|
||||
Type ValueType
|
||||
Bool bool
|
||||
Int64 int64
|
||||
Uint64 uint64
|
||||
Float64 float64
|
||||
String string
|
||||
Bytes []byte
|
||||
|
||||
// TODO Lazy value type?
|
||||
}
|
||||
// TODO Lazy value type?
|
||||
}
|
||||
|
||||
MutatorOp int
|
||||
type MutatorOp int
|
||||
|
||||
Mutator struct {
|
||||
MutatorOp
|
||||
KeyValue
|
||||
MeasureMetadata
|
||||
}
|
||||
type Mutator struct {
|
||||
MutatorOp
|
||||
KeyValue
|
||||
MeasureMetadata
|
||||
}
|
||||
|
||||
MeasureMetadata struct {
|
||||
MaxHops int // -1 == infinite, 0 == do not propagate
|
||||
type MeasureMetadata struct {
|
||||
MaxHops int // -1 == infinite, 0 == do not propagate
|
||||
|
||||
// TODO time to live?
|
||||
}
|
||||
)
|
||||
// TODO time to live?
|
||||
}
|
||||
|
||||
const (
|
||||
INVALID ValueType = iota
|
||||
|
@ -18,14 +18,12 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/api/core"
|
||||
)
|
||||
|
||||
type (
|
||||
// Event interface provides methods to retrieve Event properties.
|
||||
Event interface {
|
||||
// Event interface provides methods to retrieve Event properties.
|
||||
type Event interface {
|
||||
|
||||
// Message interface retrieves message string of the Event.
|
||||
Message() string
|
||||
// Message interface retrieves message string of the Event.
|
||||
Message() string
|
||||
|
||||
// Attributes interface returns a copy of attributes associated with the Event.
|
||||
Attributes() []core.KeyValue
|
||||
}
|
||||
)
|
||||
// Attributes interface returns a copy of attributes associated with the Event.
|
||||
Attributes() []core.KeyValue
|
||||
}
|
||||
|
@ -20,21 +20,18 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/api/unit"
|
||||
)
|
||||
|
||||
type (
|
||||
Metric interface {
|
||||
Measure() core.Measure
|
||||
type Metric interface {
|
||||
Measure() core.Measure
|
||||
|
||||
DefinitionID() core.EventID
|
||||
DefinitionID() core.EventID
|
||||
|
||||
Type() MetricType
|
||||
Fields() []core.Key
|
||||
Err() error
|
||||
Type() MetricType
|
||||
Fields() []core.Key
|
||||
Err() error
|
||||
|
||||
base() *baseMetric
|
||||
}
|
||||
|
||||
MetricType int
|
||||
)
|
||||
base() *baseMetric
|
||||
}
|
||||
type MetricType int
|
||||
|
||||
const (
|
||||
Invalid MetricType = iota
|
||||
@ -48,9 +45,7 @@ const (
|
||||
DerivedCumulativeFloat64
|
||||
)
|
||||
|
||||
type (
|
||||
Option func(*baseMetric, *[]tag.Option)
|
||||
)
|
||||
type Option func(*baseMetric, *[]tag.Option)
|
||||
|
||||
// WithDescription applies provided description.
|
||||
func WithDescription(desc string) Option {
|
||||
|
@ -21,22 +21,20 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/exporter/observer"
|
||||
)
|
||||
|
||||
type (
|
||||
baseMetric struct {
|
||||
measure core.Measure
|
||||
type baseMetric struct {
|
||||
measure core.Measure
|
||||
|
||||
mtype MetricType
|
||||
keys []core.Key
|
||||
eventID core.EventID
|
||||
status error // Indicates registry conflict
|
||||
}
|
||||
mtype MetricType
|
||||
keys []core.Key
|
||||
eventID core.EventID
|
||||
status error // Indicates registry conflict
|
||||
}
|
||||
|
||||
baseEntry struct {
|
||||
base *baseMetric
|
||||
metric Metric
|
||||
eventID core.EventID
|
||||
}
|
||||
)
|
||||
type baseEntry struct {
|
||||
base *baseMetric
|
||||
metric Metric
|
||||
eventID core.EventID
|
||||
}
|
||||
|
||||
func initBaseMetric(name string, mtype MetricType, opts []Option, init Metric) Metric {
|
||||
var tagOpts []tag.Option
|
||||
|
@ -21,15 +21,13 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/api/stats"
|
||||
)
|
||||
|
||||
type (
|
||||
Float64Gauge struct {
|
||||
baseMetric
|
||||
}
|
||||
type Float64Gauge struct {
|
||||
baseMetric
|
||||
}
|
||||
|
||||
Float64Entry struct {
|
||||
baseEntry
|
||||
}
|
||||
)
|
||||
type Float64Entry struct {
|
||||
baseEntry
|
||||
}
|
||||
|
||||
func NewFloat64Gauge(name string, mos ...Option) *Float64Gauge {
|
||||
m := initBaseMetric(name, GaugeFloat64, mos, &Float64Gauge{}).(*Float64Gauge)
|
||||
|
@ -33,18 +33,16 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
type (
|
||||
// Registry is a mechanism for avoiding duplicate registration
|
||||
// of different-type pre-aggregated metrics (in one process).
|
||||
Registry interface {
|
||||
RegisterMetric(Metric) (Metric, error)
|
||||
ForeachMetric(func(string, Metric))
|
||||
}
|
||||
// Registry is a mechanism for avoiding duplicate registration
|
||||
// of different-type pre-aggregated metrics (in one process).
|
||||
type Registry interface {
|
||||
RegisterMetric(Metric) (Metric, error)
|
||||
ForeachMetric(func(string, Metric))
|
||||
}
|
||||
|
||||
registry struct {
|
||||
nameType sync.Map // map[string]Metric
|
||||
}
|
||||
)
|
||||
type registry struct {
|
||||
nameType sync.Map // map[string]Metric
|
||||
}
|
||||
|
||||
var (
|
||||
registryLock sync.Mutex
|
||||
|
@ -21,27 +21,25 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/exporter/observer"
|
||||
)
|
||||
|
||||
type (
|
||||
Scope interface {
|
||||
ScopeID() core.ScopeID
|
||||
}
|
||||
type Scope interface {
|
||||
ScopeID() core.ScopeID
|
||||
}
|
||||
|
||||
Mutable interface {
|
||||
Scope
|
||||
type Mutable interface {
|
||||
Scope
|
||||
|
||||
SetAttribute(core.KeyValue)
|
||||
SetAttributes(...core.KeyValue)
|
||||
SetAttribute(core.KeyValue)
|
||||
SetAttributes(...core.KeyValue)
|
||||
|
||||
ModifyAttribute(core.Mutator)
|
||||
ModifyAttributes(...core.Mutator)
|
||||
}
|
||||
ModifyAttribute(core.Mutator)
|
||||
ModifyAttributes(...core.Mutator)
|
||||
}
|
||||
|
||||
scopeIdent struct {
|
||||
id core.ScopeID
|
||||
}
|
||||
type scopeIdent struct {
|
||||
id core.ScopeID
|
||||
}
|
||||
|
||||
scopeKeyType struct{}
|
||||
)
|
||||
type scopeKeyType struct{}
|
||||
|
||||
var (
|
||||
scopeKey = &scopeKeyType{}
|
||||
|
@ -22,16 +22,14 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/exporter/observer"
|
||||
)
|
||||
|
||||
type (
|
||||
Interface interface {
|
||||
Record(ctx context.Context, m ...core.Measurement)
|
||||
RecordSingle(ctx context.Context, m core.Measurement)
|
||||
}
|
||||
type Interface interface {
|
||||
Record(ctx context.Context, m ...core.Measurement)
|
||||
RecordSingle(ctx context.Context, m core.Measurement)
|
||||
}
|
||||
|
||||
Recorder struct {
|
||||
core.ScopeID
|
||||
}
|
||||
)
|
||||
type Recorder struct {
|
||||
core.ScopeID
|
||||
}
|
||||
|
||||
func With(scope scope.Scope) Recorder {
|
||||
return Recorder{scope.ScopeID()}
|
||||
|
@ -21,21 +21,19 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/api/unit"
|
||||
)
|
||||
|
||||
type (
|
||||
Map interface {
|
||||
// TODO combine these four into a struct
|
||||
Apply(a1 core.KeyValue, attributes []core.KeyValue, m1 core.Mutator, mutators []core.Mutator) Map
|
||||
type Map interface {
|
||||
// TODO combine these four into a struct
|
||||
Apply(a1 core.KeyValue, attributes []core.KeyValue, m1 core.Mutator, mutators []core.Mutator) Map
|
||||
|
||||
Value(core.Key) (core.Value, bool)
|
||||
HasValue(core.Key) bool
|
||||
Value(core.Key) (core.Value, bool)
|
||||
HasValue(core.Key) bool
|
||||
|
||||
Len() int
|
||||
Len() int
|
||||
|
||||
Foreach(func(kv core.KeyValue) bool)
|
||||
}
|
||||
Foreach(func(kv core.KeyValue) bool)
|
||||
}
|
||||
|
||||
Option func(*registeredKey)
|
||||
)
|
||||
type Option func(*registeredKey)
|
||||
|
||||
var (
|
||||
EmptyMap = NewMap(core.KeyValue{}, nil, core.Mutator{}, nil)
|
||||
|
@ -21,14 +21,12 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/api/core"
|
||||
)
|
||||
|
||||
type (
|
||||
tagMap map[core.Key]tagContent
|
||||
type tagMap map[core.Key]tagContent
|
||||
|
||||
tagContent struct {
|
||||
value core.Value
|
||||
meta core.MeasureMetadata
|
||||
}
|
||||
)
|
||||
type tagContent struct {
|
||||
value core.Value
|
||||
meta core.MeasureMetadata
|
||||
}
|
||||
|
||||
func (m tagMap) HasValue(k core.Key) bool {
|
||||
_, has := m.Value(k)
|
||||
|
@ -23,20 +23,18 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/exporter/observer"
|
||||
)
|
||||
|
||||
type (
|
||||
registeredKey struct {
|
||||
name string
|
||||
desc string
|
||||
unit unit.Unit
|
||||
eventID core.EventID
|
||||
}
|
||||
type registeredKey struct {
|
||||
name string
|
||||
desc string
|
||||
unit unit.Unit
|
||||
eventID core.EventID
|
||||
}
|
||||
|
||||
ctxTagsType struct{}
|
||||
type ctxTagsType struct{}
|
||||
|
||||
measure struct {
|
||||
rk *registeredKey
|
||||
}
|
||||
)
|
||||
type measure struct {
|
||||
rk *registeredKey
|
||||
}
|
||||
|
||||
var (
|
||||
ctxTagsKey = &ctxTagsType{}
|
||||
|
130
api/trace/api.go
130
api/trace/api.go
@ -28,90 +28,88 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/api/tag"
|
||||
)
|
||||
|
||||
type (
|
||||
Tracer interface {
|
||||
Start(context.Context, string, ...SpanOption) (context.Context, Span)
|
||||
type Tracer interface {
|
||||
Start(context.Context, string, ...SpanOption) (context.Context, Span)
|
||||
|
||||
// WithSpan wraps the execution of the function body with a span.
|
||||
// It starts a new span and sets it as an active span in the context.
|
||||
// It then executes the body. It closes the span before returning the execution result.
|
||||
// TODO: Should it restore the previous span?
|
||||
WithSpan(
|
||||
ctx context.Context,
|
||||
operation string,
|
||||
body func(ctx context.Context) error,
|
||||
) error
|
||||
// WithSpan wraps the execution of the function body with a span.
|
||||
// It starts a new span and sets it as an active span in the context.
|
||||
// It then executes the body. It closes the span before returning the execution result.
|
||||
// TODO: Should it restore the previous span?
|
||||
WithSpan(
|
||||
ctx context.Context,
|
||||
operation string,
|
||||
body func(ctx context.Context) error,
|
||||
) error
|
||||
|
||||
// TODO: Do we need WithService and WithComponent?
|
||||
WithService(name string) Tracer
|
||||
WithComponent(name string) Tracer
|
||||
// TODO: Do we need WithService and WithComponent?
|
||||
WithService(name string) Tracer
|
||||
WithComponent(name string) Tracer
|
||||
|
||||
// WithResources attaches resource attributes to the Tracer.
|
||||
WithResources(res ...core.KeyValue) Tracer
|
||||
// WithResources attaches resource attributes to the Tracer.
|
||||
WithResources(res ...core.KeyValue) Tracer
|
||||
|
||||
// Note: see https://github.com/opentracing/opentracing-go/issues/127
|
||||
Inject(context.Context, Span, Injector)
|
||||
// Note: see https://github.com/opentracing/opentracing-go/issues/127
|
||||
Inject(context.Context, Span, Injector)
|
||||
|
||||
// ScopeID returns the resource scope of this tracer.
|
||||
scope.Scope
|
||||
}
|
||||
// ScopeID returns the resource scope of this tracer.
|
||||
scope.Scope
|
||||
}
|
||||
|
||||
Span interface {
|
||||
scope.Mutable
|
||||
type Span interface {
|
||||
scope.Mutable
|
||||
|
||||
stats.Interface
|
||||
stats.Interface
|
||||
|
||||
// Tracer returns tracer used to create this span. Tracer cannot be nil.
|
||||
Tracer() Tracer
|
||||
// Tracer returns tracer used to create this span. Tracer cannot be nil.
|
||||
Tracer() Tracer
|
||||
|
||||
// Finish completes the span. No updates are allowed to span after it
|
||||
// finishes. The only exception is setting status of the span.
|
||||
Finish()
|
||||
// Finish completes the span. No updates are allowed to span after it
|
||||
// finishes. The only exception is setting status of the span.
|
||||
Finish()
|
||||
|
||||
// AddEvent adds an event to the span.
|
||||
AddEvent(ctx context.Context, event event.Event)
|
||||
// AddEvent adds an event to the span.
|
||||
AddEvent(ctx context.Context, event event.Event)
|
||||
|
||||
// IsRecordingEvents returns true if the span is active and recording events is enabled.
|
||||
IsRecordingEvents() bool
|
||||
// IsRecordingEvents returns true if the span is active and recording events is enabled.
|
||||
IsRecordingEvents() bool
|
||||
|
||||
// SpancContext returns span context of the span. Return SpanContext is usable
|
||||
// even after the span is finished.
|
||||
SpanContext() core.SpanContext
|
||||
// SpancContext returns span context of the span. Return SpanContext is usable
|
||||
// even after the span is finished.
|
||||
SpanContext() core.SpanContext
|
||||
|
||||
// SetStatus sets the status of the span. The status of the span can be updated
|
||||
// even after span is finished.
|
||||
SetStatus(codes.Code)
|
||||
}
|
||||
// SetStatus sets the status of the span. The status of the span can be updated
|
||||
// even after span is finished.
|
||||
SetStatus(codes.Code)
|
||||
}
|
||||
|
||||
Injector interface {
|
||||
// Inject serializes span context and tag.Map and inserts them in to
|
||||
// carrier associated with the injector. For example in case of http request,
|
||||
// span context could added to the request (carrier) as W3C Trace context header.
|
||||
Inject(core.SpanContext, tag.Map)
|
||||
}
|
||||
type Injector interface {
|
||||
// Inject serializes span context and tag.Map and inserts them in to
|
||||
// carrier associated with the injector. For example in case of http request,
|
||||
// span context could added to the request (carrier) as W3C Trace context header.
|
||||
Inject(core.SpanContext, tag.Map)
|
||||
}
|
||||
|
||||
// SpanOption apply changes to SpanOptions.
|
||||
SpanOption func(*SpanOptions)
|
||||
// SpanOption apply changes to SpanOptions.
|
||||
type SpanOption func(*SpanOptions)
|
||||
|
||||
// SpanOptions provides options to set properties of span at the time of starting
|
||||
// a new span.
|
||||
SpanOptions struct {
|
||||
Attributes []core.KeyValue
|
||||
StartTime time.Time
|
||||
Reference Reference
|
||||
RecordEvent bool
|
||||
}
|
||||
// SpanOptions provides options to set properties of span at the time of starting
|
||||
// a new span.
|
||||
type SpanOptions struct {
|
||||
Attributes []core.KeyValue
|
||||
StartTime time.Time
|
||||
Reference Reference
|
||||
RecordEvent bool
|
||||
}
|
||||
|
||||
// Reference is used to establish relationship between newly created span and the
|
||||
// other span. The other span could be related as a parent or linked or any other
|
||||
// future relationship type.
|
||||
Reference struct {
|
||||
core.SpanContext
|
||||
RelationshipType
|
||||
}
|
||||
// Reference is used to establish relationship between newly created span and the
|
||||
// other span. The other span could be related as a parent or linked or any other
|
||||
// future relationship type.
|
||||
type Reference struct {
|
||||
core.SpanContext
|
||||
RelationshipType
|
||||
}
|
||||
|
||||
RelationshipType int
|
||||
)
|
||||
type RelationshipType int
|
||||
|
||||
var (
|
||||
// The process global tracer could have process-wide resource
|
||||
|
@ -21,14 +21,12 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/api/scope"
|
||||
)
|
||||
|
||||
type (
|
||||
noopSpan struct {
|
||||
}
|
||||
type noopSpan struct {
|
||||
}
|
||||
|
||||
noopTracer struct {
|
||||
resources core.EventID
|
||||
}
|
||||
)
|
||||
type noopTracer struct {
|
||||
resources core.EventID
|
||||
}
|
||||
|
||||
var _ Tracer = (*noopTracer)(nil)
|
||||
|
||||
|
@ -14,9 +14,7 @@
|
||||
|
||||
package unit
|
||||
|
||||
type (
|
||||
Unit string
|
||||
)
|
||||
type Unit string
|
||||
|
||||
const (
|
||||
Dimensionless Unit = "1"
|
||||
|
@ -21,15 +21,13 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/exporter/observer"
|
||||
)
|
||||
|
||||
type (
|
||||
Buffer struct {
|
||||
observers []observer.Observer
|
||||
events chan observer.Event
|
||||
dropped uint64
|
||||
wait sync.WaitGroup
|
||||
close chan struct{}
|
||||
}
|
||||
)
|
||||
type Buffer struct {
|
||||
observers []observer.Observer
|
||||
events chan observer.Event
|
||||
dropped uint64
|
||||
wait sync.WaitGroup
|
||||
close chan struct{}
|
||||
}
|
||||
|
||||
func NewBuffer(size int, observers ...observer.Observer) *Buffer {
|
||||
b := &Buffer{
|
||||
|
@ -26,43 +26,41 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/api/event"
|
||||
)
|
||||
|
||||
type (
|
||||
EventType int
|
||||
type EventType int
|
||||
|
||||
// TODO: this Event is confusing with event.Event.
|
||||
Event struct {
|
||||
// Automatic fields
|
||||
Sequence core.EventID // Auto-filled
|
||||
Time time.Time // Auto-filled
|
||||
// TODO: this Event is confusing with event.Event.
|
||||
type Event struct {
|
||||
// Automatic fields
|
||||
Sequence core.EventID // Auto-filled
|
||||
Time time.Time // Auto-filled
|
||||
|
||||
// Type, Scope, Context
|
||||
Type EventType // All events
|
||||
Scope core.ScopeID // All events
|
||||
Context context.Context // core.FromContext() and scope.Active()
|
||||
// Type, Scope, Context
|
||||
Type EventType // All events
|
||||
Scope core.ScopeID // All events
|
||||
Context context.Context // core.FromContext() and scope.Active()
|
||||
|
||||
// Arguments (type-specific)
|
||||
Attribute core.KeyValue // SET_ATTRIBUTE
|
||||
Attributes []core.KeyValue // SET_ATTRIBUTES
|
||||
Mutator core.Mutator // SET_ATTRIBUTE
|
||||
Mutators []core.Mutator // SET_ATTRIBUTES
|
||||
Event event.Event // ADD_EVENT
|
||||
Recovered interface{} // FINISH_SPAN
|
||||
Status codes.Code // SET_STATUS
|
||||
// Arguments (type-specific)
|
||||
Attribute core.KeyValue // SET_ATTRIBUTE
|
||||
Attributes []core.KeyValue // SET_ATTRIBUTES
|
||||
Mutator core.Mutator // SET_ATTRIBUTE
|
||||
Mutators []core.Mutator // SET_ATTRIBUTES
|
||||
Event event.Event // ADD_EVENT
|
||||
Recovered interface{} // FINISH_SPAN
|
||||
Status codes.Code // SET_STATUS
|
||||
|
||||
// Values
|
||||
String string // START_SPAN, EVENT, ...
|
||||
Float64 float64
|
||||
Parent core.ScopeID // START_SPAN
|
||||
Stats []core.Measurement
|
||||
Stat core.Measurement
|
||||
}
|
||||
// Values
|
||||
String string // START_SPAN, EVENT, ...
|
||||
Float64 float64
|
||||
Parent core.ScopeID // START_SPAN
|
||||
Stats []core.Measurement
|
||||
Stat core.Measurement
|
||||
}
|
||||
|
||||
Observer interface {
|
||||
Observe(data Event)
|
||||
}
|
||||
type Observer interface {
|
||||
Observe(data Event)
|
||||
}
|
||||
|
||||
observersMap map[Observer]struct{}
|
||||
)
|
||||
type observersMap map[Observer]struct{}
|
||||
|
||||
//go:generate stringer -type=EventType
|
||||
const (
|
||||
|
@ -30,79 +30,77 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/exporter/observer"
|
||||
)
|
||||
|
||||
type (
|
||||
Reader interface {
|
||||
Read(Event)
|
||||
}
|
||||
type Reader interface {
|
||||
Read(Event)
|
||||
}
|
||||
|
||||
EventType int
|
||||
type EventType int
|
||||
|
||||
Event struct {
|
||||
Type EventType
|
||||
Time time.Time
|
||||
Sequence core.EventID
|
||||
SpanContext core.SpanContext
|
||||
Tags tag.Map
|
||||
Attributes tag.Map
|
||||
Event event.Event
|
||||
Stats []Measurement
|
||||
type Event struct {
|
||||
Type EventType
|
||||
Time time.Time
|
||||
Sequence core.EventID
|
||||
SpanContext core.SpanContext
|
||||
Tags tag.Map
|
||||
Attributes tag.Map
|
||||
Event event.Event
|
||||
Stats []Measurement
|
||||
|
||||
Parent core.SpanContext
|
||||
ParentAttributes tag.Map
|
||||
Parent core.SpanContext
|
||||
ParentAttributes tag.Map
|
||||
|
||||
Duration time.Duration
|
||||
Name string
|
||||
Message string
|
||||
Status codes.Code
|
||||
}
|
||||
Duration time.Duration
|
||||
Name string
|
||||
Message string
|
||||
Status codes.Code
|
||||
}
|
||||
|
||||
Measurement struct {
|
||||
Measure core.Measure
|
||||
Value float64
|
||||
Tags tag.Map
|
||||
}
|
||||
type Measurement struct {
|
||||
Measure core.Measure
|
||||
Value float64
|
||||
Tags tag.Map
|
||||
}
|
||||
|
||||
readerObserver struct {
|
||||
readers []Reader
|
||||
type readerObserver struct {
|
||||
readers []Reader
|
||||
|
||||
// core.EventID -> *readerSpan or *readerScope
|
||||
scopes sync.Map
|
||||
// core.EventID -> *readerSpan or *readerScope
|
||||
scopes sync.Map
|
||||
|
||||
// core.EventID -> *readerMeasure
|
||||
measures sync.Map
|
||||
// core.EventID -> *readerMeasure
|
||||
measures sync.Map
|
||||
|
||||
// core.EventID -> *readerMetric
|
||||
metrics sync.Map
|
||||
}
|
||||
// core.EventID -> *readerMetric
|
||||
metrics sync.Map
|
||||
}
|
||||
|
||||
readerSpan struct {
|
||||
name string
|
||||
start time.Time
|
||||
startTags tag.Map
|
||||
spanContext core.SpanContext
|
||||
status codes.Code
|
||||
type readerSpan struct {
|
||||
name string
|
||||
start time.Time
|
||||
startTags tag.Map
|
||||
spanContext core.SpanContext
|
||||
status codes.Code
|
||||
|
||||
*readerScope
|
||||
}
|
||||
*readerScope
|
||||
}
|
||||
|
||||
readerMeasure struct {
|
||||
name string
|
||||
desc string
|
||||
unit unit.Unit
|
||||
}
|
||||
type readerMeasure struct {
|
||||
name string
|
||||
desc string
|
||||
unit unit.Unit
|
||||
}
|
||||
|
||||
readerMetric struct {
|
||||
*readerMeasure
|
||||
mtype metric.MetricType
|
||||
fields []core.Measure
|
||||
}
|
||||
type readerMetric struct {
|
||||
*readerMeasure
|
||||
mtype metric.MetricType
|
||||
fields []core.Measure
|
||||
}
|
||||
|
||||
readerScope struct {
|
||||
span *readerSpan
|
||||
parent core.EventID
|
||||
attributes tag.Map
|
||||
}
|
||||
)
|
||||
type readerScope struct {
|
||||
span *readerSpan
|
||||
parent core.EventID
|
||||
attributes tag.Map
|
||||
}
|
||||
|
||||
const (
|
||||
INVALID EventType = iota
|
||||
|
@ -20,20 +20,18 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/exporter/reader"
|
||||
)
|
||||
|
||||
type (
|
||||
Reader interface {
|
||||
Read(*Span)
|
||||
}
|
||||
type Reader interface {
|
||||
Read(*Span)
|
||||
}
|
||||
|
||||
Span struct {
|
||||
Events []reader.Event
|
||||
}
|
||||
type Span struct {
|
||||
Events []reader.Event
|
||||
}
|
||||
|
||||
spanReader struct {
|
||||
spans map[core.SpanContext]*Span
|
||||
readers []Reader
|
||||
}
|
||||
)
|
||||
type spanReader struct {
|
||||
spans map[core.SpanContext]*Span
|
||||
readers []Reader
|
||||
}
|
||||
|
||||
func NewReaderObserver(readers ...Reader) observer.Observer {
|
||||
return reader.NewReaderObserver(&spanReader{
|
||||
|
@ -24,9 +24,7 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/exporter/spandata/format"
|
||||
)
|
||||
|
||||
type (
|
||||
spanLog struct{}
|
||||
)
|
||||
type spanLog struct{}
|
||||
|
||||
func New() observer.Observer {
|
||||
return buffer.NewBuffer(1000, spandata.NewReaderObserver(&spanLog{}))
|
||||
|
@ -22,9 +22,7 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/exporter/reader/format"
|
||||
)
|
||||
|
||||
type (
|
||||
stderrLog struct{}
|
||||
)
|
||||
type stderrLog struct{}
|
||||
|
||||
func New() observer.Observer {
|
||||
return reader.NewReaderObserver(&stderrLog{})
|
||||
|
@ -22,9 +22,7 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/exporter/reader/format"
|
||||
)
|
||||
|
||||
type (
|
||||
stdoutLog struct{}
|
||||
)
|
||||
type stdoutLog struct{}
|
||||
|
||||
func New() observer.Observer {
|
||||
return reader.NewReaderObserver(&stdoutLog{})
|
||||
|
@ -29,19 +29,10 @@ import (
|
||||
"github.com/open-telemetry/opentelemetry-go/sdk/event"
|
||||
)
|
||||
|
||||
type (
|
||||
clientLevel struct {
|
||||
trace.Span
|
||||
ident string
|
||||
}
|
||||
|
||||
clientTracer struct {
|
||||
context.Context
|
||||
httptrace.ClientTrace
|
||||
|
||||
levels []clientLevel
|
||||
}
|
||||
)
|
||||
type clientLevel struct {
|
||||
trace.Span
|
||||
ident string
|
||||
}
|
||||
|
||||
var (
|
||||
HTTPStatus = tag.New("http.status")
|
||||
@ -53,6 +44,13 @@ var (
|
||||
)
|
||||
)
|
||||
|
||||
type clientTracer struct {
|
||||
context.Context
|
||||
httptrace.ClientTrace
|
||||
|
||||
levels []clientLevel
|
||||
}
|
||||
|
||||
func newClientTracer(ctx context.Context) *clientTracer {
|
||||
ct := &clientTracer{
|
||||
Context: ctx,
|
||||
|
@ -18,7 +18,6 @@ import (
|
||||
"encoding/binary"
|
||||
"net/http"
|
||||
|
||||
"github.com/lightstep/tracecontext.go"
|
||||
"github.com/lightstep/tracecontext.go/tracestate"
|
||||
|
||||
"github.com/open-telemetry/opentelemetry-go/api/core"
|
||||
@ -29,12 +28,6 @@ const (
|
||||
Vendor = "ot"
|
||||
)
|
||||
|
||||
type (
|
||||
hinjector struct {
|
||||
*http.Request
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
HostKey = tag.New("http.host")
|
||||
URLKey = tag.New("http.url")
|
||||
@ -74,6 +67,10 @@ func Extract(req *http.Request) ([]core.KeyValue, []core.KeyValue, core.SpanCont
|
||||
return attrs, tags, sc
|
||||
}
|
||||
|
||||
type hinjector struct {
|
||||
*http.Request
|
||||
}
|
||||
|
||||
func (h hinjector) Inject(sc core.SpanContext, tags tag.Map) {
|
||||
var tc tracecontext.TraceContext
|
||||
var sid [8]byte
|
||||
|
Loading…
Reference in New Issue
Block a user