Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 33d0e12

Browse files
author
Bogdan Drutu
authored
Add a list of standard supported resources. (#235)
* Add a list of standard supported resources. * Refactor the standard resources to be more generic. * Fix typo. * Fix comments, add links to merge. * Add a todo about optional vs required. * Remove host.ip. * Add examples, remove data-center. * Fix zone vs availability zone. * Update resource keys schema, respond to comments.
1 parent 86c7bca commit 33d0e12

File tree

2 files changed

+104
-17
lines changed

2 files changed

+104
-17
lines changed

resource/Resource.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Resource API Overview
22
The resource library primarily defines a type that captures information about the entity
3-
for which stats or traces are reported. It further provides a framework for detection of
3+
for which metrics or traces are reported. It further provides a framework for detection of
44
resource information from the environment and progressive population as signals propagate
55
from the core instrumentation library to a backend's exporter.
66

@@ -12,8 +12,8 @@ about the entity.
1212

1313
Type, label keys, and label values MUST contain only printable ASCII (codes between 32
1414
and 126, inclusive) and not exceed 256 characters.
15-
Type and label keys MUST have a length greater than zero. They SHOULD start with a domain
16-
name and separate hierarchies with `/` characters, e.g. `k8s.io/namespace/name`.
15+
Type and label keys MUST have a length greater than zero. Label keys SHOULD start with the type
16+
and separate hierarchies with `.` characters, e.g. `k8s.namespace.name`.
1717

1818
Implementations MAY define a `Resource` data type, constructed from the parameters above.
1919
`Resource` MUST have getters for retrieving all the information used in `Resource` definition.
@@ -26,7 +26,7 @@ type Resource {
2626
}
2727
```
2828

29-
TODO(fabxc): link protobuf definition.
29+
For the proto definition see [here][resource-proto-link]
3030

3131
## Populating resources
3232
Resource information MAY be populated at any point between startup of the instrumented
@@ -47,8 +47,8 @@ Two environment variables are used:
4747
(`[ <key>="value" [ ,<key>="<value>" ... ] ]`). `"` characters in values MUST be escaped with `\`.
4848

4949
For example:
50-
* `OC_RESOURCE_TYPE=k8s.io/container`
51-
* `OC_RESOURCE_LABELS=k8s.io/pod/name="pod-xyz-123",k8s.io/container/name="c1",k8s.io/namespace/name="default"`
50+
* `OC_RESOURCE_TYPE=container`
51+
* `OC_RESOURCE_LABELS=container.name="c1",k8s.pod.name="pod-xyz-123",k8s.namespace.name="default"`
5252

5353
Population from environment variables MUST be the first applied detection process unless
5454
the user explicitly overwrites this behavior.
@@ -98,17 +98,17 @@ For example, from a resource object
9898

9999
```javascript
100100
{
101-
"type": "k8s.io/container",
101+
"type": "container",
102102
"labels": {
103103
// Populated from VM environment through auto-detection library.
104-
"cloud.google.com/gce/instance_id": "instance1",
105-
"cloud.google.com/zone": "eu-west2-a",
106-
"cloud.google.com/project_id": "project1",
107-
"cloud.google.com/gce/attributes/cluster_name": "cluster1",
104+
"host.id": "instance1",
105+
"cloud.zone": "eu-west2-a",
106+
"cloud.account.id": "project1",
108107
// Populated through OpenCensus resource environment variables.
109-
"k8s.io/namespace/name": "ns1",
110-
"k8s.io/pod/name": "pod1",
111-
"k8s.io/container/name": "container1",
108+
"k8s.cluster_name": "cluster1",
109+
"k8s.namespace.name": "ns1",
110+
"k8s.pod.name": "pod1",
111+
"container.name": "container1",
112112
},
113113
}
114114
```
@@ -130,7 +130,7 @@ resource type with well-known identifiers specific to its API:
130130
}
131131
```
132132

133-
For another, hyopthetical, backend a simple unique identifier might be constructed instead
133+
For another, hypothetical, backend a simple unique identifier might be constructed instead
134134
by its exporter:
135135

136136
```
@@ -139,10 +139,11 @@ cluster1/ns1/pod1/container1
139139

140140
Exporter libraries MAY provide a default translation for well-known input resource types and labels.
141141
Those would generally be based on community-supported detection integrations maintained in the
142-
[census-ecosystem][census-ecosystem] organisation.
142+
[census-ecosystem][census-ecosystem-link] organisation.
143143

