Skip to content

Add selective instrumentation configuration#501

Open
sinsi404 wants to merge 1 commit intoopen-telemetry:mainfrom
sinsi404:feat/selective-instrumentation
Open

Add selective instrumentation configuration#501
sinsi404 wants to merge 1 commit intoopen-telemetry:mainfrom
sinsi404:feat/selective-instrumentation

Conversation

@sinsi404
Copy link

I've added a feature to selectively enable or disable Laravel auto-instrumentations via environment variables. This is required for me to disable db instrumentation as it has some weird bug. It will also help improve performance when the application doesn't require specific traces.

This selective instrumentation approach is inspired by auto-instrumentations-node

This is my first PR to this community, so please let me know if there's anything I should fix or improve.

@sinsi404 sinsi404 requested a review from a team as a code owner January 22, 2026 02:14
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 22, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: sinsi404 / name: sinsi404 (1af7037)

Support OTEL_LARAVEL_ENABLED_INSTRUMENTATIONS and
OTEL_LARAVEL_DISABLED_INSTRUMENTATIONS environment variables
to enable/disable specific instrumentations (http, console,
queue, eloquent, cache, db, etc.)
@sinsi404 sinsi404 force-pushed the feat/selective-instrumentation branch from 732b96c to 1af7037 Compare January 23, 2026 03:23
@ChrisLightfootWild
Copy link
Contributor

to disable db instrumentation as it has some weird bug.

Please can you open a bug report for this?

@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.64%. Comparing base (4d13696) to head (1af7037).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #501      +/-   ##
============================================
+ Coverage     82.54%   83.64%   +1.09%     
+ Complexity     2338     2198     -140     
============================================
  Files           159      136      -23     
  Lines          8823     8015     -808     
============================================
- Hits           7283     6704     -579     
+ Misses         1540     1311     -229     
Flag Coverage Δ
Aws 93.37% <ø> (ø)
Context/Swoole 0.00% <ø> (ø)
Exporter/Instana 49.80% <ø> (ø)
Instrumentation/AwsSdk 82.00% <ø> (ø)
Instrumentation/CakePHP 20.42% <ø> (ø)
Instrumentation/CodeIgniter 79.31% <ø> (ø)
Instrumentation/Curl 86.88% <ø> (ø)
Instrumentation/Doctrine 92.82% <ø> (ø)
Instrumentation/ExtAmqp 88.80% <ø> (ø)
Instrumentation/ExtRdKafka 86.13% <ø> (ø)
Instrumentation/Guzzle 76.25% <ø> (ø)
Instrumentation/HttpAsyncClient 78.94% <ø> (ø)
Instrumentation/HttpConfig 28.76% <ø> (ø)
Instrumentation/IO 0.00% <ø> (ø)
Instrumentation/Laravel ?
Instrumentation/MongoDB 76.84% <ø> (ø)
Instrumentation/MySqli 93.39% <ø> (ø)
Instrumentation/OpenAIPHP 86.71% <ø> (ø)
Instrumentation/PDO 85.67% <ø> (ø)
Instrumentation/PostgreSql 91.36% <ø> (ø)
Instrumentation/Psr14 77.41% <ø> (ø)
Instrumentation/Psr15 89.74% <ø> (ø)
Instrumentation/Psr16 97.43% <ø> (ø)
Instrumentation/Psr18 79.41% <ø> (ø)
Instrumentation/Psr3 67.70% <ø> (ø)
Instrumentation/Psr6 97.56% <ø> (ø)
Instrumentation/ReactPHP 99.41% <ø> (ø)
Instrumentation/Session 94.28% <ø> (ø)
Instrumentation/Slim 84.21% <ø> (ø)
Logs/Monolog 100.00% <ø> (ø)
Propagation/CloudTrace 90.69% <ø> (ø)
Propagation/Instana 98.07% <ø> (ø)
Propagation/ServerTiming 94.73% <ø> (ø)
Propagation/TraceResponse 94.73% <ø> (ø)
ResourceDetectors/Azure 91.66% <ø> (ø)
ResourceDetectors/Container 93.02% <ø> (ø)
ResourceDetectors/DigitalOcean 100.00% <ø> (ø)
Sampler/Xray 78.38% <ø> (ø)
Shims/OpenTracing 92.99% <ø> (ø)
SqlCommenter 95.58% <ø> (ø)
Symfony 88.14% <ø> (ø)
Utils/Test 87.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 23 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d13696...1af7037. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +51 to +52
private const ENV_ENABLED = 'OTEL_LARAVEL_ENABLED_INSTRUMENTATIONS';
private const ENV_DISABLED = 'OTEL_LARAVEL_DISABLED_INSTRUMENTATIONS';
Copy link
Contributor

Choose a reason for hiding this comment

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

spec recommends that language-specific env vars should begin with OTEL_PHP

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

Comments