writeFieldName(fieldName); writeString(value);
Note: many performance-sensitive implementations override this method
8485868788899091929394
writer.writeStructBegin("union"); switch (value._id) { case 1: writer.writeStringField("stringValue", (short) 1, value.stringValue); break; case 2: writer.writeI64Field("longValue", (short) 2, value.longValue); break; case 3:
214215216217218219220221222223224
{ json.writeStringField("type", "timer"); json.writeFieldName("duration"); json.writeStartObject(); { json.writeStringField("unit", timer.durationUnit().toString().toLowerCase()); writeSummarizable(timer, json); writeSampling(timer, json); if (context.showFullSamples) { json.writeObjectField("values", timer.getSnapshot().getValues()); }
238239240241242243244245246247248
@Override public void processGauge(MetricName name, Gauge<?> gauge, Context context) throws Exception { final JsonGenerator json = context.json; json.writeStartObject(); { json.writeStringField("type", "gauge"); json.writeObjectField("value", evaluateGauge(gauge)); } json.writeEndObject(); }
161162163164165166167168169170171
@Override public void processMeter(MetricName name, Metered meter, Context context) throws Exception { final JsonGenerator json = context.json; json.writeStartObject(); { json.writeStringField("type", "meter"); json.writeStringField("event_type", meter.eventType()); writeMeteredFields(meter, json); } json.writeEndObject(); }
162163164165166167168169170171172
public void processMeter(MetricName name, Metered meter, Context context) throws Exception { final JsonGenerator json = context.json; json.writeStartObject(); { json.writeStringField("type", "meter"); json.writeStringField("event_type", meter.eventType()); writeMeteredFields(meter, json); } json.writeEndObject(); }
173174175176177178179180181182183
@Override public void processCounter(MetricName name, Counter counter, Context context) throws Exception { final JsonGenerator json = context.json; json.writeStartObject(); { json.writeStringField("type", "counter"); json.writeNumberField("count", counter.count()); } json.writeEndObject(); }
184185186187188189190191192193194
@Override public void processHistogram(MetricName name, Histogram histogram, Context context) throws Exception { final JsonGenerator json = context.json; json.writeStartObject(); { json.writeStringField("type", "histogram"); json.writeNumberField("count", histogram.count()); writeSummarizable(histogram, json); writeSampling(histogram, json); if (context.showFullSamples) {
210211212213214215216217218219220
@Override public void processTimer(MetricName name, Timer timer, Context context) throws Exception { final JsonGenerator json = context.json; json.writeStartObject(); { json.writeStringField("type", "timer"); json.writeFieldName("duration"); json.writeStartObject(); { json.writeStringField("unit", timer.durationUnit().toString().toLowerCase()); writeSummarizable(timer, json);
133134135136137138139140141142143
resolvedTypeIds ).sortColumnNames( sortColumnNames ).build(); StringWriter searchParamStringWriter = new StringWriter(); JsonGenerator gen = jsonFactory.createGenerator( searchParamStringWriter ); gen.writeStartObject(); gen.writeStringField( "jql", jqlQuery ); gen.writeNumberField( "maxResults", nbEntriesMax ); gen.writeArrayFieldStart( "fields" ); // Retrieve all fields. If that seems slow, we can reconsider. gen.writeString( "*all" ); gen.writeEndArray();
493494495496497498499500501502503
client.replacePath( "/rest/auth/1/session" ); client.type( MediaType.APPLICATION_JSON_TYPE ); StringWriter jsWriter = new StringWriter( ); JsonGenerator gen = jsonFactory.createGenerator( jsWriter ); gen.writeStartObject(); gen.writeStringField( "username", jiraUser ); gen.writeStringField( "password", jiraPassword ); gen.writeEndObject(); gen.close(); Response authRes = client.post( jsWriter.toString() ); if ( authRes.getStatus() != Response.Status.OK.getStatusCode() )