Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions constants/docsSideNav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1138,13 +1138,8 @@ const docsSideNav = [
},
{
type: 'doc',
route: '/docs/userguide/python-logs-auto-instrumentation',
label: 'Python Logs Auto-Instrumentation',
},
{
type: 'doc',
route: '/docs/userguide/collecting_application_logs_otel_sdk_python',
label: 'Using OTel Python SDK',
route: '/docs/logs-management/send-logs/python-logs',
label: 'Python Logs',
},
{
type: 'doc',
Expand Down Expand Up @@ -3166,4 +3161,4 @@ const docsSideNav = [
},
]

export default docsSideNav
export default docsSideNav
65 changes: 2 additions & 63 deletions data/docs/instrumentation/opentelemetry-python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,9 @@ title: Python OpenTelemetry Instrumentation
description: Send events from your Python application to SigNoz
hide_table_of_contents: true
---
{/*
import InstrumentationFAQ from '@/components/shared/instrumentation-faq.md' */}

This document contains instructions on how to set up OpenTelemetry instrumentation in your Python applications and view your application traces in SigNoz.

{/* This document contains instructions on how to set up OpenTelemetry instrumentation in your Python applications. */}
{/* OpenTelemetry, also known as OTel for short, is an open source observability framework that can help you generate and collect telemetry data - traces, metrics, and logs from your Python application. */}
{/*
Once the telemetry data is collected, you can configure an exporter to send the data to SigNoz.

There are three major steps to using OpenTelemetry:

- Instrumenting your Python application with OpenTelemetry
- Configuring exporter to send data to SigNoz
- Validating that configuration to ensure that data is being sent as expected. */}

{/* <figure data-zoomable align='center'>
<img src="/img/docs/otel_python_instrumentation.webp" alt="OpenTelemetry helps to generate and collect telemetry data from your application which is then sent to an observability backend like SigNoz"/>
<figcaption><i>OpenTelemetry helps generate and collect telemetry data from Python applications which can then be sent to SigNoz for storage, visualization, and analysis.</i></figcaption>
</figure> */}


{/* Let’s understand how to download, install, and run OpenTelemetry in Python. */}

## Requirements

- Python 3.8 or newer
Expand Down Expand Up @@ -790,50 +769,10 @@ Validate your traces in SigNoz:
2. In SigNoz, open the `Services` tab. Hit the `Refresh` button on the top right corner, and your application should appear in the list of `Applications`.
3. Go to the `Traces` tab, and apply relevant filters to see your application’s traces.

{/* You might see other dummy applications if you’re using SigNoz for the first time. You can remove it by following the docs [here](https://signoz.io/docs/operate/docker-standalone/#remove-the-sample-application). */}

{/* <figure data-zoomable align='center'>
<img src="/img/docs/opentelemetry_python_app_instrumented.webp" alt="Python Application in the list of services being monitored in SigNoz"/>
<figcaption><i>Python Application in the list of services being monitored in SigNoz</i></figcaption>
</figure>
*/}

