|
1 | 1 | # Common specification concepts |
2 | 2 |
|
| 3 | +**Status**: [Feature-freeze](../document-status.md). |
| 4 | + |
3 | 5 | <details> |
4 | 6 | <summary> |
5 | 7 | Table of Contents |
6 | 8 | </summary> |
7 | 9 |
|
8 | 10 | - [Attributes](#attributes) |
9 | | - - [Attribute and Label Naming](#attribute-and-label-naming) |
10 | | - - [Name Pluralization Guidelines](#name-pluralization-guidelines) |
11 | | - - [Recommendations for OpenTelemetry Authors](#recommendations-for-opentelemetry-authors) |
12 | | - - [Recommendations for Application Developers](#recommendations-for-application-developers) |
13 | 11 |
|
14 | 12 | </details> |
15 | 13 |
|
@@ -42,122 +40,4 @@ indices that are kept in sync (e.g., two attributes `header_keys` and `header_va |
42 | 40 | both containing an array of strings to represent a mapping |
43 | 41 | `header_keys[i] -> header_values[i]`). |
44 | 42 |
|
45 | | -## Attribute and Label Naming |
46 | | - |
47 | | -_This section applies to Resource, Span and Log attribute names (also known as |
48 | | -the "attribute keys") and to keys of Metric labels. For brevity within this |
49 | | -section when we use the term "name" without an adjective it is implied to mean |
50 | | -"attribute name or metric label key"._ |
51 | | - |
52 | | -Every name MUST be a valid Unicode sequence. |
53 | | - |
54 | | -_Note: we merely require that the names are represented as Unicode sequences. |
55 | | -This specification does not define how exactly the Unicode sequences are |
56 | | -encoded. The encoding can vary from one programming language to another and from |
57 | | -one wire format to another. Use the idiomatic way to represent Unicode in the |
58 | | -particular programming language or wire format._ |
59 | | - |
60 | | -Names SHOULD follow these rules: |
61 | | - |
62 | | -- Use namespacing to avoid name clashes. Delimit the namespaces using a dot |
63 | | - character. For example `service.version` denotes the service version where |
64 | | - `service` is the namespace and `version` is an attribute in that namespace. |
65 | | - |
66 | | -- Namespaces can be nested. For example `telemetry.sdk` is a namespace inside |
67 | | - top-level `telemetry` namespace and `telemetry.sdk.name` is an attribute |
68 | | - inside `telemetry.sdk` namespace. |
69 | | - Note: the fact that an entity is located within another entity is typically |
70 | | - not a sufficient reason for forming nested namespaces. The purpose of a |
71 | | - namespace is to avoid name clashes, not to indicate entity hierarchies. This |
72 | | - purpose should primarily drive the decision about forming nested namespaces. |
73 | | - |
74 | | -- For each multi-word dot-delimited component of the attribute name separate the |
75 | | - words by underscores (i.e. use snake_case). For example `http.status_code` |
76 | | - denotes the status code in the http namespace. |
77 | | - |
78 | | -- Names SHOULD NOT coincide with namespaces. For example if |
79 | | - `service.instance.id` is an attribute name then it is no longer valid to have |
80 | | - an attribute named `service.instance` because `service.instance` is already a |
81 | | - namespace. Because of this rule be careful when choosing names: every existing |
82 | | - name prohibits existence of an equally named namespace in the future, and vice |
83 | | - versa: any existing namespace prohibits existence of an equally named |
84 | | - attribute or label key in the future. |
85 | | - |
86 | | -### Name Pluralization guidelines |
87 | | - |
88 | | -- When an attribute represents a single entity, the attribute name SHOULD be singular. |
89 | | - Examples: `host.name`, `db.user`, `container.id`. |
90 | | - |
91 | | -- When attribute can represent multiple entities, the attribute name SHOULD be pluralized |
92 | | - and the value type SHOULD be an array. E.g. `process.command_args` might include multiple |
93 | | - values: the executable name and command arguments. |
94 | | - |
95 | | -- When an attribute represents a measurement, |
96 | | - [Metric Name Pluralization Guidelines](../metrics/semantic_conventions/README.md#pluralization) |
97 | | - SHOULD be followed for the attribute name. |
98 | | - |
99 | | -### Recommendations for OpenTelemetry Authors |
100 | | - |
101 | | -- All names that are part of OpenTelemetry semantic conventions SHOULD be part |
102 | | - of a namespace. |
103 | | - |
104 | | -- When coming up with a new semantic convention make sure to check existing |
105 | | - namespaces for |
106 | | - [Resources](../resource/semantic_conventions/README.md), |
107 | | - [Spans](../trace/semantic_conventions/README.md), |
108 | | - and |
109 | | - [Metrics](../metrics/semantic_conventions/README.md) |
110 | | - to see if the new name fits. |
111 | | - |
112 | | -- When a new namespace is necessary consider whether it should be a top-level |
113 | | - namespace (e.g. `service`) or a nested namespace (e.g. `service.instance`). |
114 | | - |
115 | | -- Semantic conventions exist for four areas: for Resource, Span and Log |
116 | | - attribute names as well as Metric label keys. In addition, for spans we have |
117 | | - two more areas: Event and Link attribute names. Identical namespaces or names |
118 | | - in all these areas MUST have identical meanings. For example the `http.method` |
119 | | - span attribute name denotes exactly the same concept as the `http.method` |
120 | | - metric label, has the same data type and the same set of possible values (in |
121 | | - both cases it records the value of the HTTP protocol's request method as a |
122 | | - string). |
123 | | - |
124 | | -- Semantic conventions MUST limit names to printable Basic Latin characters |
125 | | - (more precisely to |
126 | | - [U+0021 .. U+007E](https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)#Table_of_characters) |
127 | | - subset of Unicode code points). It is recommended to further limit names to |
128 | | - the following Unicode code points: Latin alphabet, Numeric, Underscore, Dot |
129 | | - (as namespace delimiter). |
130 | | - |
131 | | -### Recommendations for Application Developers |
132 | | - |
133 | | -As an application developer when you need to record an attribute or a label |
134 | | -first consult existing semantic conventions for |
135 | | -[Resources](../resource/semantic_conventions/README.md), |
136 | | -[Spans](../trace/semantic_conventions/README.md), |
137 | | -and |
138 | | -[Metrics](../metrics/semantic_conventions/README.md). |
139 | | -If an appropriate name does not exists you will need to come up with a new name. |
140 | | -To do that consider a few options: |
141 | | - |
142 | | -- The name is specific to your company and may be possibly used outside the |
143 | | - company as well. To avoid clashes with names introduced by other companies (in |
144 | | - a distributed system that uses applications from multiple vendors) it is |
145 | | - recommended to prefix the new name by your company's reverse domain name, e.g. |
146 | | - `com.acme.shopname`. |
147 | | - |
148 | | -- The name is specific to your application that will be used internally only. If |
149 | | - you already have an internal company process that helps you to ensure no name |
150 | | - clashes happen then feel free to follow it. Otherwise it is recommended to |
151 | | - prefix the attribute name or label key by your application name, provided that |
152 | | - the application name is reasonably unique within your organization (e.g. |
153 | | - `myuniquemapapp.longitude` is likely fine). Make sure the application name |
154 | | - does not clash with an existing semantic convention namespace. |
155 | | - |
156 | | -- The name may be generally applicable to applications in the industry. In that |
157 | | - case consider submitting a proposal to this specification to add a new name to |
158 | | - the semantic conventions, and if necessary also to add a new namespace. |
159 | | - |
160 | | -It is recommended to limit names to printable Basic Latin characters |
161 | | -(more precisely to |
162 | | -[U+0021 .. U+007E](https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)#Table_of_characters) |
163 | | -subset of Unicode code points). |
| 43 | +See [Attribute and Label Naming](attribute-and-label-naming.md) for naming guidelines. |
0 commit comments