Skip to content

chore(pin): enforce the use of the global tracer#12219

Merged
mabdinur merged 16 commits into3.x-stagingfrom
munir/remove-deprecations-from-pin
Feb 5, 2025
Merged

chore(pin): enforce the use of the global tracer#12219
mabdinur merged 16 commits into3.x-stagingfrom
munir/remove-deprecations-from-pin

Conversation

@mabdinur
Copy link
Contributor

@mabdinur mabdinur commented Feb 4, 2025

  • Removes tracer parameter from Pin.override(), Pin.clone() and Pin.__init__(). ddtrace.trace.Pin can only be used with the global tracer. With this change User's can not modify integration to use custom tracers.
  • Introduces Pin._tracer and makes Pin.tracer an immutable property. This prevents users from modifying the tracer used by Pin objects while allowing maintainers to override the Pin._tracer in tests,
  • Updates tests to use Pin._tracer, Pin._override(), and Pin._clone().

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

allow configuring dummy writers for civis

fix broken tests

update tracer

fix stuff

try to fix pytest

address failues
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2025

CODEOWNERS have been resolved as:

releasenotes/notes/remove-deprecations-from-pin-a700ae0cb6d51d03.yaml   @DataDog/apm-python
ddtrace/_trace/pin.py                                                   @DataDog/apm-sdk-api-python
ddtrace/contrib/internal/asgi/middleware.py                             @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/django/patch.py                                @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/mongoengine/trace.py                           @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/pylibmc/client.py                              @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/sqlalchemy/engine.py                           @DataDog/apm-core-python @DataDog/apm-idm-python
ddtrace/contrib/internal/tornado/application.py                         @DataDog/apm-core-python @DataDog/apm-idm-python
tests/appsec/contrib_appsec/django_app/urls.py                          @DataDog/asm-python
tests/appsec/contrib_appsec/fastapi_app/app.py                          @DataDog/asm-python
tests/appsec/contrib_appsec/flask_app/app.py                            @DataDog/asm-python
tests/appsec/contrib_appsec/test_flask.py                               @DataDog/asm-python
tests/appsec/contrib_appsec/utils.py                                    @DataDog/asm-python
tests/appsec/integrations/django_tests/conftest.py                      @DataDog/asm-python
tests/contrib/aiobotocore/utils.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/aiohttp/test_aiohttp_client.py                            @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/aiohttp_jinja2/conftest.py                                @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/aiohttp_jinja2/test_aiohttp_jinja2.py                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/aiomysql/test_aiomysql.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/aiopg/test.py                                             @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/algoliasearch/test.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/anthropic/conftest.py                                     @DataDog/ml-observability
tests/contrib/aredis/test_aredis.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/asyncpg/test_asyncpg.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/avro/test_avro.py                                         @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/boto/test.py                                              @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/botocore/test.py                                          @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/botocore/test_bedrock.py                                  @DataDog/ml-observability
tests/contrib/botocore/test_bedrock_llmobs.py                           @DataDog/ml-observability
tests/contrib/cassandra/test.py                                         @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/celery/base.py                                            @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/celery/test_tagging.py                                    @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/consul/test.py                                            @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/dbapi/test_dbapi.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/dbapi/test_dbapi_appsec.py                                @DataDog/asm-python
tests/contrib/dbapi_async/test_dbapi_async.py                           @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/django/conftest.py                                        @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/django/test_django.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/django/test_django_dbm.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/dogpile_cache/test_tracing.py                             @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/dramatiq/test_integration.py                              @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/elasticsearch/test_elasticsearch.py                       @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/flask/__init__.py                                         @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/flask/test_blueprint.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/flask_autopatch/test_flask_autopatch.py                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/google_generativeai/conftest.py                           @DataDog/ml-observability
tests/contrib/grpc/common.py                                            @DataDog/apm-idm-python @DataDog/asm-python
tests/contrib/grpc/test_grpc.py                                         @DataDog/apm-idm-python @DataDog/asm-python
tests/contrib/grpc_aio/test_grpc_aio.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/httplib/test_httplib.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/httplib/test_httplib_distributed.py                       @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/httpx/test_httpx.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/httpx/test_httpx_pre_0_11.py                              @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/jinja2/test_jinja2.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/kafka/test_kafka.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/kombu/test.py                                             @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/langchain/conftest.py                                     @DataDog/ml-observability
tests/contrib/langgraph/conftest.py                                     @DataDog/ml-observability
tests/contrib/mako/test_mako.py                                         @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/mariadb/test_mariadb.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/molten/test_molten.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/molten/test_molten_di.py                                  @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/mongoengine/test.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/mysql/test_mysql.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/mysqldb/test_mysqldb.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/openai/conftest.py                                        @DataDog/ml-observability
tests/contrib/psycopg/test_psycopg.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/psycopg/test_psycopg_async.py                             @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/psycopg2/test_psycopg.py                                  @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/pylibmc/test.py                                           @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/pymemcache/test_client.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/pymemcache/test_client_defaults.py                        @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/pymemcache/test_client_mixin.py                           @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/pymongo/test.py                                           @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/pymysql/test_pymysql.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/pynamodb/test_pynamodb.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/pyodbc/test_pyodbc.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/redis/test_redis.py                                       @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/redis/test_redis_asyncio.py                               @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/redis/test_redis_cluster.py                               @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/redis/test_redis_cluster_asyncio.py                       @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/rediscluster/test.py                                      @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/rq/test_rq.py                                             @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/shared_tests.py                                           @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/shared_tests_async.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/sqlalchemy/test_patch.py                                  @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/sqlite3/test_sqlite3.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/starlette/test_starlette.py                               @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/subprocess/test_subprocess.py                             @DataDog/asm-python
tests/contrib/urllib3/test_urllib3.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/valkey/test_valkey.py                                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/valkey/test_valkey_asyncio.py                             @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/valkey/test_valkey_cluster.py                             @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/valkey/test_valkey_cluster_asyncio.py                     @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/vertexai/conftest.py                                      @DataDog/ml-observability
tests/contrib/vertica/test_vertica.py                                   @DataDog/apm-core-python @DataDog/apm-idm-python
tests/contrib/yaaredis/test_yaaredis.py                                 @DataDog/apm-core-python @DataDog/apm-idm-python

