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
PAYARA-2547 Implement MicroProfile OpenTracing 1.0 #2776
Merged
Pandrex247
merged 27 commits into
payara:master
from
Pandrex247:PAYARA-2547-Implement-MicroProfile-OpenTracing-1.0
May 29, 2018
Merged
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
0af6260
PAYARA-2547 Initial implementation - No MP or injectable tracer
Pandrex247 d2d6800
PAYARA-2547 Remove old traced annotation
Pandrex247 6a69dc6
PAYARA-2547 Missed API
Pandrex247 7ff8e1d
PAYARA-2547 Add mock tracer
Pandrex247 462207d
PAYARA-2547 Some fixes
Pandrex247 ce019cb
PAYARA-2547 Remove old container tracing, and add exception mapper
Pandrex247 b000ed6
PAYARA-2547 Remove import
Pandrex247 60199fb
PAYARA-2547 Switch order and add span error logs
Pandrex247 f7783ae
PAYARA-2547 Remove junk, update jsonb, and fix mocktracer deactivation
Pandrex247 c657fb2
PAYARA-2547 Fix internal deactivation
Pandrex247 1084d1d
PAYARA-2547 Better error handling
Pandrex247 d6659be
PAYARA-2547 Remove junk
Pandrex247 0544e3b
PAYARA-2547 Change to use inheritable thread local
Pandrex247 f3adc53
PAYARA-2547 Inheritable thread local doesn't work, revert
Pandrex247 776e9a8
PAYARA-2547 Switch to using decorated jaxrs client - passing TCK
Pandrex247 01a4be7
PAYARA-2547 Add to embedded
Pandrex247 964cec8
PAYARA-2547 Add comments, Javadoc, and do some cleanup
Pandrex247 660ba80
PAYARA-2547 Remove swap file, and add concrete yasson version
Pandrex247 347d594
PAYARA-2547 Revert NetBeans formatting
Pandrex247 6ff731a
PAYARA-2547 Remove vestiges of old requesttracing api
Pandrex247 80d9df4
PAYARA-2547 Remove NetBeans formatting and changes that should be in …
Pandrex247 1b9ac3b
PAYARA-2547 Further redaction of things that shouldn't be in this PR
Pandrex247 54df4fa
PAYARA-2547 Correct some time conversions and settings to prevent a null
Pandrex247 47ee92f
Merge branch 'master' into PAYARA-2547-Implement-MicroProfile-OpenTra…
Pandrex247 b435892
PAYARA-2547 Dodgy fix for Jaxrs fileupload test
Pandrex247 5482134
Merge branch 'PAYARA-2547-Implement-MicroProfile-OpenTracing-1.0' of …
Pandrex247 3bd9ae0
PAYARA-2547 Extra javadoc
Pandrex247 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,43 +86,94 @@ public void addEvent(RequestTraceSpan span) { | |
if (null != span.getEventType()) { | ||
switch (span.getEventType()) { | ||
case TRACE_START: | ||
trace.clear(); | ||
startTime = span.getStartInstant(); | ||
trace.add(span); | ||
started = true; | ||
completed = false; | ||
handleTraceStart(span); | ||
break; | ||
case PROPAGATED_TRACE: | ||
trace.clear(); | ||
startTime = span.getStartInstant(); | ||
trace.add(span); | ||
started = true; | ||
completed = false; | ||
handlePropagatedTrace(span); | ||
break; | ||
case REQUEST_EVENT: { | ||
if (!started) { | ||
return; | ||
} | ||
RequestTraceSpan rootSpan = trace.getFirst(); | ||
span.setTraceId(rootSpan.getTraceId()); | ||
span.setSpanDuration(span.getStartInstant().until(Instant.now(), ChronoUnit.NANOS)); | ||
span.setTraceEndTime(Instant.now()); | ||
trace.add(span); | ||
handleRequestEvent(span); | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public void endTrace() { | ||
|
||
public void addEvent(RequestTraceSpan span, long timestampMillis) { | ||
// Do not add trace events if completed | ||
if (completed | ||
&& span.getEventType() != TRACE_START | ||
&& span.getEventType() != PROPAGATED_TRACE) { | ||
return; | ||
} | ||
|
||
if (null != span.getEventType()) { | ||
switch (span.getEventType()) { | ||
case TRACE_START: | ||
handleTraceStart(span); | ||
break; | ||
case PROPAGATED_TRACE: | ||
handlePropagatedTrace(span); | ||
break; | ||
case REQUEST_EVENT: { | ||
handleRequestEvent(span, timestampMillis); | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
|
||
private void handleTraceStart(RequestTraceSpan span) { | ||
trace.clear(); | ||
startTime = span.getStartInstant(); | ||
trace.add(span); | ||
started = true; | ||
completed = false; | ||
} | ||
|
||
private void handlePropagatedTrace(RequestTraceSpan span) { | ||
trace.clear(); | ||
startTime = span.getStartInstant(); | ||
trace.add(span); | ||
started = true; | ||
completed = false; | ||
} | ||
|
||
private void handleRequestEvent(RequestTraceSpan span) { | ||
if (!started) { | ||
return; | ||
} | ||
|
||
Collections.sort(trace); | ||
RequestTraceSpan rootSpan = trace.getFirst(); | ||
span.setTraceId(rootSpan.getTraceId()); | ||
span.setSpanDuration(span.getStartInstant().until(Instant.now(), ChronoUnit.NANOS)); | ||
span.setTraceEndTime(Instant.now()); | ||
trace.add(span); | ||
} | ||
|
||
private void handleRequestEvent(RequestTraceSpan span, long timestampMillis) { | ||
if (!started) { | ||
return; | ||
} | ||
|
||
RequestTraceSpan rootSpan = trace.getFirst(); | ||
span.setTraceId(rootSpan.getTraceId()); | ||
span.setSpanDuration(span.getStartInstant().until(Instant.ofEpochMilli(timestampMillis), ChronoUnit.NANOS)); | ||
span.setTraceEndTime(Instant.ofEpochMilli(timestampMillis)); | ||
trace.add(span); | ||
} | ||
|
||
public void endTrace() { | ||
if (!started) { | ||
return; | ||
} | ||
|
||
Collections.sort(trace); | ||
|
||
RequestTraceSpan startSpan = trace.getFirst(); | ||
endTime = Instant.now(); | ||
startSpan.setSpanDuration(startTime.until(endTime, ChronoUnit.NANOS)); | ||
|
@@ -171,16 +222,16 @@ public boolean isStarted() { | |
|
||
/** | ||
* Returns a list of all the events that make up the trace. | ||
* @return | ||
* @return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be corrected to be described in the |
||
*/ | ||
public LinkedList<RequestTraceSpan> getTraceSpans() { | ||
return trace; | ||
} | ||
|
||
/** | ||
* Gets the Instant when the span was started | ||
* Gets the Instant when the span was started | ||
* See {@link java.time.Instant#now()} for how this time is generated. | ||
* @return | ||
* @return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
*/ | ||
public Instant getStartTime() { | ||
return startTime; | ||
|
@@ -250,8 +301,8 @@ private void assignReferences() { | |
if (trace.indexOf(span) != 0) { | ||
RequestTraceSpan bestMatchingParent = null; | ||
for (RequestTraceSpan comparisonSpan : trace) { | ||
if (span.getTimeOccured() > comparisonSpan.getTimeOccured() && | ||
span.getTraceEndTime().compareTo(comparisonSpan.getTraceEndTime()) < 0) { | ||
if (span.getTimeOccured() > comparisonSpan.getTimeOccured() | ||
&& span.getTraceEndTime().compareTo(comparisonSpan.getTraceEndTime()) < 0) { | ||
if (bestMatchingParent == null) { | ||
bestMatchingParent = comparisonSpan; | ||
} else { | ||
|
@@ -291,8 +342,8 @@ public boolean equals(Object o) { | |
|
||
RequestTrace that = (RequestTrace) o; | ||
|
||
return elapsedTime == that.elapsedTime && (this.toString() != null ? | ||
this.toString().equals(that.toString()) : that.toString() == null); | ||
return elapsedTime == that.elapsedTime && (this.toString() != null | ||
? this.toString().equals(that.toString()) : that.toString() == null); | ||
} | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the first function call the overloaded one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not straight-forwardly as you'd lose the precision of
nanoTime
converting to milliseconds.