1- /**
2- * Copyright (c) 2015 Google Inc.
3- * <p/>
4- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5- * use this file except in compliance with the License. You may obtain a copy of
6- * the License at
7- * <p/>
1+ /*
2+ * Copyright 2016 Google Inc. All Rights Reserved .
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
88 * http://www.apache.org/licenses/LICENSE-2.0
9- * <p/>
9+ *
1010 * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13- * License for the specific language governing permissions and limitations under
14- * the License.
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
1515 */
1616
1717import com .google .api .services .monitoring .v3 .Monitoring ;
4040import java .util .TimeZone ;
4141
4242
43-
44-
4543/**
46- * Class to demonstrate creating a custom metric with Cloud Monitoring. This class provides a few
47- * functions that create a custom GAUGE metric, writes a timeseries value to it, then reads that
48- * metric's value back within the last 5 minutes to see the value written.
44+ * Class to demonstrate creating a custom metric with Cloud Monitoring.
45+ * <p/>
46+ * <p>This class provides a few functions that create a custom GAUGE metric, writes a timeseries
47+ * value to it, then reads that metric's value back within the last 5 minutes to see the value
48+ * written.
4949 */
5050public class CreateCustomMetric {
5151
@@ -111,7 +111,8 @@ public CreateCustomMetric(Monitoring monitoringService, String projectResource)
111111 /**
112112 * Constructs an instance of the class using the default metric name, and takes in a random
113113 * number generaotr (used for test purposes).
114- * Package-private to be accessible to tests.
114+ * <p/>
115+ * <p>Package-private to be accessible to tests.
115116 */
116117 CreateCustomMetric (Monitoring monitoringService , String projectResource ,
117118 String metricName , int bound ) {
@@ -162,7 +163,8 @@ private long getRandomPoint() {
162163 /**
163164 * This method creates a custom metric with arbitrary names, description,
164165 * and units.
165- * Package-private to be accessible to tests.
166+ * <p/>
167+ * <p>Package-private to be accessible to tests.
166168 */
167169 MetricDescriptor createCustomMetric () throws IOException {
168170 MetricDescriptor metricDescriptor = new MetricDescriptor ();
@@ -196,8 +198,10 @@ MetricDescriptor createCustomMetric() throws IOException {
196198 }
197199
198200 /**
199- * Retrieve the custom metric created by createCustomMetric. It can sometimes take a few moments
200- * before a new custom metric is ready to have TimeSeries written to it, so this method is used
201+ * Retrieve the custom metric created by createCustomMetric.
202+ * <p/>
203+ * <p>It can sometimes take a few moments before a new custom metric is ready to have
204+ * TimeSeries written to it, so this method is used
201205 * to check when it is ready.
202206 */
203207 public MetricDescriptor getCustomMetric () throws IOException {
@@ -218,8 +222,8 @@ public MetricDescriptor getCustomMetric() throws IOException {
218222 }
219223
220224 /**
221- * Writes a timeseries value for the custom metric created. The value written
222- * is a random integer value for demonstration purposes. It's a GAUGE metric,
225+ * Writes a timeseries value for the custom metric created.
226+ * <p>The value written is a random integer value for demonstration purposes. It's a GAUGE metric,
223227 * which means its a measure of a value at a point in time, and thus the start
224228 * window and end window times are the same.
225229 *
@@ -264,21 +268,21 @@ void writeCustomMetricTimeseriesValue() throws IOException {
264268 }
265269
266270 /**
267- * Read the TimeSeries value for the custom metrics created within a window of the
271+ * <p> Read the TimeSeries value for the custom metrics created within a window of the
268272 * last 5 minutes.
269273 *
270274 * @return The TimeSeries response object reflecting the Timeseries of the custom metrics
271- * for the last 5 minutes.
275+ * for the last 5 minutes.
272276 * @throws IOException On network error.
273277 */
274278 ListTimeSeriesResponse readTimeseriesValue () throws IOException {
275279 ListTimeSeriesResponse response =
276280 monitoringService .projects ().timeSeries ().list (projectResource )
277- .setFilter ("metric.type=\" " + metricType + "\" " )
278- .setPageSize (3 )
279- .setIntervalStartTime (getStartTime ())
280- .setIntervalEndTime (getNow ())
281- .execute ();
281+ .setFilter ("metric.type=\" " + metricType + "\" " )
282+ .setPageSize (3 )
283+ .setIntervalStartTime (getStartTime ())
284+ .setIntervalEndTime (getNow ())
285+ .execute ();
282286 return response ;
283287 }
284288
@@ -302,8 +306,8 @@ public static void main(final String[] args) throws Exception {
302306 // Create an authorized API client
303307 Monitoring monitoringService = ListResources .authenticate ();
304308
305- CreateCustomMetric metricWriter = new CreateCustomMetric (
306- monitoringService , projectResource );
309+ CreateCustomMetric metricWriter =
310+ new CreateCustomMetric ( monitoringService , projectResource );
307311
308312 MetricDescriptor metricDescriptor = metricWriter .createCustomMetric ();
309313
0 commit comments