1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-07-17 01:12:45 +02:00

Consolidate AddEvent and Event methods, add FinishOptions (#99)

* Merge two event methods in span API

There was an agreement to get rid of the Event interface and
consolidate the two methods for adding events into one. See #57.

* Eliminate the use of the Event interface

There is no need for the SDK to provide the implementation of the
Event interface - it is used nowhere.

* Drop the Event interface

It's dead code now.

* Make it possible to override a finish timestamp through options

Opentracing to opentelemetry bridge will certainly use this feature.

* Obey the start time option

* Add tests for events and custom start/end times
This commit is contained in:
Krzesimir Nowak
2019-09-03 20:03:51 +02:00
committed by rghetia
parent 3fc6025071
commit a776e95c61
15 changed files with 297 additions and 98 deletions

View File

@ -21,7 +21,6 @@ import (
"google.golang.org/grpc/codes"
"go.opentelemetry.io/api/core"
"go.opentelemetry.io/api/event"
"go.opentelemetry.io/api/tag"
)
@ -50,18 +49,28 @@ type Tracer interface {
Inject(context.Context, Span, Injector)
}
type FinishOptions struct {
FinishTime time.Time
}
type FinishOption func(*FinishOptions)
func WithFinishTime(finishTime time.Time) FinishOption {
return func(opts *FinishOptions) {
opts.FinishTime = finishTime
}
}
type Span interface {
// 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(options ...FinishOption)
// AddEvent adds an event to the span.
AddEvent(ctx context.Context, event event.Event)
// AddEvent records an event to the span.
Event(ctx context.Context, msg string, attrs ...core.KeyValue)
AddEvent(ctx context.Context, msg string, attrs ...core.KeyValue)
// IsRecordingEvents returns true if the span is active and recording events is enabled.
IsRecordingEvents() bool