public class JsonMarshaller extends Object implements Marshaller
The content can also be compressed with GZIPOutputStream
.
Marshaller.UncloseableOutputStream
Modifier and Type | Field and Description |
---|---|
static String |
BREADCRUMBS
List of breadcrumbs for this event.
|
static String |
CHECKSUM
Checksum for the event, allowing to group events with a similar checksum.
|
static String |
CONTEXTS
Map of map of contexts for this event.
|
static String |
CULPRIT
Function call which was the primary perpetrator of this event.
|
static int |
DEFAULT_MAX_MESSAGE_LENGTH
Default maximum length for a message.
|
static String |
DIST
Identifies the the distribution of the application.
|
static String |
ENVIRONMENT
Identifies the environment the application is running in.
|
static String |
EVENT_ID
Hexadecimal string representing a uuid4 value.
|
static String |
EXTRA
An arbitrary mapping of additional metadata to store with the event.
|
static String |
FINGERPRINT
Event fingerprint, a list of strings used to dictate the deduplicating for this event.
|
static String |
LEVEL
The record severity.
|
static String |
LOGGER
The name of the logger which created the record.
|
static String |
MESSAGE
User-readable representation of this event.
|
static String |
MODULES
A list of relevant modules and their versions.
|
static String |
PLATFORM
A string representing the platform the client is submitting from.
|
static String |
RELEASE
Identifies the the version of the application.
|
static String |
SDK
An object representing the SDK name and version.
|
static String |
SERVER_NAME
Identifies the host client from which the event was recorded.
|
static String |
TAGS
A map or list of tags for this event.
|
static String |
TIMESTAMP
Indicates when the logging record was created.
|
static String |
TRANSACTION
Name of the transaction that this event occurred inside of.
|
Constructor and Description |
---|
JsonMarshaller()
Create instance of JsonMarshaller with default message length.
|
JsonMarshaller(int maxMessageLength)
Create instance of JsonMarshaller with provided maximum length of the messages.
|
Modifier and Type | Method and Description |
---|---|
<T extends SentryInterface,F extends T> |
addInterfaceBinding(Class<F> sentryInterfaceClass,
InterfaceBinding<T> binding)
Add an interface binding to send a type of
SentryInterface through a JSON stream. |
protected com.fasterxml.jackson.core.JsonGenerator |
createJsonGenerator(OutputStream destination)
Creates the
JsonGenerator used to marshall to json. |
String |
getContentEncoding()
Returns the HTTP Content-Encoding, if applicable, or null.
|
String |
getContentType()
Returns the HTTP Content-Type, if applicable, or null.
|
boolean |
isCompressed() |
void |
marshall(Event event,
OutputStream destination)
Serialises an event and sends it through an
OutputStream . |
void |
setCompression(boolean compression)
Enables the JSON compression with gzip.
|
public static final String EVENT_ID
public static final String MESSAGE
public static final String TIMESTAMP
public static final String LEVEL
public static final String LOGGER
public static final String PLATFORM
public static final String CULPRIT
public static final String TRANSACTION
public static final String SDK
public static final String TAGS
public static final String BREADCRUMBS
public static final String CONTEXTS
public static final String SERVER_NAME
public static final String RELEASE
public static final String DIST
public static final String ENVIRONMENT
public static final String FINGERPRINT
public static final String MODULES
public static final String EXTRA
public static final String CHECKSUM
public static final int DEFAULT_MAX_MESSAGE_LENGTH
public JsonMarshaller()
public JsonMarshaller(int maxMessageLength)
maxMessageLength
- the maximum message lengthpublic void marshall(Event event, OutputStream destination) throws IOException
Marshaller
OutputStream
.
The marshaller should not close the given stream, use Marshaller.UncloseableOutputStream
to prevent automatic calls
to OutputStream.close()
.
marshall
in interface Marshaller
event
- event to serialise.destination
- destination stream.IOException
- on write errorprotected com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(OutputStream destination) throws IOException
JsonGenerator
used to marshall to json.
This method makes it easier to provide a custom implementation.destination
- used to read the contentIOException
- on error reading the streampublic String getContentType()
Marshaller
getContentType
in interface Marshaller
public String getContentEncoding()
Marshaller
getContentEncoding
in interface Marshaller
public <T extends SentryInterface,F extends T> void addInterfaceBinding(Class<F> sentryInterfaceClass, InterfaceBinding<T> binding)
SentryInterface
through a JSON stream.T
- Type of SentryInterface received by the InterfaceBinding.F
- Type of the interface stored in the event to send to the InterfaceBinding.sentryInterfaceClass
- Actual type of SentryInterface supported by the InterfaceBinding
binding
- InterfaceBinding converting SentryInterfaces of type sentryInterfaceClass
.public void setCompression(boolean compression)
compression
- state of the compression.public boolean isCompressed()
Copyright © 2012–2020. All rights reserved.