Search in sources :

Example 6 with Resource

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);
}
Also used : Resource(io.opencensus.resource.Resource) Test(org.junit.Test)

Example 7 with Resource

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, "");
}
Also used : Resource(io.opencensus.resource.Resource) Test(org.junit.Test)

Example 8 with Resource

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);
}
Also used : Resource(io.opencensus.resource.Resource) Test(org.junit.Test)

Example 9 with Resource

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);
}
Also used : Resource(io.opencensus.resource.Resource) Test(org.junit.Test)

Example 10 with Resource

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();
}
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

Resource (io.opencensus.resource.Resource)10 Test (org.junit.Test)9 MonitoredResource (com.google.api.MonitoredResource)4 CloudResource (io.opencensus.contrib.resource.util.CloudResource)4 ContainerResource (io.opencensus.contrib.resource.util.ContainerResource)4 HostResource (io.opencensus.contrib.resource.util.HostResource)4 K8sResource (io.opencensus.contrib.resource.util.K8sResource)4 ByteString (com.google.protobuf.ByteString)3 AttachmentValueString (io.opencensus.metrics.data.AttachmentValue.AttachmentValueString)3 HashMap (java.util.HashMap)3