opentracing / opentracing-go

OpenTracing API for Go. 🛑 This library is DEPRECATED! https://github.com/opentracing/specification/issues/163
http://opentracing.io
Apache License 2.0
3.5k stars 316 forks source link

Is it possible to log with a timestamp without finishing a span? #156

Open grantr opened 7 years ago

grantr commented 7 years ago

I'm using opentracing-go with the gRPC stats API, which emits lifecycle events as RPCs progress. Those events include their own timestamps, so I'd like to use them for logging.

I can use LogRecord to manipulate timestamps, but the only way to add them to a span seems to be FinishWithOptions. I'd like to add them at any time during the life of a span. I think a LogRecords(records... LogRecord) method on the Span interface would solve this.

yurishkuro commented 7 years ago

do you need a KV logging facility, or event+payload is enough? You could use LogData for now.

LogRecords would make sense, but will require major version bump.

grantr commented 7 years ago

Here's the current code:

span.LogFields(
  otlog.String(eventKey, "Payload out"),
  otlog.Int(gRPCResponseLengthTagName, event.Length),
  otlog.Int(gRPCResponseWireLengthTagName, event.WireLength),
)

Would LogData work for that? I'm not sure if it supports multiple fields.

Why major version bump to add a new method? Is it a backward incompatible change?

yurishkuro commented 7 years ago

No logdata won't work with fields.

Yes, adding a method to an interface is a breaking change - all existing implementations no longer implement the new interface. I guess depends on how you define "breaking", but say Jaeger tracer depends on ^1, so it will automatically break if we release 1.x with this change.

grantr commented 7 years ago

Oh right, I remember that now about Go interfaces. Bummer!