You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-05 00:28:58 +02:00
add WithSpanKind option to span creation (#234)
* add WithSpanKind option to span creation * change SpanKind to string alias and add support for SpanKind on ot bridge * fix tests * fix import order * fix nits
This commit is contained in:
committed by
rghetia
parent
8cb3786789
commit
5e3a2105b9
@ -110,6 +110,7 @@ type SpanOptions struct {
|
||||
StartTime time.Time
|
||||
Relation Relation
|
||||
Record bool
|
||||
SpanKind SpanKind
|
||||
}
|
||||
|
||||
// Relation is used to establish relationship between newly created span and the
|
||||
@ -143,8 +144,20 @@ type Link struct {
|
||||
Attributes []core.KeyValue
|
||||
}
|
||||
|
||||
// SpanKind represents the role of a Span inside a Trace. Often, this defines how a Span
|
||||
// will be processed and visualized by various backends.
|
||||
type SpanKind string
|
||||
|
||||
const (
|
||||
SpanKindInternal SpanKind = "internal"
|
||||
SpanKindServer SpanKind = "server"
|
||||
SpanKindClient SpanKind = "client"
|
||||
SpanKindProducer SpanKind = "producer"
|
||||
SpanKindConsumer SpanKind = "consumer"
|
||||
)
|
||||
|
||||
// WithStartTime sets the start time of the span to provided time t, when it is started.
|
||||
// In absensce of this option, wall clock time is used as start time.
|
||||
// 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 WithStartTime(t time.Time) SpanOption {
|
||||
return func(o *SpanOptions) {
|
||||
@ -188,3 +201,10 @@ func FollowsFrom(sc core.SpanContext) SpanOption {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithSpanKind specifies the role a Span on a Trace.
|
||||
func WithSpanKind(sk SpanKind) SpanOption {
|
||||
return func(o *SpanOptions) {
|
||||
o.SpanKind = sk
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user