open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
2.88k stars 2.25k forks source link

Observed timestamp in logs is not exported to clickhouse #34150

Open pimeys opened 1 month ago

pimeys commented 1 month ago

Component(s)

exporter/clickhouse

What happened?

Description

Exporting logs from opentelemetry-rust stores zero timestamps to clickhouse.

Steps to Reproduce

  1. Send logs to opentelemetry-collector-contrib server from a Rust application using opentelemetry-rust
  2. Export to clickhouse
  3. Timestamps are zero

Expected Result

The exporter should look first the timestamp and if null take the value from the observed timestamp field.

Actual Result

The exporter only reads the timestamp field, blindly converts it to timestamp and stores a zero value to clickhouse.

https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/clickhouseexporter/exporter_logs.go#L93

Collector version

v0.105.0

Environment information

Environment

OS: The official collector docker image ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.105.0

OpenTelemetry Collector configuration

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317

processors:
  batch:
    send_batch_size: 100000
    timeout: 1s

exporters:
  clickhouse:
    endpoint: tcp://clickhouse:9000
    database: otel
    ttl: 48h
    timeout: 10s
    sending_queue:
      queue_size: 100
    retry_on_failure:
      enabled: true
      initial_interval: 5s
      max_interval: 30s
      max_elapsed_time: 300s

extensions:
  health_check:

service:
  extensions: [health_check]
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [clickhouse]
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [clickhouse]
    logs:
      receivers: [otlp]
      processors: [batch]
      exporters: [clickhouse]

Log output

No response

Additional context

Should be a quick fix, I'm not a Go developer but planning to take a look :)

github-actions[bot] commented 1 month ago

Pinging code owners:

crobert-1 commented 1 month ago

Code owners have approved the PR resolving this, removing needs triage.