MyObservability

🟦 Manual Instrumentation - Logs

In OpenTelemetry, every piece of data that is neither a part of a distributed trace nor a metric is considered a log. For example, events are just specialized log entries.

OpenTelemetry use existing logging functionality from programming languages or existing logging libraries to integrate into unlike API & SDK implemented for tracing & metrics.

🟩 OpenTelemetry Solution for Logging

Emited logs, traces and metrics in a way that is compliant with OpenTelemetry data models, send the data through OpenTelemetry Collector, where it can be enriched and processed in a uniform manner.

🟥 File or Stdout Logs

logs are written to files or to standard output, requires ability to read file logs, tail them, work correctly when log rotation is used. common formats that parsers need to support are: CSV, Common Log Format, Labeled Tab-separated Values (LTSV), Key/Value Pair format, JSON, etc. To support this approach OpenTelemetry recommends to collect logs using OpenTelemetry Collector

Alternatively, if the Collector does not have the necessary file reading and parsing capabilities, another log collection agent, such as FluentBit can collect the logs, then send the logs to OpenTelemetry Collector.

🟥 Direct to Collector

The second approach is to modify the application so that the logs are output via a network protocol, e.g. via OTLP

To facilitate both approaches described above OpenTelemetry provides a API and SDK, which can be used together with existing logging libraries to automatically inject the trace context in the emitted logs, and provide an easy way to send the logs via OTLP.

🟩 Logs API

Logging Manually

Step 1: Import required libraries



✅ Next Chapter: Sampling

✅ Main Page: Click Here