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.JsonGeneratorgeneratorprivate static com.fasterxml.jackson.core.JsonFactoryJSON_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 voidclose()voidserializeRepeatedMessage(ProtoFieldInfo field, Marshaler[] repeatedMessage)Serializesrepeated messagefield.voidserializeRepeatedMessage(ProtoFieldInfo field, java.util.List<? extends Marshaler> repeatedMessage)Serializesrepeated messagefield.<T> voidserializeRepeatedMessageWithContext(ProtoFieldInfo field, java.util.List<? extends T> messages, StatelessMarshaler<T> marshaler, MarshalerContext context)Serializesrepeated messagefield.voidwriteBool(ProtoFieldInfo field, boolean value)Writes a protobufboolfield, even if it matches the default value.voidwriteByteBuffer(ProtoFieldInfo field, java.nio.ByteBuffer value)voidwriteBytes(ProtoFieldInfo field, byte[] value)voidwriteDouble(ProtoFieldInfo field, double value)Writes a protobufdoublefield, even if it matches the default value.protected voidwriteDoubleValue(double value)protected voidwriteEndMessage()protected voidwriteEndRepeated()Writes end of repeated messages.protected voidwriteEndRepeatedElement()Writes end of a repeated message element.protected voidwriteEndRepeatedPrimitive()protected voidwriteEndRepeatedVarint()protected voidwriteEnum(ProtoFieldInfo field, ProtoEnumInfo enumValue)protected voidwriteFixed32(ProtoFieldInfo field, int value)protected voidwriteFixed64(ProtoFieldInfo field, long value)protected voidwriteFixed64Value(long value)protected voidwriteint32(ProtoFieldInfo field, int value)voidwriteInt64(ProtoFieldInfo field, long value)Writes a protobufint64field, even if it matches the default value.(package private) voidwriteMessageValue(Marshaler message)voidwriteSerializedMessage(byte[] protoSerialized, java.lang.String jsonSerialized)Writes the value for a message field that has been pre-serialized.protected voidwriteSInt32(ProtoFieldInfo field, int value)protected voidwriteSpanId(ProtoFieldInfo field, java.lang.String spanId)protected voidwriteStartMessage(ProtoFieldInfo field, int protoMessageSize)protected voidwriteStartRepeated(ProtoFieldInfo field)Writes start of repeated messages.protected voidwriteStartRepeatedElement(ProtoFieldInfo field, int protoMessageSize)Writes start of a repeated message element.protected voidwriteStartRepeatedPrimitive(ProtoFieldInfo field, int protoSizePerElement, int numElements)protected voidwriteStartRepeatedVarint(ProtoFieldInfo field, int payloadSize)voidwriteString(ProtoFieldInfo field, byte[] utf8Bytes)Writes a protobufstringfield, even if it matches the default value.voidwriteString(ProtoFieldInfo field, java.lang.String string, int utf8Length, MarshalerContext context)protected voidwriteTraceId(ProtoFieldInfo field, java.lang.String traceId)protected voidwriteUint32(ProtoFieldInfo field, int value)voidwriteUInt64(ProtoFieldInfo field, long value)Writes a protobufuint64field, even if it matches the default value.protected voidwriteUInt64Value(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:
writeTraceIdin classSerializer- Throws:
java.io.IOException
-
writeSpanId
protected void writeSpanId(ProtoFieldInfo field, java.lang.String spanId) throws java.io.IOException
- Specified by:
writeSpanIdin classSerializer- Throws:
java.io.IOException
-
writeBool
public void writeBool(ProtoFieldInfo field, boolean value) throws java.io.IOException
Description copied from class:SerializerWrites a protobufboolfield, even if it matches the default value.- Specified by:
writeBoolin classSerializer- Throws:
java.io.IOException
-
writeEnum
protected void writeEnum(ProtoFieldInfo field, ProtoEnumInfo enumValue) throws java.io.IOException
- Specified by:
writeEnumin classSerializer- Throws:
java.io.IOException
-
writeUint32
protected void writeUint32(ProtoFieldInfo field, int value) throws java.io.IOException
- Specified by:
writeUint32in classSerializer- Throws:
java.io.IOException
-
writeSInt32
protected void writeSInt32(ProtoFieldInfo field, int value) throws java.io.IOException
- Specified by:
writeSInt32in classSerializer- Throws:
java.io.IOException
-
writeint32
protected void writeint32(ProtoFieldInfo field, int value) throws java.io.IOException
- Specified by:
writeint32in classSerializer- Throws:
java.io.IOException
-
writeInt64
public void writeInt64(ProtoFieldInfo field, long value) throws java.io.IOException
Description copied from class:SerializerWrites a protobufint64field, even if it matches the default value.- Specified by:
writeInt64in classSerializer- Throws:
java.io.IOException
-
writeFixed64
protected void writeFixed64(ProtoFieldInfo field, long value) throws java.io.IOException
- Specified by:
writeFixed64in classSerializer- Throws:
java.io.IOException
-
writeFixed64Value
protected void writeFixed64Value(long value) throws java.io.IOException- Specified by:
writeFixed64Valuein classSerializer- Throws:
java.io.IOException
-
writeUInt64Value
protected void writeUInt64Value(long value) throws java.io.IOException- Specified by:
writeUInt64Valuein classSerializer- Throws:
java.io.IOException
-
writeUInt64
public void writeUInt64(ProtoFieldInfo field, long value) throws java.io.IOException
Description copied from class:SerializerWrites a protobufuint64field, even if it matches the default value.- Specified by:
writeUInt64in classSerializer- Throws:
java.io.IOException
-
writeFixed32
protected void writeFixed32(ProtoFieldInfo field, int value) throws java.io.IOException
- Specified by:
writeFixed32in classSerializer- Throws:
java.io.IOException
-
writeDouble
public void writeDouble(ProtoFieldInfo field, double value) throws java.io.IOException
Description copied from class:SerializerWrites a protobufdoublefield, even if it matches the default value.- Specified by:
writeDoublein classSerializer- Throws:
java.io.IOException
-
writeDoubleValue
protected void writeDoubleValue(double value) throws java.io.IOException- Specified by:
writeDoubleValuein classSerializer- Throws:
java.io.IOException
-
writeString
public void writeString(ProtoFieldInfo field, byte[] utf8Bytes) throws java.io.IOException
Description copied from class:SerializerWrites a protobufstringfield, even if it matches the default value.- Specified by:
writeStringin 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:
writeStringin classSerializer- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(ProtoFieldInfo field, byte[] value) throws java.io.IOException
- Specified by:
writeBytesin classSerializer- Throws:
java.io.IOException
-
writeByteBuffer
public void writeByteBuffer(ProtoFieldInfo field, java.nio.ByteBuffer value) throws java.io.IOException
- Specified by:
writeByteBufferin classSerializer- Throws:
java.io.IOException
-
writeStartMessage
protected void writeStartMessage(ProtoFieldInfo field, int protoMessageSize) throws java.io.IOException
- Specified by:
writeStartMessagein classSerializer- Throws:
java.io.IOException
-
writeEndMessage
protected void writeEndMessage() throws java.io.IOException- Specified by:
writeEndMessagein classSerializer- Throws:
java.io.IOException
-
writeStartRepeatedPrimitive
protected void writeStartRepeatedPrimitive(ProtoFieldInfo field, int protoSizePerElement, int numElements) throws java.io.IOException
- Specified by:
writeStartRepeatedPrimitivein classSerializer- Throws:
java.io.IOException
-
writeEndRepeatedPrimitive
protected void writeEndRepeatedPrimitive() throws java.io.IOException- Specified by:
writeEndRepeatedPrimitivein classSerializer- Throws:
java.io.IOException
-
writeStartRepeatedVarint
protected void writeStartRepeatedVarint(ProtoFieldInfo field, int payloadSize) throws java.io.IOException
- Specified by:
writeStartRepeatedVarintin classSerializer- Throws:
java.io.IOException
-
writeEndRepeatedVarint
protected void writeEndRepeatedVarint() throws java.io.IOException- Specified by:
writeEndRepeatedVarintin classSerializer- Throws:
java.io.IOException
-
serializeRepeatedMessage
public void serializeRepeatedMessage(ProtoFieldInfo field, Marshaler[] repeatedMessage) throws java.io.IOException
Description copied from class:SerializerSerializesrepeated messagefield.- Specified by:
serializeRepeatedMessagein 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:SerializerSerializesrepeated messagefield.- Specified by:
serializeRepeatedMessagein 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:SerializerSerializesrepeated messagefield. This method reads elements from context, use together withStatelessMarshalerUtil.sizeRepeatedMessageWithContext(ProtoFieldInfo, List, StatelessMarshaler, MarshalerContext).- Specified by:
serializeRepeatedMessageWithContextin classSerializer- Throws:
java.io.IOException
-
writeStartRepeated
protected void writeStartRepeated(ProtoFieldInfo field) throws java.io.IOException
Description copied from class:SerializerWrites start of repeated messages.- Specified by:
writeStartRepeatedin classSerializer- Throws:
java.io.IOException
-
writeEndRepeated
protected void writeEndRepeated() throws java.io.IOExceptionDescription copied from class:SerializerWrites end of repeated messages.- Specified by:
writeEndRepeatedin classSerializer- Throws:
java.io.IOException
-
writeStartRepeatedElement
protected void writeStartRepeatedElement(ProtoFieldInfo field, int protoMessageSize) throws java.io.IOException
Description copied from class:SerializerWrites start of a repeated message element.- Specified by:
writeStartRepeatedElementin classSerializer- Throws:
java.io.IOException
-
writeEndRepeatedElement
protected void writeEndRepeatedElement() throws java.io.IOExceptionDescription copied from class:SerializerWrites end of a repeated message element.- Specified by:
writeEndRepeatedElementin 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.IOExceptionDescription copied from class:SerializerWrites the value for a message field that has been pre-serialized.- Specified by:
writeSerializedMessagein classSerializer- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein classSerializer- Throws:
java.io.IOException
-
-