com.google.api.services.monitoring.v3.model.TypedValue Java Examples
The following examples show how to use
com.google.api.services.monitoring.v3.model.TypedValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StackdriverWriter.java From kork with Apache License 2.0 | 5 votes |
/** * Convert a Spectator metric Meter into a Stackdriver TimeSeries entry. * * @param descriptorType The Stackdriver MetricDescriptorType name for the measurement. * @param measurement The Spectator Measurement to encode. * @return The Stackdriver TimeSeries equivalent for the measurement. */ public TimeSeries measurementToTimeSeries( String descriptorType, Registry registry, Meter meter, Measurement measurement) { Map<String, String> labels = cache.tagsToTimeSeriesLabels(descriptorType, measurement.id().tags()); long millis = measurement.timestamp(); double value = measurement.value(); TimeInterval timeInterval = new TimeInterval(); Date date = new Date(millis); timeInterval.setEndTime(rfc3339.format(date)); String descriptorKind = cache.descriptorTypeToKind(descriptorType, registry, meter); if (descriptorKind == "CUMULATIVE") { timeInterval.setStartTime(counterStartTimeRfc3339); } TypedValue typedValue = new TypedValue(); typedValue.setDoubleValue(value); Point point = new Point(); point.setValue(typedValue); point.setInterval(timeInterval); Metric metric = new Metric(); metric.setType(descriptorType); metric.setLabels(labels); TimeSeries ts = new TimeSeries(); ts.setResource(monitoredResource); ts.setMetric(metric); ts.setMetricKind(descriptorKind); ts.setValueType("DOUBLE"); ts.setPoints(Lists.<Point>newArrayList(point)); return ts; }