Skip to content

feat(duckdb): adding duckdb integration #14232

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 11 commits into
base: main
Choose a base branch
from

Conversation

cweichen-dd
Copy link

@cweichen-dd cweichen-dd commented Aug 5, 2025

Title: Add Integration for DuckDB

Overview

This PR adds a new integration for DuckDB, providing tracing for database operations including queries, table operations, and bulk inserts.

Motivation

This was mostly an onboarding exercise for @cweichen-dd to get familiarity with the tracing codebase. DuckDB was chosen in conversation with @tabgok, as DuckDB is gaining adoption in data analytics and ML workloads.

Files Changed

  • Core Integration: ddtrace/contrib/internal/duckdb/ (new module)
  • Configuration: Registry, settings, and riot test setup
  • Documentation: Updated integrations.rst
  • Tests: Comprehensive test suite with snapshot validation

Risks

  • No major risks as it follows the template for other DB integrations.
  • Testing uses temporary paths, as DuckDB supports file-based databases.
  • Tests written (and tested) with AI assistance (Cursor)

Checklist

  • ✅ PR author has checked that all the criteria below are met
  • ✅ The PR description includes an overview of the change
  • ✅ The PR description articulates the motivation for the change
  • ✅ The change includes tests OR the PR description describes a testing strategy
  • ✅ The PR description notes risks associated with the change, if any
  • ✅ Newly-added code is easy to change
  • ✅ The change follows the library release note guidelines
  • ✅ The change includes or references documentation updates if necessary
  • ✅ Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

riotfile.py Outdated
command="pytest {cmdargs} tests/contrib/duckdb",
venvs=[
Venv(
pys=select_pys(min_version="3.9", max_version="3.11"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason not to test against 3.12 and 3.13?

Comment on lines 71 to 72
else:
tags[db.NAME] = database_path
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is redundant with line 65


span = spans[0]
assert_is_measured(span)
assert span.service == "duckdb"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Multiple assertions on span attributes make this a good candidate to be converted to a snapshot test

pin._clone(tracer=self.tracer).onto(conn)
return conn, self.tracer

def test_large_table_creation_performance(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

These tests would be a good fit for the benchmarking platform, which provides stronger guarantees on resource usage. This directory contains examples of how to set up performance benchmarks that run in CI.

@cweichen-dd cweichen-dd changed the title Adding DuckDB integration feat(duckdb): Adding DuckDB integration Aug 6, 2025
@cweichen-dd cweichen-dd changed the title feat(duckdb): Adding DuckDB integration feat(duckdb): adding duckdb integration Aug 6, 2025
@cweichen-dd cweichen-dd force-pushed the feature/duckdb-integration branch from 3717269 to 9dad1f0 Compare August 6, 2025 20:16
@cweichen-dd cweichen-dd force-pushed the feature/duckdb-integration branch from 9dad1f0 to 6f2cf9e Compare August 6, 2025 20:18
@cweichen-dd cweichen-dd force-pushed the feature/duckdb-integration branch from bb8c5dd to ecb7e8b Compare August 7, 2025 17:16
- Remove duplicate imports in patch.py (config, schematize_service_name)
- Fix redundant database_path assignment
- Clean up import structure following project standards

Test Architecture Enhancements:
- Convert comprehensive tests with multiple span assertions to snapshot tests
- Add new snapshot tests: parameterized_queries, fetch_methods, service_name_override
- Simplify comprehensive tests to focus on functional validation
- Fix XFAIL issue by correcting snapshot test trace count expectations
- Remove performance tests from regular test suite

Benchmark Platform Integration:
- Create complete benchmark scenario in benchmarks/duckdb/
---
features:
- |
Add DuckDB integration support with comprehensive tracing capabilities including query execution monitoring, performance metrics, and error handling for DuckDB ≥ 0.8.0.
Copy link
Contributor

Choose a reason for hiding this comment

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

0.8.0 doesn't match with the supported versions in patch.py

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