Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support opentelemetry traces in json format from file #9982

Open
gaurang101197 opened this issue Feb 21, 2025 · 3 comments
Open

Support opentelemetry traces in json format from file #9982

gaurang101197 opened this issue Feb 21, 2025 · 3 comments

Comments

@gaurang101197
Copy link

gaurang101197 commented Feb 21, 2025

Is your feature request related to a problem? Please describe.
We write application traces in file as json(schema: trace.json). I want to tail this trace file and ingest into opentelemetry collector using opentelemetry output plugin. When I try to tail this file, traces are ingested as logs instead of traces.

Sample trace.log file

{ "resourceSpans": [ { "resource": { "attributes": [ { "key": "service.name", "value": { "stringValue": "my.service" } } ] }, "scopeSpans": [ { "scope": { "name": "my.library", "version": "1.0.0", "attributes": [ { "key": "my.scope.attribute", "value": { "stringValue": "some scope attribute" } } ] }, "spans": [ { "traceId": "5B8EFFF798038103D269B633813FC60C", "spanId": "EEE19B7EC3C1B174", "parentSpanId": "EEE19B7EC3C1B173", "name": "I'm a server span", "startTimeUnixNano": "1544712660000000000", "endTimeUnixNano": "1544712661000000000", "kind": 2, "attributes": [ { "key": "my.span.attr", "value": { "stringValue": "some value" } } ] } ] } ] } ] }

fluent-bit.conf:

[SERVICE]
    Flush                1
    Log_level            debug

[INPUT]
    Name               tail
    Path                 ./trace.log
    Tag                  app_traces
    Read_from_head       true

[OUTPUT]
    Name                                opentelemetry
    Match                               *
    Host                                127.0.0.1
    Port                                4318
    Metrics_uri                         /v1/metrics
    Logs_uri                            /v1/logs
    Traces_uri                          /v1/traces
    Log_response_payload                True
    Tls                                 Off
    Tls.verify                          Off

Otel-collector.yml

receivers:
  otlp:
    protocols:
      http:
        endpoint: "127.0.0.1:4318"
      grpc:
        endpoint: "127.0.0.1:4317"

processors:
  batch:
    timeout: 1s
    send_batch_size: 1024

exporters:
  debug:
    verbosity: detailed
  file:
    path: ./otel-collector.json

service:
  telemetry:
    logs:
      level: "debug"
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug, file]
    metrics:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug]
    logs:
      receivers: [otlp]
      processors: [batch]
      exporters: [debug] 

Describe the solution you'd like
Able to Read traces as json and ingest them to otel-collector. Something similar to opentelemetry_envelope which support converting trace json to opentelemetry schema which can be feed to opentelemetry output plugin.

@edsiper
Copy link
Member

edsiper commented Feb 21, 2025

done for OpenTelemetry input:

#9938

this will be available in v3.2.7 (this week) and further versions

ah! you want to read from a file, #9938 supports over the network in the Opentelemetry input plugin.

Tail generate logs only and each line is a log line.

@gaurang101197
Copy link
Author

you want to read from a file

Yes, I want to scrape traces printed as JSON from logs and ingest them to otel collector. Idea behind this is to use log for sending traces instead of sending traces over http call from application. We don't want to add extra http call to application for sending traces, instead application can print them as json logs and fluent bit pipeline can off load ingesting those traces from logs to otel collector.

@gaurang101197 gaurang101197 changed the title Support opentelemetry traces in json format Support opentelemetry traces in json format from file Feb 24, 2025
@gaurang101197
Copy link
Author

Looks like opentelemetry_envelope don't support traces as of now. It will be great if we add support of processing trace json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants