Search in sources :

Example 6 with MonitoredResource

use of com.google.api.MonitoredResource in project instrumentation-java by census-instrumentation.

the class StackdriverExportUtilsTest method createTimeSeriesList_withCustomMonitoredResource.

@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, PROJECT_ID, DEFAULT_CONSTANT_LABELS);
    assertThat(timeSeriesList).containsExactly(TimeSeries.newBuilder().setMetricKind(MetricKind.CUMULATIVE).setValueType(MetricDescriptor.ValueType.DOUBLE).setMetric(StackdriverExportUtils.createMetric(METRIC_DESCRIPTOR, LABEL_VALUE, CUSTOM_OPENCENSUS_DOMAIN, DEFAULT_CONSTANT_LABELS)).setResource(resource).addPoints(StackdriverExportUtils.createPoint(POINT, TIMESTAMP_2)).build());
}
Also used : TimeSeries(com.google.monitoring.v3.TimeSeries) MonitoredResource(com.google.api.MonitoredResource) Test(org.junit.Test)

Example 7 with MonitoredResource

use of com.google.api.MonitoredResource in project instrumentation-java by census-instrumentation.

the class StackdriverExportUtils method getDefaultResource.

/* Return a self-configured StackDriver monitored resource. */
static MonitoredResource getDefaultResource() {
    MonitoredResource.Builder builder = MonitoredResource.newBuilder();
    // collected.
    if (MetadataConfig.getProjectId() != null) {
        builder.putLabels(STACKDRIVER_PROJECT_ID_KEY, MetadataConfig.getProjectId());
    }
    Resource autoDetectedResource = ResourceUtils.detectResource();
    if (autoDetectedResource == null || autoDetectedResource.getType() == null) {
        builder.setType(GLOBAL);
        return builder.build();
    }
    setResourceForBuilder(builder, autoDetectedResource);
    return builder.build();
}
Also used : MonitoredResource(com.google.api.MonitoredResource) HostResource(io.opencensus.contrib.resource.util.HostResource) K8sResource(io.opencensus.contrib.resource.util.K8sResource) CloudResource(io.opencensus.contrib.resource.util.CloudResource) Resource(io.opencensus.resource.Resource) ContainerResource(io.opencensus.contrib.resource.util.ContainerResource) MonitoredResource(com.google.api.MonitoredResource)

Aggregations

MonitoredResource (com.google.api.MonitoredResource)7 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 TimeSeries (com.google.monitoring.v3.TimeSeries)3 Metric (com.google.api.Metric)2 MetricServiceClient (com.google.cloud.monitoring.v3.MetricServiceClient)2 LogEntry (com.google.logging.v2.LogEntry)2 LogNameOneof (com.google.logging.v2.LogNameOneof)2 CreateTimeSeriesRequest (com.google.monitoring.v3.CreateTimeSeriesRequest)2 Point (com.google.monitoring.v3.Point)2 ProjectName (com.google.monitoring.v3.ProjectName)2 TimeInterval (com.google.monitoring.v3.TimeInterval)2 TypedValue (com.google.monitoring.v3.TypedValue)2 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)2 ApiException (com.google.api.gax.grpc.ApiException)1 ListGroupMembersPagedResponse (com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListGroupMembersPagedResponse)1 WriteLogEntriesRequest (com.google.logging.v2.WriteLogEntriesRequest)1 WriteLogEntriesResponse (com.google.logging.v2.WriteLogEntriesResponse)1 GroupName (com.google.monitoring.v3.GroupName)1