[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
pull/16377/head
Rodrigo Nascimento 6 years ago committed by Diego Sampaio
parent adbca46ee1
commit bf828686fb
No known key found for this signature in database
GPG Key ID: E060152B30502562
  1. 4
      app/apps/client/admin/appLogs.html
  2. 3
      app/apps/server/storage/logs-storage.js
  3. 8
      app/models/server/models/apps-logs-model.js

@ -31,6 +31,10 @@
</div>
</div>
<div class="section-content">
{{#if log.instanceId}}
<span>Instance: {{log.instanceId}}</span>
{{/if}}
<span></span>
{{#each entry in log.entries}}
<div>{{ entry.severity }}: {{ entry.timestamp }} (Caller: {{ entry.caller }})</div>
<div>

@ -1,5 +1,6 @@
import { AppConsole } from '@rocket.chat/apps-engine/server/logging';
import { AppLogStorage } from '@rocket.chat/apps-engine/server/storage';
import { InstanceStatus } from 'meteor/konecty:multiple-instances-status';
export class AppRealLogsStorage extends AppLogStorage {
constructor(model) {
@ -25,6 +26,8 @@ export class AppRealLogsStorage extends AppLogStorage {
return new Promise((resolve, reject) => {
const item = AppConsole.toStorageEntry(appId, logger);
item.instanceId = InstanceStatus.id();
try {
const id = this.db.insert(item);

@ -3,5 +3,13 @@ import { Base } from './_Base';
export class AppsLogsModel extends Base {
constructor() {
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);
}
}

Loading…
Cancel
Save