Skip to content

Commit

Permalink
chore(koa): add if to verity span exist
Browse files Browse the repository at this point in the history
  • Loading branch information
haddasbronfman committed Aug 18, 2022
1 parent 75edb22 commit f13cace
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ async function showNewPost(ctx: Koa.Context) {
function runTest(ctx: Koa.Context) {
console.log('runTest');
const currentSpan = api.trace.getSpan(api.context.active());
const { traceId } = currentSpan.spanContext();
console.log(`traceid: ${traceId}`);
console.log(`Jaeger URL: http://localhost:16686/trace/${traceId}`);
console.log(`Zipkin URL: http://localhost:9411/zipkin/traces/${traceId}`);
ctx.body = `All posts: ${posts}`;
ctx.redirect('/post/new');
if (currentSpan){
const { traceId } = currentSpan.spanContext();
console.log(`traceid: ${traceId}`);
console.log(`Jaeger URL: http://localhost:16686/trace/${traceId}`);
console.log(`Zipkin URL: http://localhost:9411/zipkin/traces/${traceId}`);
ctx.body = `All posts: ${posts}`;
ctx.redirect('/post/new');
}
}

async function noOp(ctx: Koa.Context, next: Koa.Next) {
Expand Down

0 comments on commit f13cace

Please sign in to comment.