Skip to content

Commit 0ea2238

Browse files
evan-bradleysbylica-splunk
authored andcommitted
[chore][pkg/ottl] Move new function guidelines to CONTRIBUTING.md (open-telemetry#36687)
1 parent 523295b commit 0ea2238

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

pkg/ottl/CONTRIBUTING.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,52 @@ This guide is specific to the OpenTelemetry Transformation Language. All guidel
66

77
- Changes to the OpenTelemetry Transformation Language should be made independent of any component that depend on the package. Whenever possible, try not to submit PRs that change both the OTTL and a dependent component. Instead, submit a PR that updates the OTTL and then, once merged, update the component as needed.
88

9-
## New Values
9+
## Adding New Editors/Converters
1010

11-
When adding new values to the grammar you must:
11+
Before raising a PR with a new Editor or Converter, raise an issue to verify its acceptance. While acceptance is strongly specific to a specific use case, consider these guidelines for early assessment.
1212

13-
1. Update the `Value` struct with the new value. This may also mean adding new token(s) to the lexer.
14-
2. Update `NewFunctionCall` to be able to handle calling functions with this new value.
15-
3. Update `NewGetter` to be able to handle the new value.
16-
4. Add new unit tests.
13+
Your proposal likely will be accepted if:
14+
15+
- The proposed functionality is missing,
16+
- The proposed solution significantly improves user experience and readability for very common use cases,
17+
- The proposed solution is more performant in cases where it is possible to achieve the same result with existing options.
18+
19+
It will be up for discussion if your proposal solves an issue that can be achieved in another way but does not improve user experience or performance.
20+
21+
Your proposal likely won't be accepted if:
22+
23+
- User experience is worse and assumes a highly technical user,
24+
- The performance of your proposal very negatively affects the processing pipeline.
25+
26+
As with code, OTTL aims for readability first. This means:
1727

18-
## New Functions
28+
- Using short, meaningful, and descriptive names,
29+
- Ensuring naming consistency across Editors and Converters,
30+
- Avoiding deep nesting to achieve desired transformations,
31+
- Ensuring Editors and Converters have a single responsibility.
32+
33+
### Implementation guidelines
1934

2035
All new functions must be added via a new file. Function files must start with `func_`. Functions must be placed in `ottlfuncs`.
2136

2237
Unit tests must be added for all new functions. Unit test files must start with `func_` and end in `_test`. Unit tests must be placed in the same directory as the function. Functions that are not specific to a pipeline should be tested independently of any specific pipeline. Functions that are specific to a pipeline should be tests against that pipeline. End-to-end tests must be added in the `e2e` directory.
2338

24-
Function names should follow the [Function Syntax Guidelines](ottlfuncs/README.md#function-syntax)
39+
#### Naming and Parameter Guidelines
40+
41+
Functions should be named and formatted according to the following standards.
42+
43+
- Function names MUST start with a verb unless it is a Factory that creates a new type.
44+
- Converters MUST be UpperCamelCase.
45+
- Function names that contain multiple words MUST separate those words with `_`.
46+
- Functions that interact with multiple items MUST have plurality in the name. Ex: `truncate_all`, `keep_keys`, `replace_all_matches`.
47+
- Functions that interact with a single item MUST NOT have plurality in the name. If a function would interact with multiple items due to a condition, like `where`, it is still considered singular. Ex: `set`, `delete`, `replace_match`.
48+
- Functions that change a specific target MUST set the target as the first parameter.
2549

50+
## New Values
51+
52+
When adding new values to the grammar you must:
53+
54+
1. Update the `Value` struct with the new value. This may also mean adding new token(s) to the lexer.
55+
2. Update `NewFunctionCall` to be able to handle calling functions with this new value.
56+
3. Update `NewGetter` to be able to handle the new value.
57+
4. Add new unit tests.

pkg/ottl/ottlfuncs/README.md

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,35 +2127,3 @@ The returned type is `int64`.
21272127
Examples:
21282128
21292129
- `Year(Now())`
2130-
2131-
## Function syntax
2132-
2133-
Functions should be named and formatted according to the following standards.
2134-
2135-
- Function names MUST start with a verb unless it is a Factory that creates a new type.
2136-
- Converters MUST be UpperCamelCase.
2137-
- Function names that contain multiple words MUST separate those words with `_`.
2138-
- Functions that interact with multiple items MUST have plurality in the name. Ex: `truncate_all`, `keep_keys`, `replace_all_matches`.
2139-
- Functions that interact with a single item MUST NOT have plurality in the name. If a function would interact with multiple items due to a condition, like `where`, it is still considered singular. Ex: `set`, `delete`, `replace_match`.
2140-
- Functions that change a specific target MUST set the target as the first parameter.
2141-
2142-
## Adding New Editors/Converters
2143-
2144-
Before raising a PR with a new Editor or Converter, raise an issue to verify its acceptance. While acceptance is strongly specific to a specific use case, consider these guidelines for early assessment.
2145-
2146-
Your proposal likely will be accepted if:
2147-
- The proposed functionality is missing,
2148-
- The proposed solution significantly improves user experience and readability for very common use cases,
2149-
- The proposed solution is more performant in cases where it is possible to achieve the same result with existing options.
2150-
2151-
It will be up for discussion if your proposal solves an issue that can be achieved in another way but does not improve user experience or performance.
2152-
2153-
Your proposal likely won't be accepted if:
2154-
- User experience is worse and assumes a highly technical user,
2155-
- The performance of your proposal very negatively affects the processing pipeline.
2156-
2157-
As with code, OTTL aims for readability first. This means:
2158-
- Using short, meaningful, and descriptive names,
2159-
- Ensuring naming consistency across Editors and Converters,
2160-
- Avoiding deep nesting to achieve desired transformations,
2161-
- Ensuring Editors and Converters have a single responsibility.

0 commit comments

Comments
 (0)