use of io.opencensus.resource.Resource in project instrumentation-java by census-instrumentation.
the class K8sResourceTest method create_K8sContainerResourceTest.
@Test
public void create_K8sContainerResourceTest() {
Resource resource = K8sResource.create(K8S_CLUSTER_NAME, K8S_NAMESPACE_NAME, K8S_POD_NAME, K8S_DEPLOYMENT_NAME);
assertThat(resource.getType()).isEqualTo(K8sResource.TYPE);
assertThat(resource.getLabels()).containsExactly(K8sResource.CLUSTER_NAME_KEY, K8S_CLUSTER_NAME, K8sResource.NAMESPACE_NAME_KEY, K8S_NAMESPACE_NAME, K8sResource.POD_NAME_KEY, K8S_POD_NAME, K8sResource.DEPLOYMENT_NAME_KEY, K8S_DEPLOYMENT_NAME);
}
use of io.opencensus.resource.Resource in project instrumentation-java by census-instrumentation.
the class K8sResourceTest method create_K8sContainerResourceTest_Deprecated.
@Test
public void create_K8sContainerResourceTest_Deprecated() {
Resource resource = K8sResource.create(K8S_CLUSTER_NAME, K8S_NAMESPACE_NAME, K8S_POD_NAME);
assertThat(resource.getType()).isEqualTo(K8sResource.TYPE);
assertThat(resource.getLabels()).containsExactly(K8sResource.CLUSTER_NAME_KEY, K8S_CLUSTER_NAME, K8sResource.NAMESPACE_NAME_KEY, K8S_NAMESPACE_NAME, K8sResource.POD_NAME_KEY, K8S_POD_NAME, K8sResource.DEPLOYMENT_NAME_KEY, "");
}
use of io.opencensus.resource.Resource in project instrumentation-java by census-instrumentation.
the class CloudResourceTest method create_ContainerResourceTest.
@Test
public void create_ContainerResourceTest() {
Resource resource = CloudResource.create(PROVIDER, ACCOUNT_ID, REGION, ZONE);
assertThat(resource.getType()).isEqualTo(CloudResource.TYPE);
assertThat(resource.getLabels()).containsExactly(CloudResource.PROVIDER_KEY, PROVIDER, CloudResource.ACCOUNT_ID_KEY, ACCOUNT_ID, CloudResource.REGION_KEY, REGION, CloudResource.ZONE_KEY, ZONE);
}
use of io.opencensus.resource.Resource in project instrumentation-java by census-instrumentation.
the class HostResourceTest method create_ContainerResourceTest.
@Test
public void create_ContainerResourceTest() {
Resource resource = HostResource.create(HOSTNAME, NAME, ID, TYPE);
assertThat(resource.getType()).isEqualTo(HostResource.TYPE);
assertThat(resource.getLabels()).containsExactly(HostResource.HOSTNAME_KEY, HOSTNAME, HostResource.NAME_KEY, NAME, HostResource.ID_KEY, ID, HostResource.TYPE_KEY, TYPE);
}
use of io.opencensus.resource.Resource 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();
}
Aggregations