Skip to content
Snippets Groups Projects
Unverified Commit 069bbedd authored by Rodrigo Nascimento's avatar Rodrigo Nascimento Committed by GitHub
Browse files

[FIX] App removal was moving logs to the trash collection (#16362)

* [FIX] App removal was moving logs to the trash collection

It may cause a huge delay and memory overload if the app contains a huge history of logs

* Add indexes and expire logs after 30 days

* Add instance id to apps engine logs
parent 0ddecc71
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
</div> </div>
</div> </div>
<div class="section-content"> <div class="section-content">
{{#if log.instanceId}}
<span>Instance: {{log.instanceId}}</span>
{{/if}}
<span></span>
{{#each entry in log.entries}} {{#each entry in log.entries}}
<div>{{ entry.severity }}: {{ entry.timestamp }} (Caller: {{ entry.caller }})</div> <div>{{ entry.severity }}: {{ entry.timestamp }} (Caller: {{ entry.caller }})</div>
<div> <div>
......
import { AppConsole } from '@rocket.chat/apps-engine/server/logging'; import { AppConsole } from '@rocket.chat/apps-engine/server/logging';
import { AppLogStorage } from '@rocket.chat/apps-engine/server/storage'; import { AppLogStorage } from '@rocket.chat/apps-engine/server/storage';
import { InstanceStatus } from 'meteor/konecty:multiple-instances-status';
export class AppRealLogsStorage extends AppLogStorage { export class AppRealLogsStorage extends AppLogStorage {
constructor(model) { constructor(model) {
...@@ -25,6 +26,8 @@ export class AppRealLogsStorage extends AppLogStorage { ...@@ -25,6 +26,8 @@ export class AppRealLogsStorage extends AppLogStorage {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const item = AppConsole.toStorageEntry(appId, logger); const item = AppConsole.toStorageEntry(appId, logger);
item.instanceId = InstanceStatus.id();
try { try {
const id = this.db.insert(item); const id = this.db.insert(item);
......
...@@ -3,5 +3,13 @@ import { Base } from './_Base'; ...@@ -3,5 +3,13 @@ import { Base } from './_Base';
export class AppsLogsModel extends Base { export class AppsLogsModel extends Base {
constructor() { constructor() {
super('apps_logs'); super('apps_logs');
this.tryEnsureIndex({ appId: 1 });
this.tryEnsureIndex({ _updatedAt: 1 }, { expireAfterSeconds: 60 * 60 * 24 * 30 });
}
// Bypass trash collection
remove(query) {
return this._db.originals.remove(query);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment