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
@@ -126,6 +128,7 @@ The `merge_maps` function merges the source map into the target map using the su
126
128
`target` is a `pdata.Map` type field. `source` is a `pdata.Map` type field. `strategy` is a string that must be one of `insert`, `update`, or `upsert`.
127
129
128
130
If strategy is:
131
+
129
132
-`insert`: Insert the value from `source` into `target` where the key does not already exist.
130
133
-`update`: Update the entry in `target` with the value from `source` where the key does exist.
131
134
-`upsert`: Performs insert or update. Insert the value from `source` into `target` where the key does not already exist and update the entry in `target` with the value from `source` where the key does exist.
The `replace_all_matches` function replaces any matching string value with the replacement string.
150
153
151
-
`target` is a path expression to a `pdata.Map` type field. `pattern` is a string following [filepath.Match syntax](https://pkg.go.dev/path/filepath#Match). `replacement` is either a path expression to a string telemetry field or a literal string.
154
+
`target` is a path expression to a `pdata.Map` type field. `pattern` is a string following [filepath.Match syntax](https://pkg.go.dev/path/filepath#Match). `replacement` is either a path expression to a string telemetry field or a literal string.`function` is an optional argument that can take in any Converter that accepts a (`replacement`) string and returns a string. An example is a hash function that replaces any matching string with the hash value of `replacement`.
152
155
153
156
Each string value in `target` that matches `pattern` will get replaced with `replacement`. Non-string values are ignored.
154
157
@@ -158,10 +161,11 @@ There is currently a bug with OTTL that does not allow the pattern to end with `
The `replace_all_patterns` function replaces any segments in a string value or key that match the regex pattern with the replacement string.
167
171
@@ -173,6 +177,8 @@ If one or more sections of `target` match `regex` they will get replaced with `r
173
177
174
178
The `replacement` string can refer to matched groups using [regexp.Expand syntax](https://pkg.go.dev/regexp#Regexp.Expand).
175
179
180
+
The `function` is an optional argument that can take in any Converter that accepts a (`replacement`) string and returns a string. An example is a hash function that replaces any matching regex pattern with the hash value of `replacement`.
181
+
176
182
There is currently a bug with OTTL that does not allow the pattern to end with `\\"`.
177
183
If your pattern needs to end with backslashes, add something inconsequential to the end of the pattern such as `{1}`, `$`, or `.*`.
178
184
[See Issue 23238 for details](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/23238).
The `replace_match` function allows replacing entire strings if they match a glob pattern.
195
202
196
203
`target` is a path expression to a telemetry field. `pattern` is a string following [filepath.Match syntax](https://pkg.go.dev/path/filepath#Match). `replacement` is either a path expression to a string telemetry field or a literal string.
197
204
198
205
If `target` matches `pattern` it will get replaced with `replacement`.
199
206
207
+
The `function` is an optional argument that can take in any Converter that accepts a (`replacement`) string and returns a string. An example is a hash function that replaces any matching glob pattern with the hash value of `replacement`.
208
+
200
209
There is currently a bug with OTTL that does not allow the pattern to end with `\\"`.
201
210
[See Issue 23238 for details](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/23238).
The `replace_pattern` function allows replacing all string sections that match a regex pattern with a new value.
212
222
@@ -216,6 +226,8 @@ If one or more sections of `target` match `regex` they will get replaced with `r
216
226
217
227
The `replacement` string can refer to matched groups using [regexp.Expand syntax](https://pkg.go.dev/regexp#Regexp.Expand).
218
228
229
+
The `function` is an optional argument that can take in any Converter that accepts a (`replacement`) string and returns a string. An example is a hash function that replaces a matching regex pattern with the hash value of `replacement`.
230
+
219
231
There is currently a bug with OTTL that does not allow the pattern to end with `\\"`.
220
232
If your pattern needs to end with backslashes, add something inconsequential to the end of the pattern such as `{1}`, `$`, or `.*`.
221
233
[See Issue 23238 for details](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/23238).
Note that when using OTTL within the collector's configuration file, `$` must be escaped to `$$` to bypass
229
242
environment variable substitution logic. To input a literal `$` from the configuration file, use `$$$`.
@@ -275,6 +288,7 @@ Converters are pure functions that take OTTL values as input and output a single
275
288
Unlike functions, they do not modify any input telemetry and always return a value.
276
289
277
290
Available Converters:
291
+
278
292
-[Concat](#concat)
279
293
-[ConvertCase](#convertcase)
280
294
-[ExtractPatterns](#extractpatterns)
@@ -373,9 +387,9 @@ Examples:
373
387
374
388
The `ExtractPatterns` Converter returns a `pcommon.Map` struct that is a result of extracting named capture groups from the target string. If not matches are found then an empty `pcommon.Map` is returned.
375
389
376
-
`target` is a Getter that returns a string. `pattern` is a regex string.
390
+
`target` is a Getter that returns a string. `pattern` is a regex string.
377
391
378
-
If `target` is not a string or nil `ExtractPatterns` will return an error. If `pattern` does not contain at least 1 named capture group then `ExtractPatterns` will error on startup.
392
+
If `target` is not a string or nil `ExtractPatterns` will return an error. If `pattern` does not contain at least 1 named capture group then `ExtractPatterns` will error on startup.
379
393
380
394
Examples:
381
395
@@ -425,10 +439,11 @@ The `Int` Converter converts the `value` to int type.
425
439
The returned type is int64.
426
440
427
441
The input `value` types:
428
-
* float64. Fraction is discharged (truncation towards zero).
429
-
* string. Trying to parse an integer from string if it fails then nil will be returned.
430
-
* bool. If `value` is true, then the function will return 1 otherwise 0.
431
-
* int64. The function returns the `value` without changes.
442
+
443
+
- float64. Fraction is discharged (truncation towards zero).
444
+
- string. Trying to parse an integer from string if it fails then nil will be returned.
445
+
- bool. If `value` is true, then the function will return 1 otherwise 0.
446
+
- int64. The function returns the `value` without changes.
432
447
433
448
If `value` is another type or parsing failed nil is always returned.
434
449
@@ -531,8 +546,8 @@ If target is not a float64, it will be converted to one:
531
546
532
547
- int64s are converted to float64s
533
548
- strings are converted using `strconv`
534
-
- booleans are converted using `1` for `true` and `0` for `false`. This means passing `false` to the function will cause an error.
535
-
- int, float, string, and bool OTLP Values are converted following the above rules depending on their type. Other types cause an error.
549
+
- booleans are converted using `1` for `true` and `0` for `false`. This means passing `false` to the function will cause an error.
550
+
- int, float, string, and bool OTLP Values are converted following the above rules depending on their type. Other types cause an error.
536
551
537
552
If target is nil an error is returned.
538
553
@@ -713,7 +728,7 @@ Examples:
713
728
714
729
### Split
715
730
716
-
`Split(target, delimiter)`
731
+
```Split(target, delimiter)```
717
732
718
733
The `Split` Converter separates a string by the delimiter, and returns an array of substrings.
719
734
@@ -726,7 +741,7 @@ There is currently a bug with OTTL that does not allow the target string to end
726
741
727
742
Examples:
728
743
729
-
-```Split("A|B|C", "|")```
744
+
-`Split("A|B|C", "|")`
730
745
731
746
### Substring
732
747
@@ -773,7 +788,7 @@ Examples:
773
788
774
789
The `TruncateTime` Converter returns the given time rounded down to a multiple of the given duration. The Converter [uses the `time.Truncate` function](https://pkg.go.dev/time#Time.Truncate).
775
790
776
-
`time` is a `time.Time`. `duration` is a `time.Duration`. If `time` is not a `time.Time` or if `duration` is not a `time.Duration`, an error will be returned.
791
+
`time` is a `time.Time`. `duration` is a `time.Duration`. If `time` is not a `time.Time` or if `duration` is not a `time.Duration`, an error will be returned.
777
792
778
793
While some common paths can return a `time.Time` object, you will most like need to use the [Duration Converter](#duration) to create a `time.Duration`.
779
794
@@ -846,9 +861,10 @@ The `UUID` function generates a v4 uuid string.
846
861
## Function syntax
847
862
848
863
Functions should be named and formatted according to the following standards.
864
+
849
865
- Function names MUST start with a verb unless it is a Factory that creates a new type.
850
866
- Converters MUST be UpperCamelCase.
851
867
- Function names that contain multiple words MUST separate those words with `_`.
852
-
- Functions that interact with multiple items MUST have plurality in the name. Ex: `truncate_all`, `keep_keys`, `replace_all_matches`.
853
-
- 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`.
868
+
- Functions that interact with multiple items MUST have plurality in the name. Ex: `truncate_all`, `keep_keys`, `replace_all_matches`.
869
+
- 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`.
854
870
- Functions that change a specific target MUST set the target as the first parameter.
0 commit comments