Class JsonSerializer
java.lang.Object
io.opentelemetry.exporter.internal.marshal.Serializer
io.opentelemetry.exporter.internal.marshal.JsonSerializer
- All Implemented Interfaces:
AutoCloseable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.fasterxml.jackson.core.JsonGenerator
private static final com.fasterxml.jackson.core.JsonFactory
-
Constructor Summary
ConstructorsConstructorDescriptionJsonSerializer
(com.fasterxml.jackson.core.JsonGenerator generator) JsonSerializer
(OutputStream output) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
serializeRepeatedMessage
(ProtoFieldInfo field, Marshaler[] repeatedMessage) Serializesrepeated message
field.void
serializeRepeatedMessage
(ProtoFieldInfo field, List<? extends Marshaler> repeatedMessage) Serializesrepeated message
field.<T> void
serializeRepeatedMessageWithContext
(ProtoFieldInfo field, List<? extends T> messages, StatelessMarshaler<T> marshaler, MarshalerContext context) Serializesrepeated message
field.void
writeBool
(ProtoFieldInfo field, boolean value) Writes a protobufbool
field, even if it matches the default value.void
writeByteBuffer
(ProtoFieldInfo field, ByteBuffer value) void
writeBytes
(ProtoFieldInfo field, byte[] value) void
writeDouble
(ProtoFieldInfo field, double value) Writes a protobufdouble
field, even if it matches the default value.protected void
writeDoubleValue
(double value) protected void
protected void
Writes end of repeated messages.protected void
Writes end of a repeated message element.protected void
protected void
protected void
writeEnum
(ProtoFieldInfo field, ProtoEnumInfo enumValue) protected void
writeFixed32
(ProtoFieldInfo field, int value) protected void
writeFixed64
(ProtoFieldInfo field, long value) protected void
writeFixed64Value
(long value) protected void
writeint32
(ProtoFieldInfo field, int value) void
writeInt64
(ProtoFieldInfo field, long value) Writes a protobufint64
field, even if it matches the default value.(package private) void
writeMessageValue
(Marshaler message) void
writeSerializedMessage
(byte[] protoSerialized, String jsonSerialized) Writes the value for a message field that has been pre-serialized.protected void
writeSInt32
(ProtoFieldInfo field, int value) protected void
writeSpanId
(ProtoFieldInfo field, String spanId) protected void
writeStartMessage
(ProtoFieldInfo field, int protoMessageSize) protected void
writeStartRepeated
(ProtoFieldInfo field) Writes start of repeated messages.protected void
writeStartRepeatedElement
(ProtoFieldInfo field, int protoMessageSize) Writes start of a repeated message element.protected void
writeStartRepeatedPrimitive
(ProtoFieldInfo field, int protoSizePerElement, int numElements) protected void
writeStartRepeatedVarint
(ProtoFieldInfo field, int payloadSize) void
writeString
(ProtoFieldInfo field, byte[] utf8Bytes) Writes a protobufstring
field, even if it matches the default value.void
writeString
(ProtoFieldInfo field, String string, int utf8Length, MarshalerContext context) protected void
writeTraceId
(ProtoFieldInfo field, String traceId) protected void
writeUint32
(ProtoFieldInfo field, int value) void
writeUInt64
(ProtoFieldInfo field, long value) Writes a protobufuint64
field, even if it matches the default value.protected void
writeUInt64Value
(long value) Methods inherited from class io.opentelemetry.exporter.internal.marshal.Serializer
serializeBool, serializeByteAsFixed32, serializeByteBuffer, serializeBytes, serializeDouble, serializeDoubleOptional, serializeEnum, serializeFixed32, serializeFixed64, serializeFixed64Optional, serializeInt32, serializeInt64, serializeMessage, serializeMessageWithContext, serializeMessageWithContext, serializeRepeatedDouble, serializeRepeatedFixed64, serializeRepeatedFixed64, serializeRepeatedInt64, serializeRepeatedMessageWithContext, serializeRepeatedMessageWithContext, serializeRepeatedMessageWithContext, serializeRepeatedUInt64, serializeRepeatedUInt64, serializeRepeatedUInt64, serializeSInt32, serializeSpanId, serializeSpanId, serializeString, serializeStringWithContext, serializeTraceId, serializeTraceId, serializeUInt32, serializeUInt64, writeSpanId, writeTraceId
-
Field Details
-
JSON_FACTORY
private static final com.fasterxml.jackson.core.JsonFactory JSON_FACTORY -
generator
private final com.fasterxml.jackson.core.JsonGenerator generator
-
-
Constructor Details
-
JsonSerializer
JsonSerializer(OutputStream output) throws IOException - Throws:
IOException
-
JsonSerializer
JsonSerializer(com.fasterxml.jackson.core.JsonGenerator generator)
-
-
Method Details
-
writeTraceId
- Specified by:
writeTraceId
in classSerializer
- Throws:
IOException
-
writeSpanId
- Specified by:
writeSpanId
in classSerializer
- Throws:
IOException
-
writeBool
Description copied from class:Serializer
Writes a protobufbool
field, even if it matches the default value.- Specified by:
writeBool
in classSerializer
- Throws:
IOException
-
writeEnum
- Specified by:
writeEnum
in classSerializer
- Throws:
IOException
-
writeUint32
- Specified by:
writeUint32
in classSerializer
- Throws:
IOException
-
writeSInt32
- Specified by:
writeSInt32
in classSerializer
- Throws:
IOException
-
writeint32
- Specified by:
writeint32
in classSerializer
- Throws:
IOException
-
writeInt64
Description copied from class:Serializer
Writes a protobufint64
field, even if it matches the default value.- Specified by:
writeInt64
in classSerializer
- Throws:
IOException
-
writeFixed64
- Specified by:
writeFixed64
in classSerializer
- Throws:
IOException
-
writeFixed64Value
- Specified by:
writeFixed64Value
in classSerializer
- Throws:
IOException
-
writeUInt64Value
- Specified by:
writeUInt64Value
in classSerializer
- Throws:
IOException
-
writeUInt64
Description copied from class:Serializer
Writes a protobufuint64
field, even if it matches the default value.- Specified by:
writeUInt64
in classSerializer
- Throws:
IOException
-
writeFixed32
- Specified by:
writeFixed32
in classSerializer
- Throws:
IOException
-
writeDouble
Description copied from class:Serializer
Writes a protobufdouble
field, even if it matches the default value.- Specified by:
writeDouble
in classSerializer
- Throws:
IOException
-
writeDoubleValue
- Specified by:
writeDoubleValue
in classSerializer
- Throws:
IOException
-
writeString
Description copied from class:Serializer
Writes a protobufstring
field, even if it matches the default value.- Specified by:
writeString
in classSerializer
- Throws:
IOException
-
writeString
public void writeString(ProtoFieldInfo field, String string, int utf8Length, MarshalerContext context) throws IOException - Specified by:
writeString
in classSerializer
- Throws:
IOException
-
writeBytes
- Specified by:
writeBytes
in classSerializer
- Throws:
IOException
-
writeByteBuffer
- Specified by:
writeByteBuffer
in classSerializer
- Throws:
IOException
-
writeStartMessage
- Specified by:
writeStartMessage
in classSerializer
- Throws:
IOException
-
writeEndMessage
- Specified by:
writeEndMessage
in classSerializer
- Throws:
IOException
-
writeStartRepeatedPrimitive
protected void writeStartRepeatedPrimitive(ProtoFieldInfo field, int protoSizePerElement, int numElements) throws IOException - Specified by:
writeStartRepeatedPrimitive
in classSerializer
- Throws:
IOException
-
writeEndRepeatedPrimitive
- Specified by:
writeEndRepeatedPrimitive
in classSerializer
- Throws:
IOException
-
writeStartRepeatedVarint
- Specified by:
writeStartRepeatedVarint
in classSerializer
- Throws:
IOException
-
writeEndRepeatedVarint
- Specified by:
writeEndRepeatedVarint
in classSerializer
- Throws:
IOException
-
serializeRepeatedMessage
public void serializeRepeatedMessage(ProtoFieldInfo field, Marshaler[] repeatedMessage) throws IOException Description copied from class:Serializer
Serializesrepeated message
field.- Specified by:
serializeRepeatedMessage
in classSerializer
- Throws:
IOException
-
serializeRepeatedMessage
public void serializeRepeatedMessage(ProtoFieldInfo field, List<? extends Marshaler> repeatedMessage) throws IOException Description copied from class:Serializer
Serializesrepeated message
field.- Specified by:
serializeRepeatedMessage
in classSerializer
- Throws:
IOException
-
serializeRepeatedMessageWithContext
public <T> void serializeRepeatedMessageWithContext(ProtoFieldInfo field, List<? extends T> messages, StatelessMarshaler<T> marshaler, MarshalerContext context) throws IOException Description copied from class:Serializer
Serializesrepeated message
field. This method reads elements from context, use together withStatelessMarshalerUtil.sizeRepeatedMessageWithContext(ProtoFieldInfo, List, StatelessMarshaler, MarshalerContext)
.- Specified by:
serializeRepeatedMessageWithContext
in classSerializer
- Throws:
IOException
-
writeStartRepeated
Description copied from class:Serializer
Writes start of repeated messages.- Specified by:
writeStartRepeated
in classSerializer
- Throws:
IOException
-
writeEndRepeated
Description copied from class:Serializer
Writes end of repeated messages.- Specified by:
writeEndRepeated
in classSerializer
- Throws:
IOException
-
writeStartRepeatedElement
protected void writeStartRepeatedElement(ProtoFieldInfo field, int protoMessageSize) throws IOException Description copied from class:Serializer
Writes start of a repeated message element.- Specified by:
writeStartRepeatedElement
in classSerializer
- Throws:
IOException
-
writeEndRepeatedElement
Description copied from class:Serializer
Writes end of a repeated message element.- Specified by:
writeEndRepeatedElement
in classSerializer
- Throws:
IOException
-
writeMessageValue
- Throws:
IOException
-
writeSerializedMessage
public void writeSerializedMessage(byte[] protoSerialized, String jsonSerialized) throws IOException Description copied from class:Serializer
Writes the value for a message field that has been pre-serialized.- Specified by:
writeSerializedMessage
in classSerializer
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in classSerializer
- Throws:
IOException
-