Skip to main content
This guide explains how to set up and use OpenTelemetry (OTel) tracing to monitor your FalkorDB Python applications.

Overview

OpenTelemetry is an observability framework that allows you to collect, process, and export telemetry data from your applications. When integrated with FalkorDB-py, it provides valuable insights into database operations and query performance through distributed tracing. Note: This guide focuses on tracing capabilities. OpenTelemetry supports additional observability features like metrics and logs that can be configured separately.

Prerequisites

  • Python 3.9+
  • FalkorDB server running (locally or remotely)
  • Basic understanding of Python and FalkorDB

Installation

Install the required packages using pip or poetry:

Using pip

Using poetry

Basic Setup

1. Import Required Modules

2. Configure OpenTelemetry SDK

3. Connect to FalkorDB

Tracing FalkorDB Operations

Manual Span Creation

You can manually create spans around FalkorDB operations to track their performance and behavior:

Advanced Span Attributes

You can add more detailed attributes to your spans for better observability:

Exporter Configuration

Console Exporter (Development)

The console exporter is useful for development and debugging:

OTLP Exporter (Production)

For production environments, you can export to observability platforms:

Jaeger Exporter

To export traces to Jaeger:

Complete Example

Here’s a complete working example:

Best Practices

1. Service Naming

Use descriptive service names that identify your application:

2. Meaningful Span Names

Use descriptive span names that indicate the operation:

3. Error Handling

Always handle errors properly in your spans:

4. Sensitive Data

Avoid logging sensitive information in span attributes:

Troubleshooting

Common Issues

  1. No traces appearing: Ensure the tracer provider is set before creating spans
  2. Connection errors: Verify FalkorDB server is running and accessible
  3. Missing dependencies: Install all required OpenTelemetry packages

Debug Mode

Enable debug logging to troubleshoot issues:

Additional Resources

Conclusion

By integrating OpenTelemetry with FalkorDB-py, you gain powerful observability capabilities that help you monitor, debug, and optimize your graph database applications. Start with the basic setup and gradually add more sophisticated tracing as your application grows in complexity.

Frequently Asked Questions

Install opentelemetry-distro, opentelemetry-instrumentation-redis, opentelemetry-exporter-otlp, and opentelemetry-sdk alongside the falkordb package.
Yes. Use the OTLP exporter (OTLPSpanExporter) to send traces to observability platforms like Jaeger, Grafana Tempo, or Datadog. Avoid the ConsoleSpanExporter in production as it is for development only.
The overhead is minimal when using BatchSpanProcessor with async exporters. The everysec batch approach ensures traces are exported in the background without blocking query execution.
Log query structure with placeholders instead of actual values. For example, use MATCH (u:User {email: ?}) RETURN u as the db.statement attribute instead of including real email addresses.
Yes. OpenTelemetry supports distributed tracing. When you propagate trace context between services, FalkorDB query spans will appear as children of the calling service spans in your trace viewer.