Skip to content

Commit

Permalink
feat: agent context can be extended (#3478)
Browse files Browse the repository at this point in the history
  • Loading branch information
denghongcai authored and dead-horse committed Feb 20, 2019
1 parent a2f0d96 commit 7147b23
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/loader/agent_worker_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class AgentWorkerLoader extends EggLoader {

load() {
this.loadAgentExtend();
this.loadContextExtend();

this.loadCustomAgent();
}
}
Expand Down
15 changes: 15 additions & 0 deletions test/app/extend/context.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ describe('test/app/extend/context.test.js', () => {
});
});

describe('agent anonymous context can be extended', () => {
let app;
before(() => {
app = utils.app('apps/custom-context-getlogger');
return app.ready();
});
after(() => app.close());

it('should extend context as app', () => {
const ctx = app.agent.createAnonymousContext();
const logger = ctx.getLogger('foo');
logger.info('hello');
});
});

describe('properties', () => {
let app;
before(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/lib/egg.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('test/lib/egg.test.js', () => {

it('should read timing data', function* () {
let json = readJson(path.join(baseDir, `run/agent_timing_${process.pid}.json`));
assert(json.length === 32);
assert(json.length === 39);
assert(json[0].name === 'Application Start');
assert(json[0].pid === process.pid);

Expand Down

0 comments on commit 7147b23

Please sign in to comment.