-
Notifications
You must be signed in to change notification settings - Fork 336
Remove Jackson from dd-trace-ot #1185
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
101 changes: 101 additions & 0 deletions
101
dd-trace-ot/src/main/java/datadog/trace/common/serialization/FormatWriter.java
This file contains hidden or 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,101 @@ | ||
| package datadog.trace.common.serialization; | ||
|
|
||
| import datadog.opentracing.DDSpan; | ||
| import java.io.IOException; | ||
| import java.math.BigInteger; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public abstract class FormatWriter<DEST> { | ||
| public abstract void writeKey(String key, DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeListHeader(int size, DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeListFooter(DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeMapHeader(int size, DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeMapFooter(DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeString(String key, String value, DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeShort(String key, short value, DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeByte(String key, byte value, DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeInt(String key, int value, DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeLong(String key, long value, DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeFloat(String key, float value, DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeDouble(String key, double value, DEST destination) throws IOException; | ||
|
|
||
| public abstract void writeBigInteger(String key, BigInteger value, DEST destination) | ||
| throws IOException; | ||
|
|
||
| public void writeNumber(final String key, final Number value, final DEST destination) | ||
| throws IOException { | ||
| if (value instanceof Double) { | ||
| writeDouble(key, value.doubleValue(), destination); | ||
| } else if (value instanceof Long) { | ||
| writeLong(key, value.longValue(), destination); | ||
| } else if (value instanceof Integer) { | ||
| writeInt(key, value.intValue(), destination); | ||
| } else if (value instanceof Float) { | ||
| writeFloat(key, value.floatValue(), destination); | ||
| } else if (value instanceof Byte) { | ||
| writeByte(key, value.byteValue(), destination); | ||
| } else if (value instanceof Short) { | ||
| writeShort(key, value.shortValue(), destination); | ||
| } | ||
| } | ||
|
|
||
| public void writeNumberMap( | ||
| final String key, final Map<String, Number> value, final DEST destination) | ||
| throws IOException { | ||
| writeKey(key, destination); | ||
| writeMapHeader(value.size(), destination); | ||
| for (final Map.Entry<String, Number> entry : value.entrySet()) { | ||
| writeNumber(entry.getKey(), entry.getValue(), destination); | ||
| } | ||
| writeMapFooter(destination); | ||
| } | ||
|
|
||
| public void writeStringMap( | ||
| final String key, final Map<String, String> value, final DEST destination) | ||
| throws IOException { | ||
| writeKey(key, destination); | ||
| writeMapHeader(value.size(), destination); | ||
| for (final Map.Entry<String, String> entry : value.entrySet()) { | ||
| writeString(entry.getKey(), entry.getValue(), destination); | ||
| } | ||
| writeMapFooter(destination); | ||
| } | ||
|
|
||
| public void writeTrace(final List<DDSpan> trace, final DEST destination) throws IOException { | ||
| writeListHeader(trace.size(), destination); | ||
| for (final DDSpan span : trace) { | ||
| writeDDSpan(span, destination); | ||
| } | ||
| writeListFooter(destination); | ||
| } | ||
|
|
||
| public void writeDDSpan(final DDSpan span, final DEST destination) throws IOException { | ||
| // Some of the tests rely on the specific ordering here. | ||
| writeMapHeader(12, destination); // must match count below. | ||
| /* 1 */ writeString("service", span.getServiceName(), destination); | ||
| /* 2 */ writeString("name", span.getOperationName(), destination); | ||
| /* 3 */ writeString("resource", span.getResourceName(), destination); | ||
| /* 4 */ writeBigInteger("trace_id", span.getTraceId(), destination); | ||
| /* 5 */ writeBigInteger("span_id", span.getSpanId(), destination); | ||
| /* 6 */ writeBigInteger("parent_id", span.getParentId(), destination); | ||
| /* 7 */ writeLong("start", span.getStartTime(), destination); | ||
| /* 8 */ writeLong("duration", span.getDurationNano(), destination); | ||
| /* 9 */ writeString("type", span.getType(), destination); | ||
| /* 10 */ writeInt("error", span.getError(), destination); | ||
| /* 11 */ writeNumberMap("metrics", span.getMetrics(), destination); | ||
| /* 12 */ writeStringMap("meta", span.getMeta(), destination); | ||
| writeMapFooter(destination); | ||
| } | ||
| } | ||
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.
else with an exception for unsupported types?