{/* ## Database Instrumentation

Make sure that the DB client library you are using has the corresponding instrumentation library, and the version of the DB client library is supported by OpenTelemetry.

### MongoDB

You can use `opentelemetry-distro` to initialize instrumentation for your MongoDB database calls. You need to ensure that the version of your DB client library is supported by OpenTelemetry. For MongoDB, the instrumentation library is `opentelemetry-instrumentation-pymongo`.

You can check the supported versions [here](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation).

### Redis

You can use `opentelemetry-distro` to initialize instrumentation for your Redis database calls. You need to ensure that the version of your DB client library is supported by OpenTelemetry. For Redis, the instrumentation library is `opentelemetry-instrumentation-redis`.

You can check the supported versions [here](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation).

### MySQL

You can use `opentelemetry-distro` to initialize instrumentation for your MySQL database calls. You need to ensure that the version of your DB client library is supported by OpenTelemetry. For MySQL, we have two instrumentation libraries:

- opentelemetry-instrumentation-mysql
- opentelemetry-instrumentation-pymysql

You can check the supported versions [here](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation).

### Postgres

You can use `opentelemetry-distro` to initialize instrumentation for your PostgreSQL database calls. You need to ensure that the version of your DB client library is supported by OpenTelemetry. For Postgres, the instrumentation library is `opentelemetry-instrumentation-psycopg2`.

You can check the supported versions [here](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/instrumentation).

<Admonition>

`psycopg2-binary` is not supported by opentelemetry auto instrumentation libraries as it is not recommended for production use. Please use `psycopg2` to see DB calls also in your trace data in SigNoz
## Send Python application logs and correlate with traces

</Admonition> */}
To send logs from your Python application and correlate them with traces, please follow the instructions mentioned in this [documentation](https://signoz.io/docs/logs-management/send-logs/python-logs).

## Running applications with Gunicorn, uWSGI

Expand Down
67 changes: 67 additions & 0 deletions data/docs/logs-management/send-logs/python-logs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
date: 2025-09-01
title: Sending Python Logs
id: python-logs
hide_table_of_contents: true
---

You can send Python logs to SigNoz using Auto instrumentation which is the fast, no code change way to send logs to SigNoz.

## Prerequisites

- A [auto-instrumented](https://signoz.io/docs/instrumentation/opentelemetry-python/#send-traces-directly-to-signoz-cloud) python application with logging implemented
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prerequisite is not valid when user is on k8s and don't want to instrument app


## Setup

### Step 1: Instrument your application

Follow the steps in our [Python instrumentation document](https://signoz.io/docs/instrumentation/opentelemetry-python/#send-traces-directly-to-signoz-cloud) to auto-instrument your application.


### Step 2: Run your application

Now, run your application with the following environment variables set:

```bash
OTEL_SERVICE_NAME=<service_name> \
OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443" \
OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>" \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
OTEL_TRACES_EXPORTER=otlp \
OTEL_LOGS_EXPORTER=otlp \
OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true \
opentelemetry-instrument <your_run_command>
```

This attaches an OTLP log handler, injects trace context into each log record. This will allow you to correlate logs with traces.

- `OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED` when set to `true` will [attach the OTLP log handler](https://opentelemetry.io/docs/zero-code/python/configuration/#logging) to the root logger. That is what sends the logs out.


<figure data-zoomable align='center'>
<img src="/img/docs/traces-management/correlate-traces-with-logs.gif" alt="Correlated Logs and Traces"/>
<figcaption><i>Correlated Logs and Traces</i></figcaption>
</figure>


## Python application on Kubernetes

If your application is running on Kubernetes, you can use the [k8s-infra-chart](https://signoz.io/docs/collection-agents/k8s/k8s-infra/install-k8s-infra/) to get your logs directly to SigNoz.

The chart has [presets.logsCollection.enabled](https://signoz.io/docs/collection-agents/k8s/k8s-infra/configure-k8s-infra/#3-container-log-collection) property to **true** which adds a `filelogreceiver`. This receiver is configured to read the files where Kubernetes
container runtime writes all containers console output **(/var/log/pods/*/*/*.log)**.

### Parse attributes

Once you have the logs in SigNoz, you can parse different attributes from the log body using [Logs Pipelines](https://signoz.io/docs/logs-pipelines/introduction/).
Logs pipelines give you the ability to pre-process logs by providing you with a number of [log processors](https://signoz.io/docs/logs-pipelines/processors/).
Checkout [these guides](https://signoz.io/docs/category/guides/) to learn how you can use logs pipelines for different use-cases.

## Fine Grained Control

If you need more control over your logging, you can use the OpenTelemetry Python SDK to manually instrument your application. It provides a handler that can be used to transport logs to any OTLP-compatible backend.

Here are some references to get you started with manual instrumentation:
- [Configure OTel logs SDK in Python](https://signoz.io/opentelemetry/logging-in-python/) part of implementing OTel in Python applications [series](https://signoz.io/opentelemetry/python-overview/)
- Official OpenTelemetry [SDK example for python](https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples/logs) logs
- OpenTelemetry [docs for python instrumentation](https://opentelemetry.io/docs/languages/python/instrumentation/#logs) logs section

This file was deleted.

100 changes: 0 additions & 100 deletions data/docs/userguide/python-logs-auto-instrumentation.mdx

This file was deleted.

10 changes: 10 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,16 @@ module.exports = () => {
source: "/docs/llm/llamaindex-monitoring/",
destination: "/docs/llamaindex-monitoring/",
permanent: true
},
{
source: "/docs/userguide/python-logs-auto-instrumentation/",
destination: "/docs/send-logs/python-logs/",
permanent: true
},
{
source: "/docs/userguide/collecting_application_logs_otel_sdk_python/",
destination: "/docs/send-logs/python-logs/",
permanent: true
}
]
},
Expand Down