brettlangdon: Failing tests are segfaults with sqlalchemy, not related to any changes in this PR
diff --git a/ddtrace/internal/logger.py b/ddtrace/internal/logger.py
index f14037cc9..6b9930531 100644
--- a/ddtrace/internal/logger.py
+++ b/ddtrace/internal/logger.py
@@ -110,7 +110,8 @@ class DDLogger(logging.Logger):
         if logging_bucket.bucket != current_bucket:
             # Append count of skipped messages if we have skipped some since our last logging
             if logging_bucket.skipped:
-                record.msg = '{}, {} additional messages skipped'.format(record.msg, logging_bucket.skipped)
+                record.msg = '{}, %s additional messages skipped'.format(record.msg)
+                record.args = record.args + (logging_bucket.skipped, )
 
             # Reset our bucket
             self.buckets[key] = DDLogger.LoggingBucket(current_bucket, 0)

DDLogger rewrites LogRecord.msg, which causes Sentry events duplication
Sentry uses `LogRecord.msg` to identify log events. LogRecord.msg is the log message template, to be formatted on demand.

When rewriting `msg`, one should not enrich it with arbitrary values, like `logging_bucket.skipped`.

The line
```
                record.msg = '{}, {} additional messages skipped'.format(record.msg, logging_bucket.skipped)
```

should be something like:

```
                record.msg = '{}, %s additional messages skipped'.format(record.msg)
                record.args = record.args + (logging_bucket.skipped,)
```

Culprit:
https://github.com/DataDog/dd-trace-py/blob/914cbca4ba5ec53ff17cb67164cb51b7bcd91ac2/ddtrace/internal/logger.py#L113

Example of message duplication:
![image](https://user-images.githubusercontent.com/43616133/67687095-ae372580-f98f-11e9-9b81-2a0ee61f175c.png)

diff --git a/tests/internal/test_logger.py b/tests/internal/test_logger.py
index 2148da32d..206b7bb76 100644
--- a/tests/internal/test_logger.py
+++ b/tests/internal/test_logger.py
@@ -263,7 +263,9 @@ class DDLoggerTestCase(BaseTestCase):
         log = get_logger('test.logger')
 
         # Create log record to handle
-        record = self._make_record(log)
+        original_msg = 'hello %s'
+        original_args = (1, )
+        record = self._make_record(log, msg=original_msg, args=(1, ))
 
         # Create a bucket entry for this record
         key = (record.name, record.levelno, record.pathname, record.lineno)
@@ -277,7 +279,9 @@ class DDLoggerTestCase(BaseTestCase):
         # We passed to base Logger.handle
         base_handle.assert_called_once_with(record)
 
-        self.assertEqual(record.msg, 'test, 20 additional messages skipped')
+        self.assertEqual(record.msg, original_msg + ', %s additional messages skipped')
+        self.assertEqual(record.args, original_args + (20, ))
+        self.assertEqual(record.getMessage(), 'hello 1, 20 additional messages skipped')
 
     def test_logger_handle_bucket_key(self):
         """

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-mock opentracing mock
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
coverage==7.8.0
-e git+https://github.com/DataDog/dd-trace-py.git@63b0463482dfad78f7801ef784d709950ff3cea1#egg=ddtrace
exceptiongroup==1.2.2
iniconfig==2.1.0
mock==5.2.0
opentracing==2.4.0
packaging==24.2
pluggy==1.5.0
psutil==7.0.0
pytest==8.3.5
pytest-cov==6.0.0
pytest-mock==3.14.0
tomli==2.2.1

name: dd-trace-py
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.8.0
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - mock==5.2.0
      - opentracing==2.4.0
      - packaging==24.2
      - pluggy==1.5.0
      - psutil==7.0.0
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - tomli==2.2.1
prefix: /opt/conda/envs/dd-trace-py

tests/internal/test_logger.py::DDLoggerTestCase::test_logger_handle_bucket_skipped_msg
tests/internal/test_logger.py::DDLoggerTestCase::test_get_logger tests/internal/test_logger.py::DDLoggerTestCase::test_get_logger_parents tests/internal/test_logger.py::DDLoggerTestCase::test_logger_handle_bucket tests/internal/test_logger.py::DDLoggerTestCase::test_logger_handle_bucket_key tests/internal/test_logger.py::DDLoggerTestCase::test_logger_handle_bucket_limited tests/internal/test_logger.py::DDLoggerTestCase::test_logger_handle_no_limit tests/internal/test_logger.py::DDLoggerTestCase::test_logger_init tests/internal/test_logger.py::DDLoggerTestCase::test_logger_log
ddtrace/internal/logger.py
ddtrace/internal/logger.py