Skip to content

Commit 20802fb

Browse files
authored
[chore] [docs] Add component naming guidelines (#14389)
Document the new `lower_snake_case` naming convention for OpenTelemetry Collector components in the coding guidelines as result of discussion in #14208.
1 parent be92a1f commit 20802fb

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/coding-guidelines.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@ 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+
- `otlp_http` (not `otlphttp`)
21+
22+
For example, a component with identifier `memory_limiter` would typically have a Go package name like `memorylimiterprocessor`.
23+
24+
#### Migration for existing components
25+
26+
Components that currently use a different naming convention:
27+
- SHOULD add the `lower_snake_case` name as the primary identifier
28+
- MAY support the old name as a deprecated alias for backwards compatibility
29+
- MUST document the migration path in their README
30+
31+
Only components following the `lower_snake_case` naming convention should be marked as stable.
32+
33+
### Go API naming conventions
34+
1235
To keep naming patterns consistent across the project, naming patterns are enforced to make intent clear by:
1336

1437
- 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 +61,7 @@ To keep naming patterns consistent across the project, naming patterns are enfor
3861
- `func CreateTracesExport(...) {...}`
3962
- `func CreateTracesToTracesFunc(...) {...}`
4063

41-
### Configuration structs
64+
#### Configuration structs
4265

4366
When naming configuration structs, use the following guidelines:
4467

0 commit comments

Comments
 (0)