Skip to content

Bug: OTLP gRPC Log Exporter fails to wrap logs in ExportLogsServiceRequest #4814

@pareshjoshij

Description

@pareshjoshij

Describe your environment

OS: (e.g, Ubuntu)
Python version: (e.g., Python 3.9.10)
SDK version: (e.g., 1.25.0)
API version: (e.g., 1.25.0)

What happened?

Describe the bug
The OTLPLogExporter (gRPC) fails to export logs because _translate_data returns the raw result of encode_logs (a list of ResourceLogs) instead of wrapping it in the ExportLogsServiceRequest envelope.

This results in a TypeError when the gRPC stub receives the data, as it expects the service request object.

To Reproduce

  1. Configure the OTLP Log Exporter with gRPC.
  2. Attempt to export a log batch.
  3. The export fails.

Expected behavior
The exporter should wrap the encoded logs in ExportLogsServiceRequest(resource_logs=...) before passing them to the stub.

Additional context
Also, the timeout argument in __init__ incorrectly overrides an explicit 0 value with the environment variable due to boolean or usage.

Steps to Reproduce

#Steps to Reproduce
Inspect _translate_data in opentelemetry/exporter/otlp/proto/grpc/exporter.py. It returns the raw output of encode_logs(data) directly. The gRPC stub expects an ExportLogsServiceRequest envelope, so this causes a type mismatch failure during export.

Expected Result The _translate_data method should return an ExportLogsServiceRequest object containing the encoded logs, not the raw logs list.

Expected Result

_translate_data should return an ExportLogsServiceRequest wrapper object. Also, passing timeout=0 should be respected as 0.

Actual Result

_translate_data returns a raw list (ResourceLogs), causing the export to fail with a type error. Also, timeout=0 is treated as None and overwritten by the default.

Additional context

No response

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions