Class JsonSerializer
- java.lang.Object
-
- io.opentelemetry.exporter.internal.marshal.Serializer
-
- io.opentelemetry.exporter.internal.marshal.JsonSerializer
-
- All Implemented Interfaces:
java.lang.AutoCloseable
final class JsonSerializer extends Serializer
-
-
Field Summary
Fields Modifier and Type Field Description private com.fasterxml.jackson.core.JsonGenerator
generator
private static com.fasterxml.jackson.core.JsonFactory
JSON_FACTORY
-
Constructor Summary
Constructors Constructor Description JsonSerializer(com.fasterxml.jackson.core.JsonGenerator generator)
JsonSerializer(java.io.OutputStream output)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
serializeRepeatedMessage(ProtoFieldInfo field, Marshaler[] repeatedMessage)
Serializesrepeated message
field.void
serializeRepeatedMessage(ProtoFieldInfo field, java.util.List<? extends Marshaler> repeatedMessage)
Serializesrepeated message
field.<T> void
serializeRepeatedMessageWithContext(ProtoFieldInfo field, java.util.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, java.nio.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
writeEndMessage()
protected void
writeEndRepeated()
Writes end of repeated messages.protected void
writeEndRepeatedElement()
Writes end of a repeated message element.protected void
writeEndRepeatedPrimitive()
protected void
writeEndRepeatedVarint()
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, java.lang.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, java.lang.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, java.lang.String string, int utf8Length, MarshalerContext context)
protected void
writeTraceId(ProtoFieldInfo field, java.lang.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
-
-
-
-
Method Detail
-
writeTraceId
protected void writeTraceId(ProtoFieldInfo field, java.lang.String traceId) throws java.io.IOException
- Specified by:
writeTraceId
in classSerializer
- Throws:
java.io.IOException
-
writeSpanId
protected void writeSpanId(ProtoFieldInfo field, java.lang.String spanId) throws java.io.IOException
- Specified by:
writeSpanId
in classSerializer
- Throws:
java.io.IOException
-
writeBool
public void writeBool(ProtoFieldInfo field, boolean value) throws java.io.IOException
Description copied from class:Serializer
Writes a protobufbool
field, even if it matches the default value.- Specified by:
writeBool
in classSerializer
- Throws:
java.io.IOException
-
writeEnum
protected void writeEnum(ProtoFieldInfo field, ProtoEnumInfo enumValue) throws java.io.IOException
- Specified by:
writeEnum
in classSerializer
- Throws:
java.io.IOException
-
writeUint32
protected void writeUint32(ProtoFieldInfo field, int value) throws java.io.IOException
- Specified by:
writeUint32
in classSerializer
- Throws:
java.io.IOException
-
writeSInt32
protected void writeSInt32(ProtoFieldInfo field, int value) throws java.io.IOException
- Specified by:
writeSInt32
in classSerializer
- Throws:
java.io.IOException
-
writeint32
protected void writeint32(ProtoFieldInfo field, int value) throws java.io.IOException
- Specified by:
writeint32
in classSerializer
- Throws:
java.io.IOException
-
writeInt64
public void writeInt64(ProtoFieldInfo field, long value) throws java.io.IOException
Description copied from class:Serializer
Writes a protobufint64
field, even if it matches the default value.- Specified by:
writeInt64
in classSerializer
- Throws:
java.io.IOException
-
writeFixed64
protected void writeFixed64(ProtoFieldInfo field, long value) throws java.io.IOException
- Specified by:
writeFixed64
in classSerializer
- Throws:
java.io.IOException
-
writeFixed64Value
protected void writeFixed64Value(long value) throws java.io.IOException
- Specified by:
writeFixed64Value
in classSerializer
- Throws:
java.io.IOException
-
writeUInt64Value
protected void writeUInt64Value(long value) throws java.io.IOException
- Specified by:
writeUInt64Value
in classSerializer
- Throws:
java.io.IOException
-
writeUInt64
public void writeUInt64(ProtoFieldInfo field, long value) throws java.io.IOException
Description copied from class:Serializer
Writes a protobufuint64
field, even if it matches the default value.- Specified by:
writeUInt64
in classSerializer
- Throws:
java.io.IOException
-
writeFixed32
protected void writeFixed32(ProtoFieldInfo field, int value) throws java.io.IOException
- Specified by:
writeFixed32
in classSerializer
- Throws:
java.io.IOException
-
writeDouble
public void writeDouble(ProtoFieldInfo field, double value) throws java.io.IOException
Description copied from class:Serializer
Writes a protobufdouble
field, even if it matches the default value.- Specified by:
writeDouble
in classSerializer
- Throws:
java.io.IOException
-
writeDoubleValue
protected void writeDoubleValue(double value) throws java.io.IOException
- Specified by:
writeDoubleValue
in classSerializer
- Throws:
java.io.IOException
-
writeString
public void writeString(ProtoFieldInfo field, byte[] utf8Bytes) throws java.io.IOException
Description copied from class:Serializer
Writes a protobufstring
field, even if it matches the default value.- Specified by:
writeString
in classSerializer
- Throws:
java.io.IOException
-
writeString
public void writeString(ProtoFieldInfo field, java.lang.String string, int utf8Length, MarshalerContext context) throws java.io.IOException
- Specified by:
writeString
in classSerializer
- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(ProtoFieldInfo field, byte[] value) throws java.io.IOException
- Specified by:
writeBytes
in classSerializer
- Throws:
java.io.IOException
-
writeByteBuffer
public void writeByteBuffer(ProtoFieldInfo field, java.nio.ByteBuffer value) throws java.io.IOException
- Specified by:
writeByteBuffer
in classSerializer
- Throws:
java.io.IOException
-
writeStartMessage
protected void writeStartMessage(ProtoFieldInfo field, int protoMessageSize) throws java.io.IOException
- Specified by:
writeStartMessage
in classSerializer
- Throws:
java.io.IOException
-
writeEndMessage
protected void writeEndMessage() throws java.io.IOException
- Specified by:
writeEndMessage
in classSerializer
- Throws:
java.io.IOException
-
writeStartRepeatedPrimitive
protected void writeStartRepeatedPrimitive(ProtoFieldInfo field, int protoSizePerElement, int numElements) throws java.io.IOException
- Specified by:
writeStartRepeatedPrimitive
in classSerializer
- Throws:
java.io.IOException
-
writeEndRepeatedPrimitive
protected void writeEndRepeatedPrimitive() throws java.io.IOException
- Specified by:
writeEndRepeatedPrimitive
in classSerializer
- Throws:
java.io.IOException
-
writeStartRepeatedVarint
protected void writeStartRepeatedVarint(ProtoFieldInfo field, int payloadSize) throws java.io.IOException
- Specified by:
writeStartRepeatedVarint
in classSerializer
- Throws:
java.io.IOException
-
writeEndRepeatedVarint
protected void writeEndRepeatedVarint() throws java.io.IOException
- Specified by:
writeEndRepeatedVarint
in classSerializer
- Throws:
java.io.IOException
-
serializeRepeatedMessage
public void serializeRepeatedMessage(ProtoFieldInfo field, Marshaler[] repeatedMessage) throws java.io.IOException
Description copied from class:Serializer
Serializesrepeated message
field.- Specified by:
serializeRepeatedMessage
in classSerializer
- Throws:
java.io.IOException
-
serializeRepeatedMessage
public void serializeRepeatedMessage(ProtoFieldInfo field, java.util.List<? extends Marshaler> repeatedMessage) throws java.io.IOException
Description copied from class:Serializer
Serializesrepeated message
field.- Specified by:
serializeRepeatedMessage
in classSerializer
- Throws:
java.io.IOException
-
serializeRepeatedMessageWithContext
public <T> void serializeRepeatedMessageWithContext(ProtoFieldInfo field, java.util.List<? extends T> messages, StatelessMarshaler<T> marshaler, MarshalerContext context) throws java.io.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:
java.io.IOException
-
writeStartRepeated
protected void writeStartRepeated(ProtoFieldInfo field) throws java.io.IOException
Description copied from class:Serializer
Writes start of repeated messages.- Specified by:
writeStartRepeated
in classSerializer
- Throws:
java.io.IOException
-
writeEndRepeated
protected void writeEndRepeated() throws java.io.IOException
Description copied from class:Serializer
Writes end of repeated messages.- Specified by:
writeEndRepeated
in classSerializer
- Throws:
java.io.IOException
-
writeStartRepeatedElement
protected void writeStartRepeatedElement(ProtoFieldInfo field, int protoMessageSize) throws java.io.IOException
Description copied from class:Serializer
Writes start of a repeated message element.- Specified by:
writeStartRepeatedElement
in classSerializer
- Throws:
java.io.IOException
-
writeEndRepeatedElement
protected void writeEndRepeatedElement() throws java.io.IOException
Description copied from class:Serializer
Writes end of a repeated message element.- Specified by:
writeEndRepeatedElement
in classSerializer
- Throws:
java.io.IOException
-
writeMessageValue
void writeMessageValue(Marshaler message) throws java.io.IOException
- Throws:
java.io.IOException
-
writeSerializedMessage
public void writeSerializedMessage(byte[] protoSerialized, java.lang.String jsonSerialized) throws java.io.IOException
Description copied from class:Serializer
Writes the value for a message field that has been pre-serialized.- Specified by:
writeSerializedMessage
in classSerializer
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in classSerializer
- Throws:
java.io.IOException
-
-