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

Commit 6199de0

Browse files
silva-fabiokjin
authored andcommitted
refactor: addressing additional review comments
1 parent 3b564fd commit 6199de0

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ export class HttpPlugin extends classes.BasePlugin {
111111
* Creates spans for incoming requests, restoring spans' context if applied.
112112
*/
113113
patchIncomingRequest() {
114-
const plugin = this;
115114
// TODO: evaluate if this function should return RequestFunction
116115
return (original: RequestFunction):
117116
types.Func<httpModule.ClientRequest> => {
117+
const plugin = this;
118118
return function incomingRequest(
119119
event: string, request: httpModule.IncomingMessage,
120120
response: httpModule.ServerResponse):
@@ -199,9 +199,9 @@ export class HttpPlugin extends classes.BasePlugin {
199199
* tracing.
200200
*/
201201
patchOutgoingRequest() {
202-
const plugin = this;
203202
return (original: types.Func<httpModule.ClientRequest>):
204203
types.Func<httpModule.ClientRequest> => {
204+
const plugin = this;
205205
return function outgoingRequest(
206206
options, callback): httpModule.ClientRequest {
207207
if (!options) {
@@ -229,7 +229,7 @@ export class HttpPlugin extends classes.BasePlugin {
229229
plugin.logger.debug('%s plugin outgoingRequest', plugin.moduleName);
230230
const traceOptions = {
231231
name:
232-
`${request.method ? request.method : 'GET'} ${options.pathname}`,
232+
`${request.method ? request.method : 'GET'} ${options.pathname}`,
233233
type: 'CLIENT',
234234
};
235235

@@ -252,6 +252,7 @@ export class HttpPlugin extends classes.BasePlugin {
252252
};
253253
}
254254

255+
// TODO: type of options shold be better define
255256
/**
256257
* Injects span's context to header for distributed tracing and finshes the
257258
* span when the response is finished.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ describe('HttpPlugin', () => {
282282
it('should not create a root span for incoming requests', async () => {
283283
plugin.applyUnpatch();
284284
const testPath = '/incoming/unpatch/';
285+
nock.enableNetConnect();
285286

286287
const options = {host: 'localhost', path: testPath, port: serverPort};
287288

packages/opencensus-propagation-b3/src/b3-format.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ export class B3Format implements types.Propagation {
6262
*/
6363
inject(setter: types.HeaderSetter, spanContext: types.SpanContext): void {
6464
if (setter) {
65-
setter.setHeader(
66-
X_B3_TRACE_ID, spanContext && spanContext.traceId || 'undefined');
67-
setter.setHeader(
68-
X_B3_SPAN_ID, spanContext && spanContext.spanId || 'undefined');
65+
setter.setHeader(X_B3_TRACE_ID, spanContext.traceId || 'undefined');
66+
setter.setHeader(X_B3_SPAN_ID, spanContext.spanId || 'undefined');
6967
if (spanContext && (spanContext.options & SAMPLED_VALUE) !== 0) {
7068
setter.setHeader(X_B3_SAMPLED, `${SAMPLED_VALUE}`);
7169
} else {

0 commit comments

Comments
 (0)