diff --git a/test/integration/__snapshots__/tracing.spec.js.snap b/test/integration/__snapshots__/tracing.spec.js.snap index 2a06624d6..d7a606cb8 100644 --- a/test/integration/__snapshots__/tracing.spec.js.snap +++ b/test/integration/__snapshots__/tracing.spec.js.snap @@ -431,7 +431,7 @@ Array [ }, Object { "error": null, - "id": "broker-1-11", + "id": "broker-1-15", "logs": Array [], "name": "update others", "parentID": "broker-1-2", @@ -447,10 +447,10 @@ Array [ }, Object { "error": null, - "id": "broker-2-15", + "id": "broker-2-19", "logs": Array [], "name": "User updated event", - "parentID": "broker-1-11", + "parentID": "broker-1-15", "priority": 5, "sampled": true, "service": Object { @@ -475,10 +475,10 @@ Array [ }, Object { "error": null, - "id": "broker-2-16", + "id": "broker-2-20", "logs": Array [], "name": "updating user", - "parentID": "broker-2-15", + "parentID": "broker-2-19", "priority": 5, "sampled": true, "service": Object { @@ -491,10 +491,10 @@ Array [ }, Object { "error": null, - "id": "broker-2-17", + "id": "broker-2-21", "logs": Array [], "name": "action 'friends.count'", - "parentID": "broker-2-16", + "parentID": "broker-2-20", "priority": 5, "sampled": true, "service": Object { diff --git a/test/integration/tracing.spec.js b/test/integration/tracing.spec.js index 69d8bde75..7ea3b6f6b 100644 --- a/test/integration/tracing.spec.js +++ b/test/integration/tracing.spec.js @@ -47,15 +47,26 @@ describe("Test Tracing feature with actions", () => { uidGenerator: broker => `${broker.nodeID}-${idCounter++}` }; + //const stacks = []; + const STORE = []; const broker0 = H.createNode(_.defaultsDeep({ nodeID: "broker-0" }, COMMON_SETTINGS), [ { name: "tracing-collector", events: { - "$tracing.spans"(ctx) { - STORE.push(...ctx.params); + "$tracing.spans": { + tracing: false, + handler(ctx) { + STORE.push(...ctx.params); + } } + /*"**": { + tracing: false, + handler(ctx) { + stacks.push(`${ctx.broker.nodeID}:${ctx.eventName}`); + } + }*/ } } ]); @@ -81,11 +92,13 @@ describe("Test Tracing feature with actions", () => { } }, events: { - "comments.removed"(ctx) { + async "comments.removed"(ctx) { const span1 = ctx.startSpan("update posts"); ctx.broadcast("post.updated"); ctx.finishSpan(span1); + await broker1.Promise.delay(500); + const span2 = ctx.startSpan("update others"); ctx.broadcast("user.updated"); ctx.finishSpan(span2); @@ -199,6 +212,7 @@ describe("Test Tracing feature with actions", () => { it("should generate event spans", async () => { idCounter = 1; STORE.length = 0; + //stacks.length = 0; await broker1.emit("comments.removed", null, { meta: { @@ -215,6 +229,8 @@ describe("Test Tracing feature with actions", () => { const spans = getSpanFields(STORE); + //console.log(stacks); + expect(spans).toMatchSnapshot(); }); });