Tabnine Logo
MonitoredResource$Builder.setType
Code IndexAdd Tabnine to your IDE (free)

How to use
setType
method
in
com.google.api.MonitoredResource$Builder

Best Java code snippets using com.google.api.MonitoredResource$Builder.setType (Showing top 13 results out of 315)

origin: GoogleCloudPlatform/java-docs-samples

resourceLabels.put("project_id", projectId);
MonitoredResource resource = MonitoredResource.newBuilder()
  .setType("global")
  .putAllLabels(resourceLabels)
  .build();
origin: GoogleCloudPlatform/java-docs-samples

.setType("gce_instance")
.putAllLabels(resourceLabels)
.build();
origin: GoogleCloudPlatform/java-docs-samples

private static void createUptimeCheck(
  String projectId, String displayName, String hostName, String pathName) throws IOException {
 CreateUptimeCheckConfigRequest request = CreateUptimeCheckConfigRequest
   .newBuilder()
   .setParent(ProjectName.format(projectId))
   .setUptimeCheckConfig(UptimeCheckConfig
     .newBuilder()
     .setDisplayName(displayName)
     .setMonitoredResource(MonitoredResource
       .newBuilder()
       .setType("uptime_url")
       .putLabels("host", hostName))
     .setHttpCheck(HttpCheck
       .newBuilder()
       .setPath(pathName)
       .setPort(80))
     .setTimeout(Duration.newBuilder().setSeconds(10))
     .setPeriod(Duration.newBuilder().setSeconds(300)))
   .build();
 try (UptimeCheckServiceClient client = UptimeCheckServiceClient.create()) {
  UptimeCheckConfig config = client.createUptimeCheckConfig(request);
  System.out.println("Uptime check created: " + config.getDisplayName());
 } catch (Exception e) {
  usage("Exception creating uptime check: " + e.toString());
  throw e;
 }
}
// [END monitoring_uptime_check_create]]
origin: census-instrumentation/opencensus-java

  StackdriverExportUtils.createMetric(
    GAUGE_METRIC_DESCRIPTOR, LABEL_VALUE, CUSTOM_OPENCENSUS_DOMAIN))
.setResource(MonitoredResource.newBuilder().setType("global"))
.addPoints(StackdriverExportUtils.createPoint(POINT, null))
.build();
  StackdriverExportUtils.createMetric(
    GAUGE_METRIC_DESCRIPTOR, LABEL_VALUE_2, CUSTOM_OPENCENSUS_DOMAIN))
.setResource(MonitoredResource.newBuilder().setType("global"))
.addPoints(StackdriverExportUtils.createPoint(POINT_2, null))
.build();
origin: census-instrumentation/opencensus-java

