/**
   * 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");
    }
  }
 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;
   }
 }
  /** @return the INSTANCE of Channel or null if not yet initialized */
  protected static IChannel getInstance() {
    if (Channel.instance == null) {
      InternalLogging.error(TAG, "getInstance was called before initialization");
    }

    return Channel.instance;
  }
  protected void processException(Data<Domain> data) {
    Envelope envelope = EnvelopeFactory.getInstance().createEnvelope(data);

    queue.isCrashing = true;
    queue.flush();

    String serializedEnvelope = serializeEnvelope(envelope);
    String[] serializedEvelopeArray = new String[] {serializedEnvelope};

    if (this.persistence != null) {
      InternalLogging.info(TAG, "persisting crash", envelope.toString());
      this.persistence.persist(serializedEvelopeArray, true);
    } else {
      InternalLogging.info(TAG, "error persisting crash", envelope.toString());
    }
  }