Skip to content

[connector/otlpjson] Invalid OTLP payload is silently ignored #35739

@andrzej-stencel

Description

@andrzej-stencel

Component(s)

connector/otlpjson

What happened?

Description

The OTLP/JSON connector reports errors on invalid JSON, but silently ignores valid JSON that is not valid OTLP. I would expect it to also error out on valid JSON that is not valid OTLP. As another enhancement, an error_mode option could be added for users to configure the behavior.

Steps to Reproduce

  1. Prepare a newline-delimited JSON file like the below non-otlp.json file:

    {"one":"two"}
    {"this":{"is": {"not": "otlp"}}}
  2. Run the collector with the below configuration, reading the file with Filelog receiver and passing it to OTLP/JSON connector and to Debug exporter.

Expected Result

The OTLP/JSON connector rejects the input lines, outputting an error message saying that the input is not valid OTLP.

Actual Result

The connector does not report any errors. It emits an empty batch for each invalid OTLP line (see related issue #35738).

Collector version

v0.111.0

Environment information

Environment

OS: Ubuntu 24.04

OpenTelemetry Collector configuration

connectors:
  otlpjson:
exporters:
  debug:
    verbosity: basic
receivers:
  filelog:
    include:
      - non-otlp.json
    start_at: beginning
service:
  pipelines:
    logs/input:
      exporters: [otlpjson]
      receivers: [filelog]
    logs/otlp:
      exporters: [debug]
      receivers: [otlpjson]

Log output

2024-10-11T12:40:27.217+0200    info    [email protected]/service.go:136 Setting up own telemetry...
2024-10-11T12:40:27.217+0200    info    telemetry/metrics.go:70 Serving metrics {"address": "localhost:8888", "metrics level": "Normal"}
2024-10-11T12:40:27.217+0200    info    builders/builders.go:26 Development component. May change in the future.        {"kind": "exporter", "data_type": "logs", "name": "debug"}
2024-10-11T12:40:27.218+0200    info    [email protected]/logs.go:27   Building otlpjson connector for logs    {"kind": "connector", "name": "otlpjson", "exporter_in_pipeline": "logs", "receiver_in_pipeline": "logs"}
2024-10-11T12:40:27.219+0200    info    [email protected]/service.go:208 Starting otelcol-contrib...     {"Version": "0.111.0", "NumCPU": 20}
2024-10-11T12:40:27.219+0200    info    extensions/extensions.go:39     Starting extensions...
2024-10-11T12:40:27.219+0200    info    adapter/receiver.go:47  Starting stanza receiver        {"kind": "receiver", "name": "filelog", "data_type": "logs"}
2024-10-11T12:40:27.219+0200    info    [email protected]/service.go:234 Everything is ready. Begin running and processing data.
2024-10-11T12:40:27.420+0200    info    fileconsumer/file.go:256        Started watching file   {"kind": "receiver", "name": "filelog", "data_type": "logs", "component": "fileconsumer", "path": "non-otlp.json"}
2024-10-11T12:40:27.521+0200    info    LogsExporter    {"kind": "exporter", "data_type": "logs", "name": "debug", "resource logs": 0, "log records": 0}
2024-10-11T12:40:27.521+0200    info    LogsExporter    {"kind": "exporter", "data_type": "logs", "name": "debug", "resource logs": 0, "log records": 0}

Additional context

The Unmarshal(Logs|Metrics|Traces) methods do not return an error for valid JSON that is not a valid OTLP payload. They just return an empty object of logs/metrics/traces data. See https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.111.0/connector/otlpjsonconnector/traces.go#L55 for example.

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