-
Notifications
You must be signed in to change notification settings - Fork 170
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
Merged
Add observability docs #1515
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7fba143
Add observability docs
maarcingebala a4f9764
Drop Jaeger page and mentions of OpenTracing
maarcingebala 1b5d280
Review fixes
maarcingebala 9ca3b65
Improve description of service spans scope
maarcingebala 695eb60
Drop context propagation part for now
maarcingebala f516e69
Merge branch 'main' into otel-docs
aniav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.