Skip to content

Add observability docs #1515

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion docs/developer/community/faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ If you need to connect Saleor with other tools, consider writing a plugin or cre

You can check GraphQL responses in the browser dev console, on the network tab.

Saleor also supports the OpenTracing protocol allowing full in-depth analysis of all GraphQL queries. You can read more about it here: [Monitoring](setup/monitoring-jaeger.mdx).
Saleor also supports the OpenTelemetry protocol allowing full in-depth analysis of all GraphQL queries. You can read more about it here: [Telemetry in Saleor](setup/telemetry.mdx).

## Why have images not been published after deploying Saleor to AWS?

Expand Down
32 changes: 0 additions & 32 deletions docs/setup/monitoring-jaeger.mdx

This file was deleted.

107 changes: 107 additions & 0 deletions docs/setup/telemetry.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: Telemetry in Saleor
description: Learn how Saleor uses OpenTelemetry for observability and monitoring
---

# Telemetry in Saleor

## Introduction

Saleor uses OpenTelemetry standard to give you visibility into what's happening in Saleor Core, and between Core and apps. You can export this data into your preferred observability tool, and create traces, metrics, and monitors to suit your needs.
In this guide, you'll find information on how telemetry is implemented, how to configure it, and how you can start using it in your environment.

## What is OpenTelemetry?

[OpenTelemetry](https://opentelemetry.io/) is an open-source observability framework that provides tools, APIs, and SDKs to help instrument, generate, collect, and export telemetry data (metrics, logs, and traces) for analysis. OpenTelemetry is a Cloud Native Computing Foundation (CNCF) project designed to make observability a built-in feature of cloud-native applications.

## Telemetry in Saleor architecture

Saleor's telemetry system is primarily located in the `saleor.core.telemetry` package and consists of the following key components:

### Tracing

Tracing is provided through the `Tracer` class which is a wrapper around OpenTelemetry's tracing capabilities. It allows you to:

- Create spans to measure operation execution time
- Add attributes and events to spans
- Establish parent-child relationships between spans
- Link spans across asynchronous operations

Saleor implements two distinct scopes for traces:
- **CORE**: For internal system operations and core functionality
- **SERVICE**: For business logic and service-level operations

What is being traced at the **SERVICE** level:

- **HTTP requests** including their duration, full URL, request method, client's IP address, and length of response. This includes requests to Saleor's GraphQL API and requests to external services (Saleor Apps, custom apps) via sync webhooks.
- **GraphQL queries** including their duration, query string, and execution errors.

### Metrics

Metrics are handled through the `Meter` class, which is a wrapper around OpenTelemetry's metrics capabilities. It supports:

- Counters
- Histograms
- Up/Down Counters

Like traces, metrics are also separated into CORE and SERVICE scopes.

## Setting up your own observability

If you're running your own Saleor instance, you can set up telemetry collection and viewing using standard OpenTelemetry tooling. Below is an example of a observability setup where Saleor is configured to send telemetry data to an [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/), which then exports the data to a [Jaeger](https://www.jaegertracing.io/) instance for visualization.

### 1. Configure an OpenTelemetry Collector

Set up an OpenTelemetry Collector to receive, process, and export telemetry data. Below is an example configuration file for the OpenTelemetry Collector:

```yaml
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318

processors:
batch:

exporters:
jaeger:
endpoint: jaeger:4317 # example Jaeger endpoint
tls:
insecure: true # enable TLS in production

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [jaeger]
```

Note: Only traces are exported in this example as Jaeger doesn't support metrics. You can add additional exporters for metrics if needed.

Refer to the [OpenTelemetry Collector configuration](https://opentelemetry.io/docs/collector/configuration/) for more details.

### 2. Set Up Environment Variables

Configure the environment variables for your Saleor instance to connect to your telemetry system:

```bash
# OpenTelemetry configuration
export OTEL_SERVICE_NAME=saleor
export OTEL_TRACES_EXPORTER=otlp
export OTEL_METRICS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4317
```

Alternatively, you can pass above configuration as command-line arguments for the `opentelemetry-instrument` command. Refer to [OpenTelemetry Agent configuration](https://opentelemetry.io/docs/zero-code/python/configuration/) for more details.

### 3. Run Saleor with OpenTelemetry Instrumentation

Use the OpenTelemetry instrumentation command to automatically instrument your application:

```bash
opentelemetry-instrument uvicorn saleor.asgi:application
```
2 changes: 1 addition & 1 deletion sidebars/self-hosting.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const selfHosting = [
"setup/deploy-linux",

title("Monitoring"),
"setup/monitoring-jaeger",
"setup/telemetry",
"setup/monitoring-sentry",

title("Storing Files"),
Expand Down