You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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]>
Copy file name to clipboardExpand all lines: pkg/ottl/README.md
+28-4
Original file line number
Diff line number
Diff line change
@@ -18,13 +18,27 @@ This package implements everything necessary to use OTTL in a Collector componen
18
18
-[Troubleshooting](#troubleshooting)
19
19
-[Resources](#resources)
20
20
21
+
21
22
## Getting Started
22
23
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`.
24
36
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).
26
40
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.
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).
0 commit comments