opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

Allow exporting logs using OTLP exporter

Open kushal-ti opened this issue 3 years ago • 12 comments
trafficstars

Is your feature request related to a problem? Please describe.

Exporting logs from the application to otel collector directly using an otlp exporter is not possible

A clear and concise description of what the problem is.

It is possible to export traces and metrics to an otel collector, from which they can then be processed and further exported to other sources as required. However, the same is not possible with logs. When logs are attempted to be sent over HTTP to the otel /v1/logs/ endpoint, it returns a 400 bad request error because the logs are not formatted in the OTLP format

Describe the solution you'd like

Integrations into common loggers like winston that would allow exporting the logs into OTLP format, similar to traces exporter and metrics exporter, we could have a logs exported

Describe alternatives you've considered

  1. Changing logging configuration to structure logs in the required OTLP format and then sending them to the collector over http
  2. Using a middle man like fluent-bit to collect logs from stdout and send them over to the otel collector Both approaches are tedious and less desirable than having a logs exporter

kushal-ti avatar Jun 27 '22 08:06 kushal-ti

We actually discussed this in the last SIG meeting and as far as I remember someone was interested in starting work on this. There were a couple people interested in the topic. Logs work hasn't really started yet in JS since the maintainers are already stretched a bit thin and trying to focus on getting the metrics SDK ready for GA.

dyladan avatar Jun 27 '22 16:06 dyladan

I find that the logs specification is not yet feature-freeze, so it might be worth waiting for the spec to be ready?

legendecas avatar Jun 28 '22 02:06 legendecas

I think the data model is stable and has been for a while. Creating at least the exporter and a basic experimental sdk shouldn't be too much work and is unlikely to be broken by future spec. I don't have time to work on this, but I wouldn't block anyone who wants to work on this. I think @martinkuba mentioned in a SIG meeting he may have some interest?

dyladan avatar Jun 28 '22 18:06 dyladan

That is correct - I am interested in working on this along with a prototype for the Events API.

martinkuba avatar Jun 29 '22 16:06 martinkuba

I'm not sure how best I can help, but I'm also interested in this! Been using the Logs Exporter in .NET projects to nice success.

RichiCoder1 avatar Jul 17 '22 21:07 RichiCoder1

I did a (very naive) implementation of this for Cloudflare Workers, and am game to take this on or assist too!

Reading https://github.com/open-telemetry/opentelemetry-specification/issues/2506 it sounds like the "API" is currently undefined except the types defined in the SDK spec. Would an @opentelemetry/api-logs just contain the base types for now? With Noop (ConsoleLog?) Emitter.

Following on, would a good MVP be @opentelemetry/sdk-logs-base and a @opentelemetry/exporter-logs-otlp-* set of exporters?

RichiCoder1 avatar Jul 22 '22 18:07 RichiCoder1

Would an @opentelemetry/api-logs just contain the base types for now? With Noop (ConsoleLog?) Emitter.

I think just having a SDK is the right way, at least thats how java sig went: https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk/logs/src/main/java/io/opentelemetry/sdk/logs

vmarchaud avatar Jul 23 '22 09:07 vmarchaud

Actually it seems that the API is on its way: https://github.com/open-telemetry/opentelemetry-specification/pull/2676

vmarchaud avatar Jul 23 '22 12:07 vmarchaud

Actually it seems that the API is on its way: open-telemetry/opentelemetry-specification#2676

Yup! I figure I can start working from the above assumption and circle back around the API once it's officially landed in the spec. That at least allows instrumenting loggers (and potentially console).

Edit: though the API is looking fairly simple...

RichiCoder1 avatar Jul 23 '22 17:07 RichiCoder1

I put this aside while the API was being discussed, and I have opened a draft implementation of the API.

martinkuba avatar Jul 26 '22 21:07 martinkuba

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Sep 26 '22 06:09 github-actions[bot]

This issue was closed because it has been stale for 14 days with no activity.

github-actions[bot] avatar Oct 31 '22 06:10 github-actions[bot]

@kushal-ti The Log SDK is now implemented as well as three log exporters https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/exporter-logs-otlp-grpc https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/exporter-logs-otlp-http https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/exporter-logs-otlp-proto

martinkuba avatar Jun 06 '23 00:06 martinkuba

The initial ask of the issue that fits the scope of this repository is done (exporting Logs via OTLP), so I'm closing this issue. :slightly_smiling_face:

Integrations into common loggers like winston that would allow exporting the logs into OTLP format, similar to traces exporter and metrics exporter, we could have a logs exported

A request for a winston integration would be very fitting for the open-telemetry/opentelemetry-js-contrib repository, which is home to instrumentations that take care of this type of thing. If this is something of interest, please open an issue there. :slightly_smiling_face:

pichlermarc avatar Jun 06 '23 15:06 pichlermarc