-
Notifications
You must be signed in to change notification settings - Fork 292
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 pending traces report in tracer flares #8053
Merged
+247
−14
Merged
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
39fd9dc
adding tracerflare.addtext
mhlidd 6663a16
adding class to handle tracerdump
mhlidd 0e10cda
updating flare to implement reporter and store only root spans
mhlidd 6e7fc17
updating PR comments
mhlidd de9165b
rebasing
mhlidd 23bc65a
changing getSpans header
mhlidd bf1763b
Adding DumpElement, DumpDrain, and DumpSupplier to extract PendingTraces
mhlidd 907a0aa
addressing PR comments
mhlidd c76ade1
limiting number of tracers in tracer flare and sorting by oldest first
mhlidd 5638d0c
removing unused log
mhlidd a0bd565
updating comparator
mhlidd 0008ad1
saving changes
mhlidd b6b7c0d
initial implementation of test
mhlidd b3e9048
updating test
mhlidd 713ccda
feat(core): Use prepare for flare to signal dump element
PerfectSlayer 0ee90c1
feat(core): Update test prevent the span to be written early
PerfectSlayer bc71dcf
fix(core): Fix tests
PerfectSlayer 60d08e7
fix(core): Reduce scope
PerfectSlayer 60bb162
fix(core): Revert drain limit
PerfectSlayer 3382b3d
feat(core): Refactor action elements
PerfectSlayer fbed357
adding support for json encoding of traces
mhlidd 1dee7f3
cleanup
mhlidd af57f32
renaming file
mhlidd e9eac71
making TraceDumpJsonExporter a Writer
mhlidd 9786fb5
nit changes
mhlidd 3d0e3f7
updating test to match changes
mhlidd b443ddd
addressing PR comments
mhlidd 3b1c41a
final unit tests changes
mhlidd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
60 changes: 60 additions & 0 deletions
60
dd-trace-core/src/main/java/datadog/trace/common/writer/TraceDumpJsonExporter.java
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package datadog.trace.common.writer; | ||
|
||
import com.squareup.moshi.JsonAdapter; | ||
import com.squareup.moshi.Moshi; | ||
import com.squareup.moshi.Types; | ||
import datadog.trace.api.flare.TracerFlare; | ||
import datadog.trace.core.DDSpan; | ||
import java.io.IOException; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.zip.ZipOutputStream; | ||
|
||
public class TraceDumpJsonExporter implements Writer { | ||
|
||
private static final JsonAdapter<Collection<DDSpan>> TRACE_ADAPTER = | ||
new Moshi.Builder() | ||
.add(DDSpanJsonAdapter.buildFactory(false)) | ||
.build() | ||
.adapter(Types.newParameterizedType(Collection.class, DDSpan.class)); | ||
private StringBuilder dumpText; | ||
private ZipOutputStream zip; | ||
|
||
public TraceDumpJsonExporter(ZipOutputStream zip) { | ||
this.zip = zip; | ||
dumpText = new StringBuilder(); | ||
} | ||
|
||
public void write(final Collection<DDSpan> trace) { | ||
dumpText.append(TRACE_ADAPTER.toJson(trace)); | ||
dumpText.append('\n'); | ||
} | ||
|
||
@Override | ||
public void write(List<DDSpan> trace) { | ||
// Do nothing | ||
} | ||
|
||
@Override | ||
public void start() { | ||
// do nothing | ||
} | ||
|
||
@Override | ||
public boolean flush() { | ||
try { | ||
TracerFlare.addText(zip, "pending_traces.txt", dumpText.toString()); | ||
} catch (IOException e) { | ||
// do nothing | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
// do nothing | ||
} | ||
|
||
@Override | ||
public void incrementDropCounts(int spanCount) {} | ||
} |
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
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.
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.
🟠 Code Quality Violation
StringBuilder can lead to memory leaks in long lasting classes (...read more)
StringBuffers and StringBuilders have the potential to grow significantly, which could lead to memory leaks if they are retained within objects with extended lifetimes.