Skip to content

Commit 7ac560f

Browse files
axwevan-bradley
andauthored
pkg/ottl: add section about design principles (#29424)
**Description:** Drawing inspiration from https://github.com/bazelbuild/starlark#design-principles and https://github.com/google/cel-spec/blob/master/doc/langdef.md#overview, add a brief section about design principles. The aim of this is to ensure OTTL is and remains safe for execution of untrusted programs in multi-tenant systems, where tenants can provide their own OTTL programs. --------- Co-authored-by: Evan Bradley <[email protected]>
1 parent 541bbd1 commit 7ac560f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

pkg/ottl/LANGUAGE.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
The OTTL grammar includes function invocations, Values and Boolean Expressions. These parts all fit into a Statement, which is the basis of execution in the OTTL.
44

5+
### Design principles
6+
7+
OTTL is intended as a domain-specific language (DSL) for telemetry mutation and generation,
8+
and is not intended to be used as a general-purpose programming language.
9+
10+
OTTL has been designed to work directly with [pdata](https://github.com/open-telemetry/opentelemetry-collector/tree/main/pdata), but can operate on other data formats.
11+
512
### Editors
613

714
Editors are functions that transform the underlying telemetry payload. They may return a value, but typically do not. There must be a single Editor Invocation in each OTTL statement.
@@ -288,4 +295,4 @@ It is possible to update the Value in a telemetry field using a Setter. For read
288295

289296
## Logging inside a OTTL function
290297

291-
To emit logs inside a OTTL function, add a parameter of type [`component.TelemetrySettings`](https://pkg.go.dev/go.opentelemetry.io/collector/component#TelemetrySettings) to the function signature. The OTTL will then inject the TelemetrySettings that were passed to `NewParser` into the function. TelemetrySettings can be used to emit logs.
298+
To emit logs inside a OTTL function, add a parameter of type [`component.TelemetrySettings`](https://pkg.go.dev/go.opentelemetry.io/collector/component#TelemetrySettings) to the function signature. The OTTL will then inject the TelemetrySettings that were passed to `NewParser` into the function. TelemetrySettings can be used to emit logs.

pkg/ottl/ottlfuncs/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ This document contains documentation for both types of OTTL functions:
88
- [Functions](#functions) that transform telemetry.
99
- [Converters](#converters) that provide utilities for transforming telemetry.
1010

11+
## Design principles
12+
13+
For the standard OTTL functions described in this document, we specify design principles to ensure they are always
14+
secure and safe for use:
15+
16+
- Built-in OTTL functions may not access the file system, network, or any other I/O devices.
17+
- Built-in OTTL functions may share information only through their parameters and results.
18+
- Built-in OTTL functions must be terminating; they must not loop forever.
19+
20+
OTTL functions are implemented in Go, and so are only limited by what can be implemented in a Go program.
21+
User-defined OTTL functions may therefore not adhere the above principles.
22+
1123
## Working with functions
1224

1325
Functions generally expect specific types to be returned by `Paths`.

0 commit comments

Comments
 (0)