switch (type) {
 case GcpGceInstanceResource.TYPE:
  builder.setType(GCP_GCE_INSTANCE);
  mappings = GCP_RESOURCE_MAPPING;
  break;
 case K8sContainerResource.TYPE:
  builder.setType(GCP_GKE_CONTAINER);
  mappings = K8S_RESOURCE_MAPPING;
  break;
 case AwsEc2InstanceResource.TYPE:
  builder.setType(AWS_EC2_INSTANCE);
  mappings = AWS_RESOURCE_MAPPING;
  break;
 default:
  builder.setType(GLOBAL);
  return;
origin: io.micrometer/micrometer-registry-stackdriver

private TimeSeries createTimeSeries(Meter.Id id, TypedValue typedValue, MetricDescriptor.ValueType valueType,
                  @Nullable String statistic) {
  if (client != null)
    createMetricDescriptorIfNecessary(client, id, valueType, statistic);
  String metricType = metricType(id, statistic);
  Map<String, String> metricLabels = getConventionTags(id).stream()
      .collect(Collectors.toMap(Tag::getKey, Tag::getValue));
  return TimeSeries.newBuilder()
      .setMetric(Metric.newBuilder()
          .setType(metricType)
          .putAllLabels(metricLabels)
          .build())
      .setResource(MonitoredResource.newBuilder()
          .setType(RESOURCE_TYPE)
          .putLabels("project_id", config.projectId())
          .build())
      .setMetricKind(MetricDescriptor.MetricKind.GAUGE) // https://cloud.google.com/monitoring/api/v3/metrics-details#metric-kinds
      .setValueType(valueType)
      .addPoints(Point.newBuilder()
          .setInterval(interval)
          .setValue(typedValue)
          .build())
      .build();
}
origin: census-instrumentation/opencensus-java

@Test
public void createTimeSeriesList_Cumulative() {
 List<TimeSeries> timeSeriesList =
   StackdriverExportUtils.createTimeSeriesList(
     METRIC, DEFAULT_RESOURCE, CUSTOM_OPENCENSUS_DOMAIN);
 assertThat(timeSeriesList).hasSize(1);
 TimeSeries expectedTimeSeries =
   TimeSeries.newBuilder()
     .setMetricKind(MetricKind.CUMULATIVE)
     .setValueType(MetricDescriptor.ValueType.DOUBLE)
     .setMetric(
       StackdriverExportUtils.createMetric(
         METRIC_DESCRIPTOR, LABEL_VALUE, CUSTOM_OPENCENSUS_DOMAIN))
     .setResource(MonitoredResource.newBuilder().setType("global"))
     .addPoints(StackdriverExportUtils.createPoint(POINT, TIMESTAMP_2))
     .build();
 assertThat(timeSeriesList).containsExactly(expectedTimeSeries);
}
origin: census-instrumentation/opencensus-java

@Test
public void createTimeSeriesList_withCustomMonitoredResource() {
 MonitoredResource resource =
   MonitoredResource.newBuilder().setType("global").putLabels("key", "value").build();
 List<TimeSeries> timeSeriesList =
   StackdriverExportUtils.createTimeSeriesList(METRIC, resource, CUSTOM_OPENCENSUS_DOMAIN);
 assertThat(timeSeriesList)
   .containsExactly(
     TimeSeries.newBuilder()
       .setMetricKind(MetricKind.CUMULATIVE)
       .setValueType(MetricDescriptor.ValueType.DOUBLE)
       .setMetric(
         StackdriverExportUtils.createMetric(
           METRIC_DESCRIPTOR, LABEL_VALUE, CUSTOM_OPENCENSUS_DOMAIN))
       .setResource(resource)
       .addPoints(StackdriverExportUtils.createPoint(POINT, TIMESTAMP_2))
       .build());
}
origin: com.google.cloud/google-cloud-core

public com.google.api.MonitoredResource toPb() {
 return com.google.api.MonitoredResource.newBuilder().setType(type).putAllLabels(labels).build();
}
origin: census-instrumentation/opencensus-java

static MonitoredResource getDefaultResource() {
 MonitoredResource.Builder builder = MonitoredResource.newBuilder();
 // Populate internal resource label for defaulting project_id label.
 // This allows stats from other projects (e.g from GAE running in another project) to be
 // collected.
 if (MetadataConfig.getProjectId() != null) {
  builder.putLabels(STACKDRIVER_PROJECT_ID_KEY, MetadataConfig.getProjectId());
 }
 Resource autoDetectedResource = MonitoredResourceUtils.detectResource();
 if (autoDetectedResource == null || autoDetectedResource.getType() == null) {
  builder.setType(GLOBAL);
  return builder.build();
 }
 setResourceForBuilder(builder, autoDetectedResource);
 return builder.build();
}
origin: com.google.cloud/gcloud-java-core

public com.google.api.MonitoredResource toPb() {
 return com.google.api.MonitoredResource.newBuilder()
   .setType(type)
   .putAllLabels(labels)
   .build();
}
origin: GoogleCloudPlatform/java-docs-samples

.setMonitoredResource(MonitoredResource
  .newBuilder()
  .setType("uptime_url")
  .putLabels("host", hostName))
.setHttpCheck(HttpCheck
origin: googleapis/google-cloud-java

public com.google.api.MonitoredResource toPb() {
 return com.google.api.MonitoredResource.newBuilder().setType(type).putAllLabels(labels).build();
}
com.google.apiMonitoredResource$BuildersetType

Javadoc

 
Required. The monitored resource type. This field must match 
the `type` field of a [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] object. For 
example, the type of a Cloud SQL database is `"cloudsql_database"`. 
string type = 1;

Popular methods of MonitoredResource$Builder

  • build
  • buildPartial
  • mergeFrom
  • putLabels
    Required. Values for all of the labels listed in the associated monitored resource descriptor. Fo
  • putAllLabels
    Required. Values for all of the labels listed in the associated monitored resource descriptor. Fo
  • getLabelsMap
    Required. Values for all of the labels listed in the associated monitored resource descriptor. Fo
  • <init>
  • clone
  • getType
    Required. The monitored resource type. This field must match the `type` field of a [MonitoredReso
  • internalGetLabels
  • internalGetMutableLabels
  • maybeForceBuilderInitialization
  • internalGetMutableLabels,
  • maybeForceBuilderInitialization,
  • newUninitializedMessageException,
  • onBuilt,
  • onChanged

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSharedPreferences (Context)
  • runOnUiThread (Activity)
  • addToBackStack (FragmentTransaction)
  • Kernel (java.awt.image)
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now