/** * Serializes this object in JSON format. * * @param writer The writer that helps with serializing into Json format * @throws IOException The exception that might be thrown during the serialization */ @Override public void serialize(JsonTelemetryDataSerializer writer) throws IOException { String telemetryName = this.getTelemetryName( this.normalizeInstrumentationKey(context.getInstrumentationKey()), this.getEnvelopName()); Envelope envelope = new Envelope(); envelope.setName(telemetryName); setSampleRate(envelope); envelope.setIKey(context.getInstrumentationKey()); envelope.setSeq(sequence); Data<T> tmp = new Data<T>(); tmp.setBaseData(getData()); tmp.setBaseType(this.getBaseTypeName()); envelope.setData(tmp); envelope.setTime(LocalStringsUtils.getDateFormatter().format(getTimestamp())); envelope.setTags(context.getTags()); envelope.serialize(writer); }