EDXDataType

Learn about the EDXDataType Edge Delta OTTL extension function.

Minimum Agent Version: v1.32.0

EDXDataType fills a gap in standard OTTL which lacks type introspection capabilities. While OTTL provides type conversion functions like Int and String, it doesn’t offer a way to determine the current type of a field. This Edge Delta extension enables you to inspect data types at runtime, which is essential for debugging, conditional processing, and data validation.

Syntax

EDXDataType(input)
  • input: The field or value whose data type you want to determine.

Input

{
  "_type": "log",
  "timestamp": 1735789400000,
  "body": "Test log message",
  "resource": {...},
  "attributes": {
    "string_field": "hello",
    "number_field": 42,
    "float_field": 3.14,
    "boolean_field": true,
    "null_field": null,
    "array_field": ["item1", "item2"],
    "map_field": {
      "key1": "value1",
      "key2": "value2"
    }
  }
}

Example

set(attributes["types"]["string_type"], EDXDataType(attributes["string_field"]))
set(attributes["types"]["number_type"], EDXDataType(attributes["number_field"]))
set(attributes["types"]["float_type"], EDXDataType(attributes["float_field"]))
set(attributes["types"]["boolean_type"], EDXDataType(attributes["boolean_field"]))
set(attributes["types"]["null_type"], EDXDataType(attributes["null_field"]))
set(attributes["types"]["array_type"], EDXDataType(attributes["array_field"]))
set(attributes["types"]["map_type"], EDXDataType(attributes["map_field"]))
set(attributes["types"]["body_type"], EDXDataType(body))

Output

{
  "_type": "log",
  "timestamp": 1735789430000,
  "body": "Test log message",
  "resource": {...},
  "attributes": {
    "string_field": "hello",
    "number_field": 42,
    "float_field": 3.14,
    "boolean_field": true,
    "null_field": null,
    "array_field": ["item1", "item2"],
    "map_field": {
      "key1": "value1",
      "key2": "value2"
    },
    "types": {
      "string_type": "string",
      "number_type": "int",
      "float_type": "float",
      "boolean_type": "bool",
      "null_type": "nil",
      "array_type": "array",
      "map_type": "map",
      "body_type": "bytes"
    }
  }
}

The EDXDataType function has identified the data type of each field, returning type names such as “string”, “int”, “float”, “bool”, “nil”, “array”, “map”, and “bytes” (for the body field which is a byte array).