-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3556 from SOZ-Faut-etre-Sub/feat/profiler-scope
feat(profiler): add scope for profiler so we can have more information when profiling
- Loading branch information
Showing
10 changed files
with
73 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
resources/[soz]/soz-core/src/core/middleware/middleware.event.client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { EventMetadata } from '../decorators/event'; | ||
import { Injectable } from '../decorators/injectable'; | ||
import { Inject, Injectable } from '../decorators/injectable'; | ||
import { Middleware, MiddlewareFactory } from './middleware'; | ||
import { ProfilerMiddlewareFactory } from './profiler.middleware'; | ||
|
||
@Injectable() | ||
export class ChainMiddlewareEventClientFactory implements MiddlewareFactory { | ||
@Inject(ProfilerMiddlewareFactory) | ||
private profilerMiddlewareFactory: ProfilerMiddlewareFactory; | ||
|
||
create(event: EventMetadata, next: Middleware): Middleware { | ||
return next; | ||
return this.profilerMiddlewareFactory.create(event, next); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
resources/[soz]/soz-core/src/core/middleware/middleware.tick.client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { Injectable } from '../decorators/injectable'; | ||
import { Inject, Injectable } from '../decorators/injectable'; | ||
import { TickMetadata } from '../decorators/tick'; | ||
import { Middleware, MiddlewareTickFactory } from './middleware'; | ||
import { ProfilerTickMiddlewareFactory } from './profiler.middleware'; | ||
|
||
@Injectable() | ||
export class ChainMiddlewareTickClientFactory implements MiddlewareTickFactory { | ||
@Inject(ProfilerTickMiddlewareFactory) | ||
private profilerTickMiddlewareFactory: ProfilerTickMiddlewareFactory; | ||
|
||
create(tick: TickMetadata, next: Middleware): Middleware { | ||
return next; | ||
return this.profilerTickMiddlewareFactory.create(tick, next); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
resources/[soz]/soz-core/src/core/middleware/profiler.middleware.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { EventMetadata } from '../decorators/event'; | ||
import { Injectable } from '../decorators/injectable'; | ||
import { TickMetadata } from '../decorators/tick'; | ||
import { Middleware, MiddlewareFactory, MiddlewareTickFactory } from './middleware'; | ||
|
||
@Injectable() | ||
export class ProfilerMiddlewareFactory implements MiddlewareFactory { | ||
public create(event: EventMetadata, next: Middleware): Middleware { | ||
return async (...args): Promise<void> => { | ||
ProfilerEnterScope(`[soz-core] event: ${event.name}`); | ||
|
||
const promise = next(...args); | ||
|
||
ProfilerExitScope(); | ||
|
||
return await promise; | ||
}; | ||
} | ||
} | ||
|
||
@Injectable() | ||
export class ProfilerTickMiddlewareFactory implements MiddlewareTickFactory { | ||
public create(tick: TickMetadata, next: Middleware): Middleware { | ||
return async (...args): Promise<void> => { | ||
ProfilerEnterScope(`[soz-core] tick: ${tick.name} (${tick.interval}ms)`); | ||
|
||
const promise = next(...args); | ||
|
||
ProfilerExitScope(); | ||
|
||
return await promise; | ||
}; | ||
} | ||
} |