opentracing/opentracing-cpp

Default construction of `StartSpanOptions` sets timestamps to epoch time

Closed this issue · 6 comments

Calling tracer->StartSpan("operation") intuitively should behave the same as calling tracer->StartSpanWithOptions("operation", StartSpanOptions()), however it doesn't. The former default constructs the StartSpanOptions object and sets the timestamps to Clock::now(), but the latter does not set the timestamps. I think it would make more sense to set the timestamps to Clock::now() in a new default constructor StartSpanOptions().

+1

options are meant to be optional, you only need to set those that you care about

I literally just wasted a whole day debugging this...

How about just removing these lines. Then the tracers can set the timestamps if options.start_system_timestamp == std::chrono::system_clock::time_point{}.

I could see stamping the times in StartSpanOption's default constructor causing issues if you want to reuse the options or if you construct it significantly before the span.

It would also match the behavior in Go.

makes sense

I put in #30. I also documented the options more to make the expected behavior clearer. Let me know if that works for you. (Sorry for the trouble).

Updated in #30.