Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds observability infrastructure to improve request tracing and performance monitoring. It introduces a telemetry collection system with middleware and decorators to track request durations and method execution times, along with Babel decorator support.
Changes:
- Added Babel decorators plugin support to enable TypeScript decorator syntax
- Implemented telemetry collection infrastructure with TelemetryCollector class and TimedMethod decorator
- Integrated observability middleware into the request pipeline to track HTTP requests and method execution times
- Enabled v2CreateEntity feature flag
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Added dependencies for @babel/plugin-proposal-decorators and related Babel packages |
| package.json | Added @babel/plugin-proposal-decorators dependency |
| babel.config.json | Configured decorators plugin with legacy mode |
| app/server.js | Added observabilityMiddleware to middleware chain |
| app/api/utils/requestIdMiddleware.ts | Refactored to store requestId in a variable before setting in context |
| app/api/utils/observabilityMiddleware.ts | New middleware to initialize telemetry collector and log request metrics |
| app/api/utils/languageMiddleware.ts | Added timing instrumentation for language detection |
| app/api/utils/AppContext.ts | Added methods to get/set TelemetryCollector in context |
| app/api/entities.v2/database/MongoMultiLanguageEntityDataSource.ts | Added @TimedMethod decorator to create method |
| app/api/core/libs/logger/TimedMethodDecorator.ts | New decorator to automatically track method execution time |
| app/api/core/libs/logger/TelemetryCollector.ts | New class to collect and aggregate telemetry data |
| app/api/core/infrastructure/mongodb/thesauri/MongoThesauriDataSourceV2.ts | Added @TimedMethod decorators to create and exists methods |
| app/api/core/infrastructure/express/thesaurus/UpdateThesaurusController.ts | Added @TimedMethod decorator to handle method |
| app/api/core/infrastructure/express/thesaurus/CreateThesaurusController.ts | Added @TimedMethod decorator to handle method |
| app/api/core/infrastructure/express/template/GetTemplatesController.ts | Added @TimedMethod decorator to handle method |
| app/api/core/infrastructure/express/template/CountTemplatesByThesaurusController.ts | Added @TimedMethod decorator to handle method |
| app/api/core/infrastructure/express/entity/BulkDeleteEntityController.ts | Added @TimedMethod decorator to handle method |
| app/api/core/application/thesaurusTranslationService/ThesaurusTranslationService.ts | Added @TimedMethod decorator to create method |
| app/api/config.ts | Enabled v2CreateEntity feature flag |
Comments suppressed due to low confidence (1)
app/api/utils/languageMiddleware.ts:37
- If an exception occurs in the try block before timeEnd is called, the timer will remain in an incomplete state. Consider wrapping the telemetryCollector.timeEnd call in a finally block or adding it to the catch block as well to ensure timers are always ended even when errors occur.
telemetryCollector.timeEnd('language_middleware');
next();
} catch (e) {
next(e);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…o improve-observability
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 21 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/api/core/infrastructure/express/middlewares/DependenciesContextMiddleware.ts
Show resolved
Hide resolved
app/api/core/infrastructure/express/entity/UpdateEntityController.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
fixes #
PR checklist:
QA checklist: