Minimize Perfomance overhead

Created on 13 January 2025, 8 days ago

Problem/Motivation

I have some concerns about the performance overhead this module introduces, creating this as a task to discuss, can expand on topics as necessary.

This is just a brain dump of ideas I had while going through the code.

* Quite a bit of initialization happens on constructors, both \Drupal\opentelemetry\OpentelemetryService, where at least the tracing makes sense, but also \Drupal\opentelemetry_logs\Logger\OpentelemetryLogs. And because the logger is injected into the OpenTelemetryService, which in turn is injected into the request event, the whole logging infrastructure is initialized on every request, but most requests shoudln't create any logs
* Logs uses terminate event, so it's initialized just to be terminated. Core has a concept to only call services that were actually initialized. I'm not sure why it uses both destruct and terminate and if it has to use destruct, why using only that isn't enough. Could also use a shutdown function like Lock, although that's pretty ugly.
* Log classes could be initialized once the first log is written, and shutdown could then also check if it was initialized to minimize work spent.
* OpenTelemetryService avoids injecting a debug dependency for messenger, but it always injects the logger, does some stuff with it ( 🐛 OpenTelemetryService::$logger is not initialized when tracing is disabled Active ) and then only conditionally logs an event. This also seems like a debug setting that will be off on production. One option for cases like this would be to use a ServiceProvider to conditionally register the service only when enabled.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇨🇭Switzerland berdir Switzerland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024