Skip to content

Commit 1c37438

Browse files
TylerHelmuthevan-bradleyedmocosta
authored
[processor/transform] more readme refactoring (#37909)
#### Description With the new context inference feature the user needs to know less about the concept of an OTTL Context. This refactor restructures the README some more to try really hard not to talk about OTTL context and instead talk about OTTL Paths, which is the concrete thing the user needs to know to write an OTTL statement. #### Link to tracking issue #29017 --------- Co-authored-by: Evan Bradley <[email protected]> Co-authored-by: Edmo Vamerlatti Costa <[email protected]>
1 parent 235afe9 commit 1c37438

File tree

2 files changed

+167
-227
lines changed

2 files changed

+167
-227
lines changed

pkg/ottl/README.md

+28-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,27 @@ This package implements everything necessary to use OTTL in a Collector componen
1818
- [Troubleshooting](#troubleshooting)
1919
- [Resources](#resources)
2020

21+
2122
## Getting Started
2223

23-
If you're looking to write OTTL statements for a component's configuration check out these resources.
24+
An OTTL statement is made up of 2 parts:
25+
1. A function that transforms telemetry
26+
2. Optionally, a condition that determines whether the function is executed.
27+
28+
Here is an example OTTL statement:
29+
30+
```
31+
set(span.attributes["test"], "pass") where span.attributes["test"] == nil
32+
```
33+
34+
This statement sets a new span attribute named `"test"` with a value of `"pass"` whenever the span does not already
35+
have an attribute named `"test"`. In this example, the **function** is `set`, which uses the second parameter to set the value of the first parameter, and the **condition** is `span.attributes["test"] == nil`.
2436

25-
See [OTTL Functions](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/ottlfuncs#ottl-functions) for a list of functions available for use in the OTTL statements of most components.
37+
Within a statement you utilize OTTL Paths to access telemetry. The example uses the Path `span.attributes` to access
38+
the span's attributes. For each Open Telemetry Signal, OTTL has a Path to every field (plus some extras to help make
39+
interacting with the data easier).
2640

27-
OTTL Contexts define how you access the fields on a given telemetry item. See the table to find the exact list of available fields:
41+
To see a list of available Paths for each Open Telemetry Signal, checkout the links below.
2842

2943
| Telemetry | OTTL Context |
3044
|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
@@ -36,7 +50,17 @@ OTTL Contexts define how you access the fields on a given telemetry item. See th
3650
| `Datapoint` | [DataPoint](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/contexts/ottldatapoint/README.md) |
3751
| `Log` | [Log](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/contexts/ottllog/README.md) |
3852

39-
To understand what OTTL offers as a language, check out [OTTL's grammar doc](./LANGUAGE.md).
53+
OTTL does not support cross-signal interactions at this time. That means you cannot write a statement like
54+
55+
```
56+
set(span.attributes["log body"], log.body)
57+
```
58+
59+
See [OTTL Functions](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/ottlfuncs#ottl-functions) for a list of functions available for use in OTTL statements of most components.
60+
61+
To see more examples of OTTL statements, checkout the [Transform Processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/transformprocessor/README.md#examples)
62+
63+
There is a lot more OTTL can do, like nested functions, arithmetic, indexing, and enums. To explore it further check out [OTTL's grammar doc](./LANGUAGE.md).
4064

4165
## Where to use OTTL
4266

0 commit comments

Comments
 (0)