protected String serializeEnvelope(Envelope envelope) { try { if (envelope != null) { StringWriter stringWriter = new StringWriter(); envelope.serialize(stringWriter); return stringWriter.toString(); } InternalLogging.warn( TAG, "Envelop wasn't empty but failed to serialize anything, returning null"); return null; } catch (IOException e) { InternalLogging.warn(TAG, "Failed to save data with exception: " + e.toString()); return null; } }
/** * Records the passed in data. * * @param data the base object to record */ public void log(Base data, Map<String, String> tags) { if (data instanceof Data) { Envelope envelope = EnvelopeFactory.getInstance().createEnvelope((Data<Domain>) data); // log to queue String serializedEnvelope = serializeEnvelope(envelope); queue.enqueue(serializedEnvelope); InternalLogging.info(TAG, "enqueued telemetry", envelope.getName()); } else { InternalLogging.warn(TAG, "telemetry not enqueued, must be of type ITelemetry"); } }