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
docs(debugger): split overview and applications, show examples close to the top (#29601)
* Add conditional operator examples to Expression Language doc
* docs(debugger): split overview and applications, show examples close to the top
Overview section is too wordy right now. Keep the introduction, show examples right after, talk about logs/metrics/conditions in a separate section.
---------
Co-authored-by: sstonehill12 <sarah.stonehill@datadoghq.com>
Copy file name to clipboardExpand all lines: content/en/tracing/dynamic_instrumentation/expression-language.md
+20-7Lines changed: 20 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,16 +9,18 @@ aliases:
9
9
10
10
The Dynamic Instrumentation Expression Language helps you formulate log probe message templates, metric probe expressions, span tag values, and probe conditions. It borrows syntax elements from common programming languages, but also has its own unique rules. The language lets you access local variables, method parameters, and nested fields within objects, and it supports the use of comparison and logical operators.
11
11
12
-
For example, you can create a histogram from the length of a string using `len(data)` as the metric expression. Metric expressions must evaluate to a number.
13
-
14
-
In log templates and tag values, expressions are delimited from the static parts of the template with brackets, for example: `User name is {user.name}`. Log template expressions can evaluate to any value. If evaluating the expression fails, it is replaced with `UNDEFINED`.
12
+
Examples:
13
+
-`someVar.someField`
14
+
-`request.headers["Host"]`
15
+
-`any(post.tags, {@it == "debugger"})`
16
+
-`@duration > 10 && len(p.data) < 100`
15
17
16
-
Probe conditions must evaluate to a Boolean, for example: `startsWith(user.name, "abc")`, `len(str) > 20` or `a == b`.
18
+
{{< img src="tracing/dynamic_instrumentation/expressions.png" alt="Example log probe with expressions" style="width:100%;" >}}
17
19
18
20
Generally, the Expression Language supports:
19
21
* Accessing local variables, method parameters, and deeply nested fields and attributes within objects.
20
22
* Using comparison operators (`<`, `>`, `>=`, `<=`, `==`, `!=`, `instanceof`) to compare variables, fields, and constants in your conditions, for example: `localVar1.field1.field2 != 15`.
21
-
* Using logical operators (`&&`, `||`, and `not` or `!`) to build complex Boolean conditions.
23
+
* Using logical operators (`&&`, `||`, and `!` or `not(...)`) to build complex Boolean conditions, for example: `!isEmpty(user.email) && not(contains(user.name, "abc"))`.
22
24
* Using the `null` literal (equivalent to `nil` in Python).
23
25
24
26
It does **not** support:
@@ -27,7 +29,18 @@ It does **not** support:
27
29
28
30
Try [autocomplete and search (in Preview)][6] for an improved user experience using the Expression Language.
29
31
30
-
The following sections summarize the variables and operations that the Dynamic Instrumentation Expression Language supports.
32
+
## Applications
33
+
34
+
Expressions can be used to produce metrics or logs, and as conditions to emit filtered data.
35
+
36
+
For example, you can create a histogram from the length of a string using `len(data)` as the metric expression. Metric expressions must evaluate to a number.
37
+
38
+
Logs can be emitted using templates. In log templates and tag values, expressions are delimited from the static parts of the template with brackets, for example: `User name is {user.name}`. Log template expressions can evaluate to any value. If evaluating the expression fails, it is replaced with `UNDEFINED`.
39
+
40
+
Probe conditions must evaluate to a Boolean, for example:
41
+
-`startsWith(user.name, "abc")`
42
+
-`len(str) > 20`
43
+
-`a == b`
31
44
32
45
## Contextual variables
33
46
@@ -36,7 +49,7 @@ The Expression Language provides contextual variables for different instrumentat
0 commit comments