@mabdinur mabdinur force-pushed the munir/remove-deprecations-from-pin branch from 20d6173 to ddf975c Compare February 4, 2025 18:14
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Feb 4, 2025

Datadog Report

Branch report: munir/remove-deprecations-from-pin
Commit report: 6ab7487
Test service: dd-trace-py

✅ 0 Failed, 130 Passed, 1184 Skipped, 3m 30.08s Total duration (25m 14.77s time saved)

@pr-commenter
Copy link

pr-commenter bot commented Feb 4, 2025

Benchmarks

Benchmark execution time: 2025-02-05 22:05:04

Comparing candidate commit 6ab7487 in PR branch munir/remove-deprecations-from-pin with baseline commit 33ad7b3 in branch 3.x-staging.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 394 metrics, 2 unstable metrics.

@mabdinur mabdinur changed the title chore(pin): prevent overriding the global tracer chore(pin): ensure the global tracer is used in Pin objects Feb 5, 2025
@mabdinur mabdinur changed the title chore(pin): ensure the global tracer is used in Pin objects chore(pin): ensure the global tracer is used in Pin Feb 5, 2025
fix override logic

fix get_from in testpin

fix get_from

attempt to fix pylibmc, tornado, and appsec tests

rn
@mabdinur mabdinur force-pushed the munir/remove-deprecations-from-pin branch from 4bb07e1 to 3d7df40 Compare February 5, 2025 02:39
@mabdinur mabdinur changed the title chore(pin): ensure the global tracer is used in Pin chore(pin): enforce the use of the global tracer Feb 5, 2025
@mabdinur mabdinur marked this pull request as ready for review February 5, 2025 14:04
@mabdinur mabdinur requested review from a team as code owners February 5, 2025 14:04
@mabdinur mabdinur requested review from emmettbutler, quinna-h and rachelyangdog and removed request for a team February 5, 2025 14:04
@mabdinur mabdinur force-pushed the munir/remove-deprecations-from-pin branch from 689abc6 to 0040d26 Compare February 5, 2025 14:10
@mabdinur mabdinur requested review from a team as code owners February 5, 2025 14:10
@mabdinur mabdinur requested review from a team as code owners February 5, 2025 15:34
@mabdinur mabdinur force-pushed the munir/remove-deprecations-from-pin branch from a4a4aae to bc1e8a2 Compare February 5, 2025 15:46
Copy link
Collaborator

@erikayasuda erikayasuda left a comment

Choose a reason for hiding this comment

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

I think something weird happened with the branches. Just leaving one question here for now while that gets resolved 😅

Copy link
Collaborator

@erikayasuda erikayasuda left a comment

Choose a reason for hiding this comment

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

Just one nit question, LGTM otherwise. Thanks!

mabdinur and others added 3 commits February 5, 2025 11:06
Co-authored-by: erikayasuda <153395705+erikayasuda@users.noreply.github.com>
@mabdinur mabdinur enabled auto-merge (squash) February 5, 2025 17:48
@mabdinur mabdinur merged commit 25e7e2e into 3.x-staging Feb 5, 2025
623 of 625 checks passed
@mabdinur mabdinur deleted the munir/remove-deprecations-from-pin branch February 5, 2025 22:15
ZStriker19 pushed a commit that referenced this pull request Feb 6, 2025
- Removes `tracer` parameter from `Pin.override()`, `Pin.clone()` and
`Pin.__init__()`. `ddtrace.trace.Pin` can only be used with the global
tracer. With this change User's can not modify integration to use custom
tracers.
- Introduces `Pin._tracer` and makes `Pin.tracer` an immutable property.
This prevents users from modifying the tracer used by Pin objects while
allowing maintainers to override the Pin._tracer in tests,
- Updates tests to use `Pin._tracer`, `Pin._override()`, and
`Pin._clone()`.

- [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

- [x] 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: erikayasuda <153395705+erikayasuda@users.noreply.github.com>
gnufede pushed a commit that referenced this pull request Feb 19, 2025
- Removes `tracer` parameter from `Pin.override()`, `Pin.clone()` and
`Pin.__init__()`. `ddtrace.trace.Pin` can only be used with the global
tracer. With this change User's can not modify integration to use custom
tracers.
- Introduces `Pin._tracer` and makes `Pin.tracer` an immutable property.
This prevents users from modifying the tracer used by Pin objects while
allowing maintainers to override the Pin._tracer in tests,
- Updates tests to use `Pin._tracer`, `Pin._override()`, and
`Pin._clone()`.

## Checklist
- [x] 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](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
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](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

---------

Co-authored-by: erikayasuda <153395705+erikayasuda@users.noreply.github.com>
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.

6 participants