use of com.google.monitoring.v3.Point in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClient method createTimeSeries.
// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Creates or adds data to one or more time series. The response is empty if all time series in
* the request were written. If any time series could not be written, a corresponding failure
* message is included in the error response.
*
* <p>Sample code:
*
* <pre><code>
* try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
* ProjectName name = ProjectName.create("[PROJECT]");
* List<TimeSeries> timeSeries = new ArrayList<>();
* metricServiceClient.createTimeSeries(name, timeSeries);
* }
* </code></pre>
*
* @param name The project on which to execute the request. The format is
* `"projects/{project_id_or_number}"`.
* @param timeSeries The new data to be added to a list of time series. Adds at most one data
* point to each of several time series. The new data point must be more recent than any other
* point in its time series. Each `TimeSeries` value must fully specify a unique time series
* by supplying all label values for the metric and the monitored resource.
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final void createTimeSeries(ProjectName name, List<TimeSeries> timeSeries) {
CreateTimeSeriesRequest request = CreateTimeSeriesRequest.newBuilder().setNameWithProjectName(name).addAllTimeSeries(timeSeries).build();
createTimeSeries(request);
}
use of com.google.monitoring.v3.Point in project java-docs-samples by GoogleCloudPlatform.
the class TimeSeriesSummary method getMostRecentPoint.
Point getMostRecentPoint(TimeSeries timeSeries) {
Point max = Collections.max(timeSeries.getPointsList(), Comparator.comparingLong(p -> p.getInterval().getEndTime().getSeconds()));
mostRecentRunTime = max.getInterval().getEndTime();
return max;
}
use of com.google.monitoring.v3.Point in project imagej-ops by imagej.
the class ConvolveTest method placeSphereInCenter.
// utility to place a small sphere at the center of the image
private void placeSphereInCenter(Img<FloatType> img) {
final Point center = new Point(img.numDimensions());
for (int d = 0; d < img.numDimensions(); d++) center.setPosition(img.dimension(d) / 2, d);
HyperSphere<FloatType> hyperSphere = new HyperSphere<>(img, center, 2);
for (final FloatType value : hyperSphere) {
value.setReal(1);
}
}
use of com.google.monitoring.v3.Point in project imagej-ops by imagej.
the class ColocalisationTest method gaussianSmooth.
/**
* Gaussian Smooth of the input image using intermediate float format.
*
* @param <T>
* @param img
* @param sigma
* @return
*/
public static <T extends RealType<T> & NativeType<T>> Img<T> gaussianSmooth(RandomAccessibleInterval<T> img, double[] sigma) {
Interval interval = Views.iterable(img);
ImgFactory<T> outputFactory = new ArrayImgFactory<T>();
final long[] dim = new long[img.numDimensions()];
img.dimensions(dim);
Img<T> output = outputFactory.create(dim, img.randomAccess().get().createVariable());
final long[] pos = new long[img.numDimensions()];
Arrays.fill(pos, 0);
Localizable origin = new Point(pos);
ImgFactory<FloatType> tempFactory = new ArrayImgFactory<FloatType>();
RandomAccessible<T> input = Views.extendMirrorSingle(img);
Gauss.inFloat(sigma, input, interval, output, origin, tempFactory);
return output;
}
use of com.google.monitoring.v3.Point in project java-docs-samples by GoogleCloudPlatform.
the class Snippets method writeTimeSeries.
/**
* Demonstrates writing a time series value for the metric type
* 'custom.google.apis.com/my_metric'.
* <p>
* This method assumes `my_metric` descriptor has already been created as a
* DOUBLE value_type and GAUGE metric kind. If the metric descriptor
* doesn't exist, it will be auto-created.
*/
// CHECKSTYLE OFF: VariableDeclarationUsageDistance
void writeTimeSeries() throws IOException {
// [START monitoring_write_timeseries]
String projectId = System.getProperty("projectId");
// Instantiates a client
MetricServiceClient metricServiceClient = MetricServiceClient.create();
// Prepares an individual data point
TimeInterval interval = TimeInterval.newBuilder().setEndTime(Timestamps.fromMillis(System.currentTimeMillis())).build();
TypedValue value = TypedValue.newBuilder().setDoubleValue(123.45).build();
Point point = Point.newBuilder().setInterval(interval).setValue(value).build();
List<Point> pointList = new ArrayList<>();
pointList.add(point);
ProjectName name = ProjectName.of(projectId);
// Prepares the metric descriptor
Map<String, String> metricLabels = new HashMap<>();
Metric metric = Metric.newBuilder().setType("custom.googleapis.com/my_metric").putAllLabels(metricLabels).build();
// Prepares the monitored resource descriptor
Map<String, String> resourceLabels = new HashMap<>();
resourceLabels.put("instance_id", "1234567890123456789");
resourceLabels.put("zone", "us-central1-f");
MonitoredResource resource = MonitoredResource.newBuilder().setType("gce_instance").putAllLabels(resourceLabels).build();
// Prepares the time series request
TimeSeries timeSeries = TimeSeries.newBuilder().setMetric(metric).setResource(resource).addAllPoints(pointList).build();
List<TimeSeries> timeSeriesList = new ArrayList<>();
timeSeriesList.add(timeSeries);
CreateTimeSeriesRequest request = CreateTimeSeriesRequest.newBuilder().setName(name.toString()).addAllTimeSeries(timeSeriesList).build();
// Writes time series data
metricServiceClient.createTimeSeries(request);
System.out.println("Done writing time series value.");
// [END monitoring_write_timeseries]
}
Aggregations