144144
Additionally, exporters SHOULD provide configuration hooks for users to provide their own
145145
translation unless the exporter's backend does not support resources at all. For such backends,
146146
exporters SHOULD allow attaching converting resource labels to metric tags.
147147

148-
[census-ecosystem]: https://github.com/census-ecosystem
148+
[census-ecosystem-link]: https://github.com/census-ecosystem
149+
[resource-proto-link]: https://github.com/census-instrumentation/opencensus-proto/blob/master/src/opencensus/proto/resource/v1/resource.proto

resource/StandardResources.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Standard Resources
2+
3+
This page lists the standard resource types in OpenCensus. For more details on how resources can
4+
be combined see [this](Resource.md).
5+
6+
OpenCensus defines these fields.
7+
* [Compute Unit](#compute-unit)
8+
* [Container](#container)
9+
* [Deployment Service](#deployment-service)
10+
* [Kubernetes](#kubernetes)
11+
* [Compute Instance](#compute-instance)
12+
* [Host](#host)
13+
* [Environment](#environment)
14+
* [Cloud](#cloud)
15+
* [Cluster](#cluster)
16+
17+
## TODOs
18+
* Add logical compute units: Service, Task - instance running in a service.
19+
* Add more compute units: Process, Lambda Function, AppEngine unit, etc.
20+
* Add Device (mobile) and Web Browser.
21+
* Decide if lower case strings only.
22+
* Consider to add optional/required for each label and combination of labels (e.g when supplying a
23+
k8s resource all k8s may be required).
24+
25+
## Compute Unit
26+
Resources defining a compute unit (e.g. Container, Process, Lambda Function).
27+
28+
### Container
29+
**type:** `container`
30+
31+
**Description:** A container instance. This resource can be [merged](Resource.md#Merging) with a
32+
deployment service resource, a compute instance resource, and an environment resource.
33+
34+
| Label | Description | Example |
35+
|---|---|---|
36+
| container.name | Container name. | `opencenus-autoconf` |
37+
| container.image.name | Name of the image the container was built on. | `gcr.io/opencensus/operator` |
38+
| container.image.tag | Container image tag. | `0.1` |
39+
40+
## Deployment Service
41+
Resources defining a deployment service (e.g. Kubernetes).
42+
43+
### Kubernetes
44+
**type:** `k8s`
45+
46+
**Description:** A Kubernetes resource. This resource can be [merged](Resource.md#Merging) with
47+
a compute instance resource, and/or an environment resource.
48+
49+
| Label | Description | Example |
50+
|---|---|---|
51+
| k8s.cluster.name | The name of the cluster that the pod is running in. | `opencensus-cluster` |
52+
| k8s.namespace.name | The name of the namespace that the pod is running in. | `default` |
53+
| k8s.pod.name | The name of the pod. | `opencensus-pod-autoconf` |
54+
55+
## Compute Instance
56+
Resources defining a computing instance (e.g. host).
57+
58+
### Host
59+
**type:** `host`
60+
61+
**Description:** A host is defined as a general computing instance. This resource should be
62+
[merged](Resource.md#Merging) with an environment resource.
63+
64+
65+
| Label | Description | Example |
66+
|---|---|---|
67+
| host.hostname | Hostname of the host.<br/> It contains what the `hostname` command returns on the host machine. | `opencensus-test` |
68+
| host.id | Unique host id.<br/> For Cloud this must be the instance_id assigned by the cloud provider | `opencensus-test` |
69+
| host.name | Name of the host.<br/> It may contain what `hostname` returns on Unix systems, the fully qualified, or a name specified by the user. | `opencensus-test` |
70+
| host.type | Type of host.<br/> For Cloud this must be the machine type.| `n1-standard-1` |
71+
72+
## Environment
73+
74+
Resources defining a running environment (e.g. Cloud, Data Center).
75+
76+
### Cloud
77+
**type:** `cloud`
78+
79+
**Description:** A cloud infrastructure (e.g. GCP, Azure, AWS).
80+
81+
| Label | Description | Example |
82+
|---|---|---|
83+
| cloud.provider | Name of the cloud provider.<br/> Example values are aws, azure, gcp. | `gcp` |
84+
| cloud.account.id | The cloud account id used to identify different entities. | `opencensus` |
85+
| cloud.region | A specific geographical location where different entities can run | `us-central1` |
86+
| cloud.zone | Zones are a sub set of the region connected through low-latency links.<br/> In aws it is called availability-zone. | `us-central1-a` |

0 commit comments

Comments
 (0)