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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#90): adds support for finished span handler. #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jcchavezs
Copy link
Contributor

This PR adds support for finishedSpanHandler in the same way as brave: https://github.com/openzipkin/brave/releases/tag/5.4.1

Ping @basvanbeek @adriancole

Closes #90

@coveralls
Copy link

coveralls commented Jul 14, 2019

Coverage Status

Coverage decreased (-0.3%) to 60.823% when pulling 5087c90 on adds_finished_span_handler into faa50ce on master.

Copy link
Member

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the start on this!

tracer *Tracer
mustCollect int32 // used as atomic bool (1 = true, 0 = false)
flushOnFinish bool
finishedSpanHandler func(*model.SpanModel) bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi we have a list of these in java (ex one for metrics, one for dependency graph)

shouldRecord = s.finishedSpanHandler(&s.SpanModel)
}

if shouldRecord && s.flushOnFinish {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume flushOnFinish is related to sampling bit. if so, sg

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that is the case. I think it is more for when you want to add more stuff after a span is finished. See https://github.com/openzipkin/zipkin-go/blob/master/span_options.go#L79

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha. yeah I think this will want sampled local support before people start coding to it. Otherwise, later they might get a firehose and not notice. here's the docs from the java side.

/**
 * Triggered on each finished span except when spans that are {@link Span#isNoop() no-op}.
 *
 * <p>{@link TraceContext#sampled() Sampled spans} hit this stage before reporting to Zipkin.
 * This means changes to the mutable span will reflect in reported data.
 *
 * <p>When Zipkin's reporter is {@link zipkin2.reporter.Reporter#NOOP} or the context is
 * unsampled, this will still receive spans where {@link TraceContext#sampledLocal()} is true.
 *
 * @see #alwaysSampleLocal()
 */

https://github.com/openzipkin/brave/blob/5a17fc018613958db00cc7b6951826e95f1b9d6c/brave/src/main/java/brave/handler/FinishedSpanHandler.java#L30

tracer, _ := NewTracer(
rep,
WithNoopSpan(false),
WithSampler(AlwaysSample),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need a test for never sample, that if the finished span handler needs all data it can still see it.

note in brave we have a flag on finished span handler which is always record or not (sampledLocal) you might need this to properly implement finished span handler.

@basvanbeek basvanbeek self-requested a review July 16, 2019 07:17
@basvanbeek
Copy link
Member

@jcchavezs thanks for taking this on. I will review end of the week.

@basvanbeek
Copy link
Member

After a quick glance, this is not ready yet. Promised my wife not to work the next few weeks so this will have to wait a little.

@db80
Copy link

db80 commented Jul 11, 2022

any news on this matter?

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

Successfully merging this pull request may close these issues.

Adds support for "finished span handler"
5 participants