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

Add TracingTimer #207

Closed
wants to merge 2 commits into from
Closed

Add TracingTimer #207

wants to merge 2 commits into from

Conversation

checketts
Copy link
Contributor

Alternative solution to #28

This creates a TracingTimer that could be used to automatically generate tracing spans.

Instead of instrumenting at the registry level, I wrap the Timer that is returned by the register call.

FYI @adriancole

} catch (InterruptedException e) {
e.printStackTrace();
}
TracingTimer.builder("outerTimer", tracer)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Usage example here


@Bean
public Tracer tracer() {
Tracer tracer = new com.uber.jaeger.Configuration(

Choose a reason for hiding this comment

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

why do you need to use uber's tracer.. I thought opentracing has a test variant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is in the samples and won't be checked in long term.

It is essentially a spring boot app that I run to play around and explore. Thanks for the point about using the test variant in the unit tests.

I left it in the PR to demonstrate if anyone wanted to check it out and try running it.

@codefromthecrypt
Copy link

codefromthecrypt commented Nov 12, 2017 via email

@checketts checketts force-pushed the tracing-timer branch 2 times, most recently from 2499686 to 81f39a2 Compare November 12, 2017 05:40
@checketts
Copy link
Contributor Author

Removed temp code. Added in correct unit test

import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;

public class TracingTimer implements Timer{
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps OpenTracingTimer is a better name as it is more specific. Users who do tracing and are interested in this concept but aren't using OpenTracing might be confused by the current name.

}

@Override
public Timer register(MeterRegistry registry) {
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason we can't return the more specific type TracerTimer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I had a flashback of Java 4 not supporting covariant return types.

@jkschneider
Copy link
Contributor

jkschneider commented Nov 13, 2017

@adriancole I'm trying to understand a few comments from the earlier incarnation of this PR (#206).

I guess my feedback is this is a good example of why census has tracing apis separate from metrics apis. You don't get into the tagging trouble as you can access propagated tags independently from metrics or tracing. There's also a data model which means you can derive metrics later and forward them to micrometer that way. http://opencensus.io/

I'm comfortable with an optional dependency that provides opentracing support and also provide opencensus support separately -- all in the spirit of there's no need for Micrometer to pick winners. That said, I don't know enough about the tracing world to know: how entrenched is opentracing even if it is objectively lacking in some way? Is long-term support of it worthwhile?

Both opentracing and opencensus are in 0.x releases, implying continued API instability. If we do support one or both, it would have to be clear that it is incubating or experimental support. Spring's BOM-driven model makes it less than obvious how to pick up new dependencies, so even if we do releases of Micrometer between releases of Boot, it will be hard to propagate it. This isn't a "no", just weighs on me a bit.

You don't get into the tagging trouble as you can access propagated tags independently from metrics or tracing.

What is the tagging trouble you are referring to?

@@ -36,6 +36,11 @@ dependencies {

compile 'com.squareup.okhttp3:okhttp:3.9.0',optional

//tracing
compile 'io.opentracing:opentracing-api:0.30.0', optional
Copy link
Contributor

Choose a reason for hiding this comment

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

re: @adriancole earlier comment that 0.31.0 has a breaking API change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just upgrade to 0.31.0-RC1 and it does break the API I was using. Should I program against the RC? It appears the Scope API is the way forward (and matches the OpenCensus examples I looked at)

Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't know. Let's hang tight and wait for Adrian's input.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR (opentracing/opentracing-java#189) covers the changes. Looks like they will include a backwards compatible shim. So coding against 0.30.0 is probably the right decision. But I agree that @adriancole 's input will be good.

@codefromthecrypt
Copy link

codefromthecrypt commented Nov 14, 2017 via email

@codefromthecrypt
Copy link

codefromthecrypt commented Nov 14, 2017 via email

Copy link

@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.

Seems very odd to me that this code isn't in a contrib module until such time as the api is stable. We are basically being asked to trust a stability statement of an api with a very poor compatibility track record and no representation from micrometer.

Feel free to merge this anyway, but understand that this is adding a compile step and drift, and as soon as a change is made you'll have to do a release in micrometer.

Very odd

@jkschneider
Copy link
Contributor

jkschneider commented Nov 14, 2017

Seems very odd to me that this code isn't in a contrib module

I think this should be in a contrib module. Probably in a separate github repo in fact.

I want to avoid the explosion of dependencies that something like Prometheus has as I believe there is a discoverability problem inherent in that. So I'm comfortable having optional deps on libraries where drift is unlikely (e.g. Guava cache). But a pre-1.0 library with demonstrated churn is not a good fit for core.

@shakuzen
Copy link
Member

Has it been considered to ask the OpenTracing Java maintainers if they'd be interested in hosting this code in their library or org? It would seem easier for them to maintain it and keep it in sync with their API, as the assumption is that micrometer's API is going to be more stable.

@jkschneider
Copy link
Contributor

jkschneider commented Nov 14, 2017

Good point @shakuzen. We'll be committed to 3 year support of the 1.0 line.

@checketts
Copy link
Contributor Author

I'm totally fine with this code being hosted elsewhere. The one finding I wanted to expose pre-1.0 is changing the visibility of the Timer.Builder so it can be sub-classes/extended as in this usecase, allowing extensions like this to be possible.

If that isn't desire-able, then I could investigate based on that feedback.

I'm going to refactor this into a separate package to see if there are other visibility issues that need resolution. (Or move it to a contrib module if that exists)

@codefromthecrypt
Copy link

codefromthecrypt commented Nov 14, 2017 via email

@@ -143,7 +143,7 @@ static Builder builder(String name) {
private String description;
private final HistogramConfig.Builder histogramConfigBuilder;

private Builder(String name) {
protected Builder(String name) {
Copy link
Contributor Author

@checketts checketts Dec 1, 2017

Choose a reason for hiding this comment

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

@jkschneider This single line change is the only really 'required' change in Micrometer that will allow creating the other Tracing timer classes in other repos. I could remove the rest of the PR if needed.

I would love to leave the Opentracing/OpenCensus implementations in Micrometer as Optional deps. I did research and the breaking API change that Adrian brought up will be properly shimmed, and should actually behave as a deprecation for a good while.

Alternatively I could add an abstraction so the Tracer is an interface that could be implemented with a few lines of code that is added to a typical timer.

@jkschneider
Copy link
Contributor

From my understanding, we are thinking that this pursuit should be external to micrometer core?

@jkschneider jkschneider closed this Sep 5, 2018
@checketts
Copy link
Contributor Author

Yes. This PR was just exploring to ensure the underlying timer was extensible enough to allow the user to extend it. If we could make the builder protected then that would allow a user to subclass Timer and make their own TracingTimer. I think closing this for now is fine.

@jkschneider jkschneider removed this from the 1.1.0-rc.1 milestone Oct 29, 2018
@jkschneider jkschneider deleted the tracing-timer branch January 7, 2019 15:01
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.

4 participants