Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

Commit

Permalink
Adds tests that shows how to override the span name (openzipkin#97)
Browse files Browse the repository at this point in the history
Default span names are good choices as they are bounded. However, users
may want to change these to other bounded choices (ex names that don't
include variables). This shows how to accomplish this.

Note: it is quite common for custom code to get naming wrong, by using
high cardinality names such as specific http paths. This is one reason
why defaults are limited, as tags/binary annotations can be used to add
more specific lookup criteria without degrading the UI.

See openzipkin#96
See openzipkin/openzipkin.github.io#70 (comment)
  • Loading branch information
adriancole authored Jul 4, 2017
1 parent 24004df commit 8195783
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/zipkin/test/batch-recorder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,38 @@ describe('Batch Recorder', () => {
});
});

// Applications can override the span name via trace.recordRpc
it('should record span name as last recordRpc', () => {
const logSpan = sinon.spy();

const ctxImpl = new ExplicitContext();
const logger = {logSpan};
const recorder = new BatchRecorder({logger});
const trace = new Tracer({ctxImpl, recorder});

ctxImpl.scoped(() => {
trace.setId(new TraceId({
traceId: None,
parentId: new Some('a'),
spanId: 'c',
sampled: new Some(true)
}));

trace.recordServiceName('SmoothieStore');
trace.recordRpc('buySmoothie');
trace.recordAnnotation(new Annotation.ServerRecv());

// some customization code scoped to this trace ID resets the span name
trace.recordRpc('rentSmoothie');

trace.recordAnnotation(new Annotation.ServerSend());

const loggedSpan = logSpan.getCall(0).args[0];

expect(loggedSpan.name).to.eql(new Some('rentSmoothie'));
});
});

it('should set MutableSpan.startTimestamp to first record', () => {
const clock = lolex.install(12345678);
const logSpan = sinon.spy();
Expand Down

0 comments on commit 8195783

Please sign in to comment.