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

Initial Commit #1

Merged
merged 2 commits into from
Jun 22, 2018
Merged

Initial Commit #1

merged 2 commits into from
Jun 22, 2018

Conversation

tylerbenson
Copy link
Owner

No description provided.

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.

left some things that jumped to brain!

build.gradle Outdated

dependencies {
compile group: 'io.zipkin.zipkin2', name: 'zipkin', version: '2.8.3'
compile group: 'io.zipkin.reporter2', name: 'zipkin-reporter', version: '2.6.0'

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

build.gradle Outdated
dependencies {
compile group: 'io.zipkin.zipkin2', name: 'zipkin', version: '2.8.3'
compile group: 'io.zipkin.reporter2', name: 'zipkin-reporter', version: '2.6.0'
compile group: 'org.msgpack', name: 'jackson-dataformat-msgpack', version: '0.8.16'

Choose a reason for hiding this comment

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

consider shading this to avoid library conflicts (since this is a 0.x library)

Copy link
Owner Author

Choose a reason for hiding this comment

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

not sure this is worth the effort. skipping for now.

build.gradle Outdated
compile group: 'io.zipkin.reporter2', name: 'zipkin-reporter', version: '2.6.0'
compile group: 'org.msgpack', name: 'jackson-dataformat-msgpack', version: '0.8.16'

compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.0'

Choose a reason for hiding this comment

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

consider killing this so that folks using log4j2 or otherwise don't get slf4j warnings only on account of this code. This implies using JUL, which has well understood limitations.

Copy link
Owner Author

Choose a reason for hiding this comment

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

private static final ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());

public DDApi(final String host, final int port) {
this(host, port, traceEndpointAvailable("http://" + host + ":" + port + TRACES_ENDPOINT_V4));

Choose a reason for hiding this comment

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

careful about I/O in constructors. usually it is nicer to be lazy about this, for example initializing it when the reporter thread is or on first call to flush (if external flushing is supported)

Copy link
Owner Author

Choose a reason for hiding this comment

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

the tradeoff is the endpoint URL can't be final. I kinda like the final... I understand it's less ideal to do this, but is it really a big deal?

Choose a reason for hiding this comment

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

yep it can crash apps during wiring just because zipkin isn't available. it is a well-known anti-pattern

Choose a reason for hiding this comment

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

incidentally, I can't find the anti-pattern note as it was years ago.. this one is a similar notice. https://github.com/google/guice/wiki/BeCarefulAboutIoInProviders

basically if you have something like this in spring, the whole app will crash. that's the part that is a big deal. That's why in zipkin we have this "Component" interface which defers i/o but lets things get wired together.

Anyway, you can still do this, just make a disclaimer about it in javadoc about the risk

}
}

public void addResponseListener(final ResponseListener listener) {

Choose a reason for hiding this comment

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

consider nixing this as it is package private so people can't use it anyway.. makes the code smaller

Copy link
Owner Author

@tylerbenson tylerbenson Jun 22, 2018

Choose a reason for hiding this comment

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


This was a result of copy pasting from our repo where that was useful. Removed here since it isn't needed.

trace = previousTrace != null ? previousTrace : trace; // Handles race condition

trace.spans.add(new DDMappingSpan(span));
if (span.kind() == Span.Kind.SERVER

Choose a reason for hiding this comment

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

needs a comment

Copy link
Owner Author

Choose a reason for hiding this comment

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

public static final long FLUSH_DELAY = TimeUnit.SECONDS.toMillis(1);

private final Queue<List<DDMappingSpan>> reportingTraces;
private final Map<String, PendingTrace> pendingTraces = new ConcurrentHashMap<>();

Choose a reason for hiding this comment

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

this can potentially OOM on backlog. consider what to do about that (either don't use CHM or use some other sort of means to have an absolute limit)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Growth is somewhat time constrained. I've documented this potential issue in the class comment.

return System.nanoTime();
}

private class PendingTrace {

Choose a reason for hiding this comment

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

static the things that don't need to be instance

Copy link
Owner Author

Choose a reason for hiding this comment

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

This is non-static because nanoTime is overridden in the tests to provide specific values.

target = new MapPropertySource(PROPERTY_SOURCE_NAME, new HashMap<>());
}

target.getSource().put("spring.sleuth.supports-join", false);

Choose a reason for hiding this comment

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

maybe you can also override the traceId128 thing I suppose. This won't always work, but anyway think about it..

Copy link
Owner Author

Choose a reason for hiding this comment

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

Not sure what you mean...

Choose a reason for hiding this comment

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

does DD expect 128bit trace IDs? If so, there's a similar property for that

Copy link
Owner Author

Choose a reason for hiding this comment

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

DD only uses 64 bit trace/span id's.

// from configuring a bean with the same name.
@Bean
public Reporter<Span> reporter() {
return new DatadogReporter();

Choose a reason for hiding this comment

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

here's where builder would be helpful as some properties can be set in spring and mapped to builder methods here.

@codefromthecrypt
Copy link

codefromthecrypt commented Jun 22, 2018 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.

coolio

@tylerbenson tylerbenson merged commit 264d4d5 into master Jun 22, 2018
@tylerbenson tylerbenson deleted the initial-commit branch June 22, 2018 07:56
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.

2 participants