open-telemetry / opentelemetry-js-contrib

OpenTelemetry instrumentation for JavaScript modules
https://opentelemetry.io
Apache License 2.0
710 stars 529 forks source link

Instrumentation to capture console logs as OTel logs #1560

Open martinkuba opened 1 year ago

martinkuba commented 1 year ago

Is your feature request related to a problem? Please describe

This is a feature request to capture console logs and send them to OTLP backends using the OTel Logs API/SDK.

Describe the solution you'd like to see

User should be able to capture console logs and export them to OpenTelemetry backends.

Related to https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1558 and https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1559

davidwindell commented 8 months ago

This would be super useful, especially for capturing errors that occur before a backend application can detect them and forward on to the collector.

el-buku commented 1 month ago

for now the only solution seems to be creating a dedicated app route for collecting frontend console.[] calls, right? 🥹

martinkuba commented 1 month ago

@el-buku If by app route you mean a custom backend endpoint for collecting the logs, you can collect the logs by sending them to a Collector or any OTLP backend that supports OTel logs. This instrumentation unfortunately still does not exist, but you can generate the logs manually using the Logs API and SDK.