Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Tracing: Permit span start and end times to be supplied #273

Open
somersf opened this issue Oct 17, 2020 · 0 comments
Open

Tracing: Permit span start and end times to be supplied #273

somersf opened this issue Oct 17, 2020 · 0 comments

Comments

@somersf
Copy link

somersf commented Oct 17, 2020

Please enable devs using opencensus tracing to supply the start and end times for spans themselves to override the (current default) of capturing the system time when the span is created/ended.

From the spec:

What is Span lifetime?

Span lifetime represents the process of recording the start and the end timestamps to the Span object:

    The start time is recorded when the Span is created.
    The end time needs to be recorded when the operation is ended.

The wording seems to prescribe that the timestamps are captured/applied (eg from system time) by the language bindings at the point in time when spans are created/ended.

That does seem to be the case for the go bindings:

and similarly for the C++ bindings:

My use-case is that I have existing data from a system which already has start/end times. I want to convert this into spans for publication/analysis in opencensus-supported tracing systems by making opencensus spans corresponding to the data.

This is straightforward to do with opentracing APIs - for example, the opentracing Go bindings permit the start and end times to be supplied (using the go-idiomatic "options" patterns):

func callSstart(t opentracing.Tracer, parent opentracing.Span, name string, start time.Time) opentracing.Span {
	return t.StartSpan(name, opentracing.ChildOf(parent.Context()), opentracing.StartTime(start))
}

func callFinish(s opentracing.Span, end time.Time) {
	s.FinishWithOptions(opentracing.FinishOptions{
		FinishTime: end,
	})
}

Since this issue seems to be present in opencensus Go and C++ bindings (I haven't checked others), I have opened it against the spec instead of the specific opencensus language bindings as was suggested by the "new issue" template at https://github.com/census-instrumentation/opencensus-go/issues/new

Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant