Skip to content

feat: add GalileoSpanProcessor and GalileoOTLPExporter#392

Merged
Focadecombate merged 3 commits intomainfrom
feature/sc-43420/simplify-otel-processor-setup-by
Nov 12, 2025
Merged

feat: add GalileoSpanProcessor and GalileoOTLPExporter#392
Focadecombate merged 3 commits intomainfrom
feature/sc-43420/simplify-otel-processor-setup-by

Conversation

@Focadecombate
Copy link
Contributor

@Focadecombate Focadecombate commented Oct 30, 2025

User description

Shortcut: SC-43420

Description:

This PR adds OpenTelemetry (OTEL) integration to the Galileo Python SDK, enabling users to export trace data to Galileo using standard OTEL protocols.

Key Components:

  • GalileoOTLPExporter - Preconfigured OTLP exporter for Galileo platform
  • GalileoSpanProcessor - Complete span processor with integrated Galileo export functionality
  • New optional dependencies: opentelemetry-sdk, opentelemetry-api, opentelemetry-exporter-otlp
  • Install with: pip install galileo[otel]

Features:

  • Easy one-line setup: GalileoSpanProcessor(project="my-project")
  • Environment variable support (GALILEO_API_KEY, GALILEO_PROJECT, etc.)
  • Graceful degradation when OTEL dependencies not installed
  • Python 3.9+ compatible with proper type annotations
  • No breaking changes - entirely additive feature

Usage:

from opentelemetry.sdk.trace import TracerProvider
from galileo.otel import GalileoSpanProcessor

tracer_provider = TracerProvider()
processor = GalileoSpanProcessor(project="my-app", api_key="your-key")
tracer_provider.add_span_processor(processor)

