Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Initializing Span with a Previously Started Context #233

Open
dm03514 opened this issue Oct 31, 2019 · 2 comments
Open

Support for Initializing Span with a Previously Started Context #233

dm03514 opened this issue Oct 31, 2019 · 2 comments

Comments

@dm03514
Copy link

dm03514 commented Oct 31, 2019

馃憢 Hello, I was wondering if there was any way you'd be open to allowing a span to be created with an already existing SpanContext? I have a unique use case where I need to save an in-progress span and ship it out of memory, and then later reload it into memory and finish the span. I was wondering if you'd be open to supporting this feature in the lightstep go client?

I was able to add support for this in the jaeger client, and was hoping to use the same functionality with LightStep:

jaegertracing/jaeger-client-go#397

The strategy we took for jaeger was to add a SelfRef type that bhs proposed:

opentracing/specification#81 (comment)

If you're interested I would be happy to contribute this!


I was imagining the same API and approach as the jaeger library:

span := tracer.StartSpan(
    "continued_span",
    lightstep.SelfRef(aSpanContext),
)

Which would require:

  • adding a new reference type SelfRefType:
SelfRefType opentracing.SpanReferenceType = 99
sp.raw.Context = refCtx
  • Expose Tags From Span:
func (s *spanImpl) Tags() opentracing.Tags {
	return s.raw.Tags
}

I think this is everything needed to then export a context:

spanCtx := span.Context()
saveContext(key, spanCtx, spanCtx.Tags())
...

Then starting a span with a previously started context:

span := tracer.StartSpan(
    "continued_span",
    lightstep.SelfRef(getPreviousContext(key)),
)

I really appreciate your time! Thank you

Danny

@dm03514 dm03514 changed the title Support Exporting SpanContext and initializing Span with A given Context Support for Initializing Span with A given Context Oct 31, 2019
@dm03514 dm03514 changed the title Support for Initializing Span with A given Context Support for Initializing Span with a Previously Started Context Oct 31, 2019
@dm03514
Copy link
Author

dm03514 commented Nov 3, 2019

Closing as I don't have a very good idea of the problem yet, just learning this library!

@dm03514
Copy link
Author

dm03514 commented Nov 3, 2019

The strategy I took was to make SpanImpl public and allow callers to access the RawSpan through SpanImpl.Raw().

Then when creating a span there is an option to StartSpan with an already established RawSpan:

		span := tracer.StartSpan(
			rawSpan.Operation,
			lightstep.SetRawSpan(rawSpan),
		)

Would love if there was any way this could be in main but understand if it's too big of change.

Thank you again, danny

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

No branches or pull requests

1 participant