OpenTelemetry Bot d680729c09 [chore] Prepare release 0.90.0 (#29543) il y a 1 an
..
contexts f4c44858b5 [all][chore] Moved from interface{} to any for all go code (#29072) il y a 1 an
internal f4c44858b5 [all][chore] Moved from interface{} to any for all go code (#29072) il y a 1 an
ottlfuncs 533b72da8c feat: add IsDouble function (#29076) il y a 1 an
ottltest 5133f4ccd6 [chore] use license shortform (#22052) il y a 1 an
CONTRIBUTING.md db1aee576a [pkg/ottl] Add more function documentation (#16440) il y a 2 ans
LANGUAGE.md d6b1471839 [pkg/ottl] Restructure OTTL readme to make it easier to find functions and contexts (#29241) il y a 1 an
Makefile 577e279932 Flatten ottl package more, simplify structure (#14393) il y a 2 ans
README.md d6b1471839 [pkg/ottl] Restructure OTTL readme to make it easier to find functions and contexts (#29241) il y a 1 an
boolean_value.go 5133f4ccd6 [chore] use license shortform (#22052) il y a 1 an
boolean_value_test.go f4c44858b5 [all][chore] Moved from interface{} to any for all go code (#29072) il y a 1 an
compare.go 6ba05da264 feat: add boolean behavior for durations (#24272) il y a 1 an
compare_test.go f4c44858b5 [all][chore] Moved from interface{} to any for all go code (#29072) il y a 1 an
doc.go 8a3310964e [pkg/ottl] Add status header to readme (#27896) il y a 1 an
expression.go 78da59a4f6 [pkg/ottl] Add BoolGetter and IsBool converter (#27900) il y a 1 an
expression_test.go 78da59a4f6 [pkg/ottl] Add BoolGetter and IsBool converter (#27900) il y a 1 an
factory.go f4c44858b5 [all][chore] Moved from interface{} to any for all go code (#29072) il y a 1 an
functions.go 14ea97df5d Add an optional argument to converters to support hashing (#27235) il y a 1 an
functions_test.go f4c44858b5 [all][chore] Moved from interface{} to any for all go code (#29072) il y a 1 an
go.mod d680729c09 [chore] Prepare release 0.90.0 (#29543) il y a 1 an
go.sum 40b485f08a Update core for v0.90.0 release (#29539) il y a 1 an
grammar.go 501ef10fa2 [pkg/ottl] Fix issue with named parameter spacing (#28511) il y a 1 an
lexer_test.go 5133f4ccd6 [chore] use license shortform (#22052) il y a 1 an
math.go f4c44858b5 [all][chore] Moved from interface{} to any for all go code (#29072) il y a 1 an
math_test.go f4c44858b5 [all][chore] Moved from interface{} to any for all go code (#29072) il y a 1 an
metadata.yaml 8a3310964e [pkg/ottl] Add status header to readme (#27896) il y a 1 an
parser.go 8e09b1727d [pkg/ottl] Add ability to parse conditions (#29315) il y a 1 an
parser_test.go 8e09b1727d [pkg/ottl] Add ability to parse conditions (#29315) il y a 1 an

README.md

OpenTelemetry Transformation Language

Status
Stability alpha: traces, metrics, logs
Issues Open issues Closed issues
Code Owners @TylerHelmuth, @kentquirk, @bogdandrutu, @evan-bradley

The OpenTelemetry Transformation Language is a language for transforming open telemetry data based on the OpenTelemetry Collector Processing Exploration.

This package reads in OTTL statements and converts them to invokable functions/booleans based on the OTTL's grammar.

Getting Started

If you're looking to write OTTL statements for a component's configuration check out these resources.

See OTTL Functions for a list of functions available for use in the OTTL statements of most components.

OTTL Contexts define how you access the fields on a piece of telemetry. See the table to find the exact list of available fields:

Telemetry OTTL Context
Resource Resource
Instrumentation Scope Instrumentation Scode
Span Span
Span Event SpanEvent
Metric Metric
Datapoint DataPoint
Log Log

Component Creators

If you're looking to use OTTL in your component, check out the OTTL grammar.

Examples

These examples contain a SQL-like declarative language. Applied statements interact with only one signal, but statements can be declared across multiple signals. Functions used in examples are indicative of what could be useful.

Remove a forbidden attribute

traces:
  delete(attributes["http.request.header.authorization"])
metrics:
  delete(attributes["http.request.header.authorization"])
logs:
  delete(attributes["http.request.header.authorization"])

Remove all attributes except for some

traces:
  keep_keys(attributes, ["http.method", "http.status_code"])
metrics:
  keep_keys(attributes, ["http.method", "http.status_code"])
logs:
  keep_keys(attributes, ["http.method", "http.status_code"])

Reduce cardinality of an attribute

traces:
  replace_match(attributes["http.target"], "/user/*/list/*", "/user/{userId}/list/{listId}")

Reduce cardinality of a span name

traces:
  replace_match(name, "GET /user/*/list/*", "GET /user/{userId}/list/{listId}")

Reduce cardinality of any matching attribute

traces:
  replace_all_matches(attributes, "/user/*/list/*", "/user/{userId}/list/{listId}")

Decrease the size of the telemetry payload

traces:
  delete(resource.attributes["process.command_line"])
metrics:
  delete(resource.attributes["process.command_line"])
logs:
  delete(resource.attributes["process.command_line"])

Attach information from resource into telemetry

metrics:
  set(attributes["k8s_pod"], resource.attributes["k8s.pod.name"])

Decorate error spans with additional information

traces:
  set(attributes["whose_fault"], "theirs") where attributes["http.status"] == 400 or attributes["http.status"] == 404
  set(attributes["whose_fault"], "ours") where attributes["http.status"] == 500

Update a spans ID

logs:
  set(span_id, SpanID(0x0000000000000000))
traces:
  set(span_id, SpanID(0x0000000000000000))

Convert metric name to snake case

metrics:
  set(metric.name, ConvertCase(metric.name, "snake"))

Check if an attribute exists

traces:
  set(attributes["test-passed"], true) where attributes["target-attribute"] != nil