Skip to content

Conversation

@marcm-ml
Copy link
Contributor

@marcm-ml marcm-ml commented May 8, 2025

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #3454

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Run this file via uv with my changes, i.e. uv sync && uv run reproduce.py

# /// script
# requires-python = ">=3.12"
# dependencies = [
#     "opentelemetry-api",
#     "opentelemetry-sdk",
#     "sqlalchemy",
# ]
# ///

from sqlalchemy import create_engine

from opentelemetry import trace
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
from opentelemetry.instrumentation.utils import suppress_instrumentation
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
    ConsoleSpanExporter,
    SimpleSpanProcessor,
)

tracer_provider = TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))
trace.set_tracer_provider(tracer_provider)

tracer = trace.get_tracer(__name__)

engine = create_engine("sqlite:///:memory:")
SQLAlchemyInstrumentor().instrument(engine=engine)

# creates span
with engine.connect():
    pass

# no span
with suppress_instrumentation(), engine.connect():
    pass

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated (no need)

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 8, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@github-actions github-actions bot requested a review from shalevr May 8, 2025 09:44
@marcm-ml marcm-ml requested a review from a team as a code owner May 8, 2025 09:44
@tammy-baylis-swi tammy-baylis-swi moved this to Easy to review / merge / close in @xrmx's Python PR digest May 8, 2025
@marcm-ml
Copy link
Contributor Author

I have updated the changelog after release. Can you re-review?

Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

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

Thanks again!

@marcm-ml
Copy link
Contributor Author

marcm-ml commented May 29, 2025

@shalevr give me a ping here if we are able to merge this, then I (or you) will update the changelog conflicts.

@xrmx xrmx enabled auto-merge (squash) May 30, 2025 15:50
@xrmx xrmx merged commit 77325aa into open-telemetry:main May 30, 2025
624 of 625 checks passed
@github-project-automation github-project-automation bot moved this from Easy to review / merge / close to Done in @xrmx's Python PR digest May 30, 2025
devmonkey22 pushed a commit to devmonkey22/opentelemetry-python-contrib that referenced this pull request Aug 5, 2025
…rumentation (open-telemetry#3477)

* respect supress_instrumentation

* update changelog

* Update CHANGELOG.md

Fix changelog after release

---------

Co-authored-by: Emídio Neto <[email protected]>
Co-authored-by: Riccardo Magliocchetti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

SQLAlchemy instrumentation does not respect suppress_instrumentation functionality

5 participants