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

Update Span API event methods (#1254)

* Update Span API event methods

Remove the context argument from the event methods. It is unused and can
be added back in as a passed option if needed in the future.

Update AddEvent to accept a required name and a set of options. These
options are the new EventOption type that can be used to configure a
SpanConfig Timestamp and Attributes.

Remove the AddEventWithTimestamp method as it is redundant to calling
AddEvent with a WithTimestamp option.

Update RecordError to also accept the EventOptions.

* Add changes to CHANGELOG

* Add LifeCycleOption

Use the LifeCycleOption to encapsulate the options passed to a span for
life cycle events.
This commit is contained in:
Tyler Yahn
2020-10-16 08:09:27 -07:00
committed by GitHub
parent 786a78ea36
commit ec300b28ad
16 changed files with 162 additions and 283 deletions

View File

@ -88,7 +88,7 @@ func main() {
ctx, span = tracer.Start(ctx, "operation")
defer span.End()
span.AddEvent(ctx, "Nice operation!", label.Int("bogons", 100))
span.AddEvent("Nice operation!", otel.WithAttributes(label.Int("bogons", 100)))
span.SetAttributes(anotherKey.String("yes"))
meter.RecordBatch(
@ -105,7 +105,7 @@ func main() {
defer span.End()
span.SetAttributes(lemonsKey.String("five"))
span.AddEvent(ctx, "Sub span event")
span.AddEvent("Sub span event")
valuerecorder.Record(ctx, 1.3)
return nil