Tests:

  • Unit Tests Added
  • E2E Test Added (if it's a user-facing feature, or fixing a bug)

Generated description

Below is a concise technical summary of the changes proposed in this PR:

graph LR
GalileoSpanProcessor_init_("GalileoSpanProcessor.__init__"):::added
GalileoOTLPExporter_init_("GalileoOTLPExporter.__init__"):::added
BatchSpanProcessor_("BatchSpanProcessor"):::added
SpanProcessor_("SpanProcessor"):::added
GalileoSpanProcessor_on_start_("GalileoSpanProcessor.on_start"):::added
GalileoSpanProcessor_processor_("GalileoSpanProcessor.processor"):::added
GalileoSpanProcessor_on_end_("GalileoSpanProcessor.on_end"):::added
GalileoSpanProcessor_shutdown_("GalileoSpanProcessor.shutdown"):::added
GalileoSpanProcessor_force_flush_("GalileoSpanProcessor.force_flush"):::added
GalileoSpanProcessor_exporter_("GalileoSpanProcessor.exporter"):::added
GalileoOTLPExporter_("GalileoOTLPExporter"):::added
GalileoSpanProcessor_init_ -- "Initializes exporter with project and logstream configuration." --> GalileoOTLPExporter_init_
GalileoSpanProcessor_init_ -- "Uses BatchSpanProcessor for efficient batch span processing." --> BatchSpanProcessor_
GalileoSpanProcessor_init_ -- "Uses SpanProcessor as base for underlying processor." --> SpanProcessor_
GalileoSpanProcessor_on_start_ -- "Delegates span start handling to underlying processor." --> GalileoSpanProcessor_processor_
GalileoSpanProcessor_on_end_ -- "Delegates span end handling to underlying processor." --> GalileoSpanProcessor_processor_
GalileoSpanProcessor_shutdown_ -- "Gracefully shuts down and flushes remaining spans." --> GalileoSpanProcessor_processor_
GalileoSpanProcessor_force_flush_ -- "Immediately exports all pending spans." --> GalileoSpanProcessor_processor_
GalileoSpanProcessor_exporter_ -- "Provides access to underlying Galileo OTLP exporter." --> GalileoOTLPExporter_
classDef added stroke:#15AA7A
classDef removed stroke:#CD5270
classDef modified stroke:#EDAC4C
linkStyle default stroke:#CBD5E1,font-size:13px
Loading

Integrates OpenTelemetry (OTel) tracing into the galileo-python SDK, enabling users to export trace data to the Galileo platform using standard OTel protocols. Provides GalileoOTLPExporter to configure OTLP export and GalileoSpanProcessor to manage the lifecycle of spans.

TopicDetails
Dependency Management Updates project dependencies by adding optional OpenTelemetry packages and introducing an otel extra for simplified installation, ensuring compatibility and modularity.
Modified files (2)
  • pyproject.toml
  • poetry.lock
Latest Contributors(2)
UserCommitDate
ci@rungalileo.iochore-release-v1.30.0November 07, 2025
jweiler@galileo.aichore-Bump-galileo-cor...November 07, 2025
OTel Integration Adds GalileoOTLPExporter to configure OpenTelemetry Protocol (OTLP) export to the Galileo platform and GalileoSpanProcessor to manage the lifecycle of spans, including graceful degradation if OTel dependencies are not installed.
Modified files (2)
  • tests/test_otel.py
  • src/galileo/otel.py
Latest Contributors(0)
UserCommitDate
This pull request is reviewed by Baz. Review like a pro on (Baz).

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 78.57143% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.14%. Comparing base (f465442) to head (3306d5a).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/galileo/otel.py 78.57% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #392      +/-   ##
==========================================
- Coverage   86.23%   86.14%   -0.09%     
==========================================
  Files          75       76       +1     
  Lines        5942     6012      +70     
==========================================
+ Hits         5124     5179      +55     
- Misses        818      833      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

self,
project: Optional[str] = None,
logstream: Optional[str] = None,
api_key: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

The api_key and base_url values are provided thru the GalileoPythonConfig objects. This would be the first method to accept this value as a parameter creating an special case in the SDK. I don't think this is the path we want to follow.

Copy link
Contributor

Choose a reason for hiding this comment

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

Commit 57038f9 addressed this comment by completely removing the api_key and base_url parameters from the method signatures and replacing them with values obtained from GalileoPythonConfig.get(). This eliminates the special case concern and follows the desired pattern of using GalileoPythonConfig objects for configuration values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented it!

logstream: Optional[str] = None,
api_key: Optional[str] = None,
base_url: Optional[str] = None,
headers: Optional[dict[str, str]] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

What’s the use case for allowing the header to be passed as a parameter? Why would we want to let the user add additional header values?

Copy link
Contributor

Choose a reason for hiding this comment

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

Commit 57038f9 addressed this comment by removing the ability for users to pass custom headers as a parameter. The headers are now constructed internally using configuration values (API key, project, logstream) from GalileoPythonConfig, eliminating the potential for users to add arbitrary header values that the commenter was questioning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove it. If we need it, we can use the following OTEL env var OTEL_EXPORTER_OTLP_HEADERS.

@Focadecombate Focadecombate force-pushed the feature/sc-43420/simplify-otel-processor-setup-by branch from ed7d776 to 57038f9 Compare November 12, 2025 14:45
@Focadecombate Focadecombate force-pushed the feature/sc-43420/simplify-otel-processor-setup-by branch from 57038f9 to 89fa1bb Compare November 12, 2025 14:49
@Focadecombate Focadecombate requested a review from vamaq November 12, 2025 14:49
@Focadecombate Focadecombate force-pushed the feature/sc-43420/simplify-otel-processor-setup-by branch from 89fa1bb to d087367 Compare November 12, 2025 15:28
@Focadecombate Focadecombate force-pushed the feature/sc-43420/simplify-otel-processor-setup-by branch from d087367 to 04d72cc Compare November 12, 2025 15:44
@Focadecombate Focadecombate force-pushed the feature/sc-43420/simplify-otel-processor-setup-by branch from 04d72cc to 3306d5a Compare November 12, 2025 15:50
endpoint: str = urljoin(base_url, "otel/traces")

if not config.api_key:
raise ValueError("API key is required.")
Copy link
Contributor

Choose a reason for hiding this comment

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

overall looks good. just a nit. You may want to make Error actionable by pointing to docs or in fact directly to cluster api keys (e.g., https://app.galileo.ai/default/settings/api-keys).

Copy link
Contributor

@savula15 savula15 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@vamaq vamaq left a comment

Choose a reason for hiding this comment

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

LGTM!

@Focadecombate Focadecombate merged commit e4dd773 into main Nov 12, 2025
21 checks passed
@Focadecombate Focadecombate deleted the feature/sc-43420/simplify-otel-processor-setup-by branch November 12, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants