Skip to content

Opentelemetry metadata and attributes are lost when wasm filter is usedΒ #11302

@akaluzinski

Description

@akaluzinski

Bug Report

Describe the bug
OpenTelemetry group attributes and scopes are lost when opentelemetry input is used with wasm filter.

To Reproduce
Prerequisite: Create and build blank WASM plugin.

//export debugFn
func debugFn(tag *uint8, tagLen uint, timeSec uint32, timeNsec uint32, record *uint8, recordLen uint) *uint8 {
	// some business filtering logic would be added here.
	return record
}

Case A) (Incorrect)

Step 1) Create configuration with opentelemetry input and wasm filter and start HTTP server.

Configuration:

service:
  http_port: 2020

pipeline:
  inputs:
    - name: opentelemetry

  filters:
    - name: wasm
      match: 'v1_logs'
      function_name: 'debugFn'
      wasm_path: /fluent-bit/lib/filter/debug.wasm

  outputs:
    - name: stdout
      match: '*'

Step 2) Send HTTP request to fluent-bit that contains group attributes and scopes.

curl --header "Content-Type: application/json" --request POST --data '{"resourceLogs":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"filter-service"}}]},"scopeLogs":[{"scope":{"name":"my.scope"},"logRecords":[{"timeUnixNano":"1660296023390371588","body":{"stringValue":"{\"message\":\"dummy\"}"}}]}]}]}'   http://0.0.0.0:4318/v1/logs

Data missing: Output does not contain attributes and resource logs:

[2025/12/19 13:48:25.435367475] [ info] [output:stdout:stdout.0] worker #0 started
[0] v1_logs: [[1660296023.1698112429, {"otlp"=>{}}], {"log"=>"{"message":"dummy"}"}]

Case B) (Working)

Create configuration with dummy input processed by opentelemetry_envelope and wasm filter.
Use the same dummy's input as was sent in Case A.

service:
  http_port: 2020

pipeline:
  inputs:
    - name: dummy
      dummy: |-
        {
          "resourceLogs": [
            {
              "resource": {
                "attributes": [
                  {
                    "key": "service.name",
                    "value": {
                      "stringValue": "filter-service"
                    }
                  }
                ]
              },
              "scopeLogs": [
                {
                  "scope": {
                    "name": "my.scope"
                  },
                  "logRecords": [
                    {
                      "timeUnixNano": "1660296023390371588",
                      "body": {
                        "stringValue": "{\"message\":\"dummy\"}"
                      }
                    }
                  ]
                }
              ]
            }
          ]
        }
      tag: 'v1_logs'
      processors:
        logs:
          - name: opentelemetry_envelope

  filters:
    - name: wasm
      match: 'v1_logs'
      function_name: 'debugFn'
      wasm_path: /fluent-bit/lib/filter/debug.wasm
      wasm_heap_size: 256KB
      wasm_stack_size: 256KB

  outputs:
    - name: stdout
      match: '*'

Output contains attributes and scopeLogs as expected:

[2025/12/19 13:45:28.787731766] [ info] [output:stdout:stdout.0] worker #0 started
[0] v1_logs: [[1766151929.431803891, {}], {"resourceLogs"=>[{"resource"=>{"attributes"=>[{"key"=>"service.name", "value"=>{"stringValue"=>"filter-service"}}]}, "scopeLogs"=>[{"scope"=>{"name"=>"my.scope"}, "logRecords"=>[{"timeUnixNano"=>"1660296023390371588", "body"=>{"stringValue"=>"{"message":"dummy"}"}}]}]}]}]

Case C) (Working)
Create configuration with opentelemetry input and no wasm filter and start HTTP server.

service:
  http_port: 2020

pipeline:
  inputs:
    - name: opentelemetry

  outputs:
    - name: stdout
      match: '*'

Step 2) Send HTTP request to fluent-bit that contains group attributes and scopes.

curl --header "Content-Type: application/json" --request POST --data '{"resourceLogs":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"filter-service"}}]},"scopeLogs":[{"scope":{"name":"my.scope"},"logRecords":[{"timeUnixNano":"1660296023390371588","body":{"stringValue":"{\"message\":\"dummy\"}"}}]}]}]}'   http://0.0.0.0:4318/v1/logs

Output contains group attributes and metadata as expected.

[2025/12/19 13:50:30.837814660] [ info] [output:stdout:stdout.0] worker #0 started
GROUP METADATA : 

{"schema"=>"otlp", "resource_id"=>0, "scope_id"=>0}

GROUP ATTRIBUTES : 

{"resource"=>{"attributes"=>{"service.name"=>"filter-service"}}, "scope"=>{"name"=>"my.scope"}}

[0] v1_logs: [[1660296023.1698112429, {"otlp"=>{}}], {"log"=>"{"message":"dummy"}"}]

Expected behavior
I expected that using opentelemetry filter together with wasm filter would not not remove group attributes and metadata.

Screenshots
Image

Your Environment

  • Version used: v4.2.1

  • Configuration: see cases above.

  • Environment name and version (e.g. Kubernetes? What version?): Docker running on localhost

  • Server type and version: N/A

  • Operating System and version: macOS 15.7.3

  • Filters and plugins: opentelemetry, wasm, stdout

Additional context
Parts of original message are lost but could contain important information.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions