Skip to content

refactor(logging): use printf-style formatting#7409

Merged
watson merged 1 commit intomasterfrom
watson/cleanup-logs
Feb 2, 2026
Merged

refactor(logging): use printf-style formatting#7409
watson merged 1 commit intomasterfrom
watson/cleanup-logs

Conversation

@watson
Copy link
Copy Markdown
Collaborator

@watson watson commented Feb 2, 2026

What does this PR do?

Refactors logging statements across the codebase, where appropriate, to use printf-style formatting (%d, %s placeholders) instead of string concatenation and callback-style logging.

The changes also merge multi-line concatenated strings into single strings, eliminating runtime string concatenation overhead.

Motivation

Improve performance by avoiding unnecessary string operations and provides more consistent logging patterns throughout the tracer.

Additional notes

The new ESLint rule is written by AI, and I have only reviewed it briefly. But I think that's ok since it's just an ESLint rule.

@watson watson self-assigned this Feb 2, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 2, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.57%. Comparing base (0ac5788) to head (3e585f2).

Files with missing lines Patch % Lines
packages/dd-trace/src/openfeature/writers/base.js 0.00% 8 Missing ⚠️
...ages/dd-trace/src/openfeature/flagging_provider.js 0.00% 2 Missing ⚠️
packages/datadog-instrumentations/src/kafkajs.js 0.00% 1 Missing ⚠️
...ackages/datadog-instrumentations/src/mocha/main.js 0.00% 1 Missing ⚠️
packages/datadog-plugin-http/src/index.js 0.00% 1 Missing ⚠️
packages/dd-trace/src/llmobs/tagger.js 0.00% 1 Missing ⚠️
packages/dd-trace/src/openfeature/index.js 0.00% 1 Missing ⚠️
packages/dd-trace/src/plugins/ci_plugin.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7409   +/-   ##
=======================================
  Coverage   80.56%   80.57%           
=======================================
  Files         731      731           
  Lines       31236    31233    -3     
=======================================
- Hits        25166    25165    -1     
+ Misses       6070     6068    -2     
Flag Coverage Δ
aiguard-macos 39.11% <0.00%> (-0.10%) ⬇️
aiguard-ubuntu 39.16% <0.00%> (-0.10%) ⬇️
aiguard-windows 39.00% <0.00%> (-0.10%) ⬇️
apm-capabilities-tracing-macos 48.88% <33.33%> (+<0.01%) ⬆️
apm-capabilities-tracing-ubuntu 48.92% <33.33%> (+<0.01%) ⬆️
apm-capabilities-tracing-windows 48.65% <33.33%> (+<0.01%) ⬆️
apm-integrations-child-process 38.61% <0.00%> (-0.10%) ⬇️
apm-integrations-couchbase-18 37.48% <0.00%> (+0.05%) ⬆️
apm-integrations-couchbase-eol 37.82% <0.00%> (-0.25%) ⬇️
apm-integrations-oracledb 38.01% <0.00%> (-0.10%) ⬇️
appsec-express 55.47% <0.00%> (-0.07%) ⬇️
appsec-fastify 52.07% <0.00%> (-0.07%) ⬇️
appsec-graphql 52.40% <0.00%> (-0.07%) ⬇️
appsec-kafka 44.68% <0.00%> (-0.08%) ⬇️
appsec-ldapjs 44.36% <0.00%> (-0.08%) ⬇️
appsec-lodash 44.04% <0.00%> (-0.08%) ⬇️
appsec-macos 58.53% <0.00%> (-0.07%) ⬇️
appsec-mongodb-core 49.27% <0.00%> (-0.08%) ⬇️
appsec-mongoose 49.95% <0.00%> (-0.09%) ⬇️
appsec-mysql 51.34% <0.00%> (-0.07%) ⬇️
appsec-node-serialize 43.55% <0.00%> (-0.08%) ⬇️
appsec-passport 48.16% <0.00%> (-0.09%) ⬇️
appsec-postgres 51.13% <0.00%> (-0.07%) ⬇️
appsec-sourcing 42.88% <0.00%> (-0.08%) ⬇️
appsec-template 43.72% <0.00%> (-0.08%) ⬇️
appsec-ubuntu 58.56% <0.00%> (-0.06%) ⬇️
appsec-windows 58.40% <0.00%> (-0.08%) ⬇️
instrumentations-instrumentation-bluebird 32.28% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-body-parser 40.76% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-child_process 37.91% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-cookie-parser 34.52% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-express 34.87% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.66% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-express-session 40.44% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-fs 31.88% <0.00%> (-0.11%) ⬇️
instrumentations-instrumentation-generic-pool 29.77% <0.00%> (+<0.01%) ⬆️
instrumentations-instrumentation-http 39.64% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-knex 32.04% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-mongoose 33.61% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-multer 40.49% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-mysql2 38.30% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-passport 40.80% <0.00%> (-0.09%) ⬇️
instrumentations-instrumentation-passport-http 40.77% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-passport-local 40.77% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-pg 37.82% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-promise 32.21% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-promise-js 32.21% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-q 32.26% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-url 32.18% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-when 32.23% <0.00%> (-0.10%) ⬇️
llmobs-ai 41.41% <33.33%> (-0.10%) ⬇️
llmobs-anthropic 40.62% <25.00%> (-0.10%) ⬇️
llmobs-bedrock 39.51% <25.00%> (-0.09%) ⬇️
llmobs-google-genai 40.11% <25.00%> (-0.09%) ⬇️
llmobs-langchain 39.65% <25.00%> (-0.08%) ⬇️
llmobs-openai 44.46% <25.00%> (-0.09%) ⬇️
llmobs-vertex-ai 40.40% <25.00%> (-0.02%) ⬇️
platform-core 28.09% <ø> (ø)
platform-esbuild 31.49% <ø> (ø)
platform-instrumentations-misc 39.62% <ø> (ø)
platform-shimmer 34.83% <ø> (ø)
platform-unit-guardrails 30.37% <ø> (ø)
plugins-azure-event-hubs 22.64% <ø> (ø)
plugins-azure-service-bus 22.08% <ø> (ø)
plugins-bullmq 43.75% <0.00%> (+0.13%) ⬆️
plugins-cassandra 38.05% <0.00%> (-0.10%) ⬇️
plugins-cookie 23.69% <ø> (ø)
plugins-cookie-parser 23.50% <ø> (ø)
plugins-crypto 22.88% <ø> (ø)
plugins-dd-trace-api 38.42% <0.00%> (-0.10%) ⬇️
plugins-express-mongo-sanitize 23.67% <ø> (ø)
plugins-express-session 23.46% <ø> (ø)
plugins-fastify 42.56% <0.00%> (-0.09%) ⬇️
plugins-fetch 38.61% <0.00%> (-0.10%) ⬇️
plugins-fs 38.69% <0.00%> (-0.10%) ⬇️
plugins-generic-pool 22.68% <ø> (ø)
plugins-google-cloud-pubsub 45.77% <0.00%> (-0.09%) ⬇️
plugins-grpc 41.33% <0.00%> (-0.09%) ⬇️
plugins-handlebars 23.71% <ø> (ø)
plugins-hapi 40.46% <0.00%> (-0.10%) ⬇️
plugins-hono 40.65% <0.00%> (-0.10%) ⬇️
plugins-ioredis 38.49% <0.00%> (-0.10%) ⬇️
plugins-knex 23.51% <ø> (ø)
plugins-ldapjs 21.28% <ø> (ø)
plugins-limitd-client 32.58% <0.00%> (-0.10%) ⬇️
plugins-lodash 22.74% <ø> (ø)
plugins-mariadb 39.55% <0.00%> (-0.15%) ⬇️
plugins-memcached 38.22% <0.00%> (-0.10%) ⬇️
plugins-microgateway-core 39.46% <0.00%> (-0.10%) ⬇️
plugins-moleculer 40.87% <0.00%> (-0.10%) ⬇️
plugins-mongodb 39.65% <0.00%> (-0.02%) ⬇️
plugins-mongodb-core 39.14% <0.00%> (-0.10%) ⬇️
plugins-mongoose 40.44% <0.00%> (-0.09%) ⬇️
plugins-multer 23.46% <ø> (ø)
plugins-mysql 39.25% <0.00%> (-0.10%) ⬇️
plugins-mysql2 39.32% <0.00%> (-0.10%) ⬇️
plugins-node-serialize 23.73% <ø> (ø)
plugins-opensearch 37.89% <0.00%> (-0.10%) ⬇️
plugins-postgres 35.71% <0.00%> (-0.08%) ⬇️
plugins-process 22.88% <ø> (ø)
plugins-pug 23.69% <ø> (ø)
plugins-redis 38.81% <0.00%> (-0.10%) ⬇️
plugins-router 43.28% <0.00%> (-0.10%) ⬇️
plugins-sequelize 22.27% <ø> (ø)
plugins-test-and-upstream-amqp10 38.55% <0.00%> (+0.05%) ⬆️
plugins-test-and-upstream-amqplib 43.94% <0.00%> (-0.10%) ⬇️
plugins-test-and-upstream-apollo 39.34% <0.00%> (-0.09%) ⬇️
plugins-test-and-upstream-avsc 38.84% <0.00%> (-0.10%) ⬇️
plugins-test-and-upstream-bunyan 33.87% <0.00%> (-0.10%) ⬇️
plugins-test-and-upstream-connect 41.07% <0.00%> (-0.10%) ⬇️
plugins-test-and-upstream-graphql 40.26% <0.00%> (-0.10%) ⬇️
plugins-test-and-upstream-koa 40.71% <0.00%> (-0.10%) ⬇️
plugins-test-and-upstream-protobufjs 39.07% <0.00%> (-0.10%) ⬇️
plugins-test-and-upstream-rhea 44.19% <0.00%> (-0.10%) ⬇️
plugins-undici 39.41% <0.00%> (-0.09%) ⬇️
plugins-url 22.88% <ø> (ø)
plugins-valkey 38.11% <0.00%> (-0.13%) ⬇️
plugins-vm 22.88% <ø> (ø)
plugins-winston 34.37% <0.00%> (-0.10%) ⬇️
plugins-ws 40.79% <0.00%> (-0.10%) ⬇️
profiling-macos 40.07% <0.00%> (-0.10%) ⬇️
profiling-ubuntu 40.12% <0.00%> (-0.10%) ⬇️
profiling-windows 41.49% <0.00%> (-0.10%) ⬇️
serverless-azure-functions-client 22.88% <ø> (ø)
serverless-azure-functions-eventhubs 22.88% <ø> (ø)
serverless-azure-functions-servicebus 22.88% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Collaborator Author

watson commented Feb 2, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2026

Overall package size

Self size: 4.49 MB
Deduped: 5.33 MB
No deduping: 5.33 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.3 | 76.87 kB | 808.03 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-official

This comment has been minimized.

@watson watson force-pushed the watson/cleanup-logs branch from 0304c74 to c214f53 Compare February 2, 2026 07:53
@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Feb 2, 2026

Benchmarks

Benchmark execution time: 2026-02-02 09:07:06

Comparing candidate commit 3e585f2 in PR branch watson/cleanup-logs with baseline commit 0ac5788 in branch master.

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

@watson watson force-pushed the watson/cleanup-logs branch 2 times, most recently from ec78b86 to f105a9c Compare February 2, 2026 08:43
Replace string concatenation and callback-style logging with
printf-style formatting (%d, %s placeholders) for better performance and
consistency.

Merge multi-line concatenated strings into single strings with eslint
max-len disables where needed to avoid unnecessary string operations.
@watson watson force-pushed the watson/cleanup-logs branch from f105a9c to 3e585f2 Compare February 2, 2026 08:55
@watson watson marked this pull request as ready for review February 2, 2026 09:14
@watson watson requested review from a team as code owners February 2, 2026 09:14
@watson watson requested review from khanayan123 and removed request for a team February 2, 2026 09:14
@tlhunter
Copy link
Copy Markdown
Member

tlhunter commented Feb 2, 2026

I don't want to prefix all of my long log lines with ignore comments... Can the AI write a rule to auto ignore line lengths for log lines?

@watson
Copy link
Copy Markdown
Collaborator Author

watson commented Feb 2, 2026

@tlhunter maybe, but I don't think it's really a problem. Normally a log line is not that long. We have close to 500 log.* calls in our code and in this PR I add 6 eslint ignore comments. I don't think that warrants a custom rule.

@watson watson merged commit 2e337bd into master Feb 2, 2026
1060 of 1061 checks passed
@watson watson deleted the watson/cleanup-logs branch February 2, 2026 18:39
dd-octo-sts bot pushed a commit that referenced this pull request Feb 3, 2026
Replace string concatenation and callback-style logging with
printf-style formatting (%d, %s placeholders) for better performance and
consistency.

Merge multi-line concatenated strings into single strings with eslint
max-len disables where needed to avoid unnecessary string operations.
@dd-octo-sts dd-octo-sts bot mentioned this pull request Feb 3, 2026
BridgeAR pushed a commit that referenced this pull request Feb 5, 2026
Replace string concatenation and callback-style logging with
printf-style formatting (%d, %s placeholders) for better performance and
consistency.

Merge multi-line concatenated strings into single strings with eslint
max-len disables where needed to avoid unnecessary string operations.
bm1549 pushed a commit that referenced this pull request Feb 10, 2026
Replace string concatenation and callback-style logging with
printf-style formatting (%d, %s placeholders) for better performance and
consistency.

Merge multi-line concatenated strings into single strings with eslint
max-len disables where needed to avoid unnecessary string operations.
BridgeAR pushed a commit that referenced this pull request Feb 22, 2026
Replace string concatenation and callback-style logging with
printf-style formatting (%d, %s placeholders) for better performance and
consistency.

Merge multi-line concatenated strings into single strings with eslint
max-len disables where needed to avoid unnecessary string operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants