Search in sources :

Example 1 with Point

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&lt;TimeSeries&gt; timeSeries = new ArrayList&lt;&gt;();
   *   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);
}
Also used : CreateTimeSeriesRequest(com.google.monitoring.v3.CreateTimeSeriesRequest)

Example 2 with Point

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;
}
Also used : List(java.util.List) Lists(com.google.common.collect.Lists) TimeSeries(com.google.monitoring.v3.TimeSeries) Collections2(com.google.common.collect.Collections2) Point(com.google.monitoring.v3.Point) Comparator(java.util.Comparator) Timestamp(com.google.protobuf.Timestamp) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) Point(com.google.monitoring.v3.Point)

Example 3 with Point

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);
    }
}
Also used : HyperSphere(net.imglib2.algorithm.region.hypersphere.HyperSphere) Point(net.imglib2.Point) Point(net.imglib2.Point) FloatType(net.imglib2.type.numeric.real.FloatType) ComplexFloatType(net.imglib2.type.numeric.complex.ComplexFloatType)

Example 4 with Point

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;
}
Also used : Point(net.imglib2.Point) ArrayImgFactory(net.imglib2.img.array.ArrayImgFactory) Localizable(net.imglib2.Localizable) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) Interval(net.imglib2.Interval) FloatType(net.imglib2.type.numeric.real.FloatType)

Example 5 with Point

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]
}
Also used : TimeSeries(com.google.monitoring.v3.TimeSeries) MetricServiceClient(com.google.cloud.monitoring.v3.MetricServiceClient) TimeInterval(com.google.monitoring.v3.TimeInterval) ProjectName(com.google.monitoring.v3.ProjectName) HashMap(java.util.HashMap) CreateTimeSeriesRequest(com.google.monitoring.v3.CreateTimeSeriesRequest) ArrayList(java.util.ArrayList) MonitoredResource(com.google.api.MonitoredResource) Point(com.google.monitoring.v3.Point) Metric(com.google.api.Metric) TypedValue(com.google.monitoring.v3.TypedValue)

Aggregations

Point (net.imglib2.Point)8 Point (com.google.monitoring.v3.Point)4 HyperSphere (net.imglib2.algorithm.region.hypersphere.HyperSphere)4 FloatType (net.imglib2.type.numeric.real.FloatType)4 Metric (com.google.api.Metric)3 CreateTimeSeriesRequest (com.google.monitoring.v3.CreateTimeSeriesRequest)3 TimeInterval (com.google.monitoring.v3.TimeInterval)3 TimeSeries (com.google.monitoring.v3.TimeSeries)3 TypedValue (com.google.monitoring.v3.TypedValue)3 ArrayList (java.util.ArrayList)3 MonitoredResource (com.google.api.MonitoredResource)2 MetricServiceClient (com.google.cloud.monitoring.v3.MetricServiceClient)2 ProjectName (com.google.monitoring.v3.ProjectName)2 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Interval (net.imglib2.Interval)2 Collections2 (com.google.common.collect.Collections2)1