Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 209beba

Browse files
tcolgatekjin
authored andcommitted
fix: don't attempt to propagate a null span. (#120)
Strictly this should not happen, we should always get a spanContext, however, this is not currently the case.
1 parent 073ddb4 commit 209beba

File tree

1 file changed

+5
-5
lines changed
  • packages/opencensus-instrumentation-http/src

1 file changed

+5
-5
lines changed

packages/opencensus-instrumentation-http/src/http.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ export class HttpPlugin extends BasePlugin {
256256
return (span: Span): httpModule.ClientRequest => {
257257
plugin.logger.debug('makeRequestTrace');
258258

259+
if (!span) {
260+
plugin.logger.debug('makeRequestTrace span is null');
261+
return request;
262+
}
263+
259264
const setter: HeaderSetter = {
260265
setHeader(name: string, value: string) {
261266
request.setHeader(name, value);
@@ -267,11 +272,6 @@ export class HttpPlugin extends BasePlugin {
267272
propagation.inject(setter, span.spanContext);
268273
}
269274

270-
if (!span) {
271-
plugin.logger.debug('makeRequestTrace span is null');
272-
return request;
273-
}
274-
275275
request.on('response', (response: httpModule.ClientResponse) => {
276276
plugin.tracer.wrapEmitter(response);
277277
plugin.logger.debug('outgoingRequest on response()');

0 commit comments

Comments
 (0)