Skip to content

Commit e37337d

Browse files
committed
[docs] Add component naming guidelines
Document the new `lower_snake_case` naming convention for OpenTelemetry Collector components in the coding guidelines as result of discussion in #14208.
1 parent 928507a commit e37337d

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

docs/coding-guidelines.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,31 @@ interaction with a human (such as this Collector).
99

1010
## Naming convention
1111

12+
### Component naming
13+
14+
Components (receivers, processors, exporters, extensions, and connectors) MUST use `lower_snake_case` naming convention. This ensures consistency and enhances readability for end users.
15+
16+
This naming convention applies to the component identifier used in configuration files and component registration, not to Go package names which follow standard Go naming conventions (lowercase, no underscores).
17+
18+
Examples of correct component names:
19+
- `memory_limiter` (not `memorylimiter`)
20+
- `docker_stats` (not `dockerstats`)
21+
- `k8s_cluster` (not `k8scluster`)
22+
- `otlp_http` (not `otlphttp`)
23+
24+
For example, a component with identifier `memory_limiter` would typically have a Go package name like `memorylimiterprocessor`.
25+
26+
#### Migration for existing components
27+
28+
Components that currently use a different naming convention:
29+
- SHOULD add the `lower_snake_case` name as the primary identifier
30+
- MAY support the old name as a deprecated alias for backwards compatibility
31+
- MUST document the migration path in their README
32+
33+
Only components following the `lower_snake_case` naming convention should be marked as stable.
34+
35+
### Go API naming conventions
36+
1237
To keep naming patterns consistent across the project, naming patterns are enforced to make intent clear by:
1338

1439
- Methods that return a variable that uses the zero value or values provided via the method MUST have the prefix `New`. For example:
@@ -38,7 +63,7 @@ To keep naming patterns consistent across the project, naming patterns are enfor
3863
- `func CreateTracesExport(...) {...}`
3964
- `func CreateTracesToTracesFunc(...) {...}`
4065

41-
### Configuration structs
66+
#### Configuration structs
4267

4368
When naming configuration structs, use the following guidelines:
4469

0 commit comments

Comments
 (0)