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

Code Enhancement/Refactor #403

Merged
merged 2 commits into from
Mar 8, 2019

Conversation

mayurkale22
Copy link
Member

@mayurkale22 mayurkale22 commented Mar 8, 2019

This PR contains following things

  1. Remove unsed parentSpanId from startChildSpan API.
  2. Code refactor/enhancement.
  3. Enforce noUnusedLocals on opencensus-nodejs package.

@codecov-io
Copy link

codecov-io commented Mar 8, 2019

Codecov Report

Merging #403 into master will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #403      +/-   ##
==========================================
+ Coverage   94.77%   94.79%   +0.02%     
==========================================
  Files         136      136              
  Lines        8942     8939       -3     
  Branches      650      656       +6     
==========================================
- Hits         8475     8474       -1     
+ Misses        467      465       -2
Impacted Files Coverage Δ
src/trace/model/root-span.ts 97.91% <0%> (-0.09%) ⬇️
test/test-tracer.ts 100% <0%> (ø) ⬆️
src/trace/model/tracer.ts 87.03% <0%> (+0.12%) ⬆️
src/trace/model/no-record/no-record-root-span.ts 55.88% <0%> (+3.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 73f83a1...9ffd355. Read the comment docs.

Copy link
Contributor

@draffensperger draffensperger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits

this.notifyStartSpan(root);
if (!this.active) return;
if (!root) {
return this.logger.debug('cannot start trace - no active trace found');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you think about separating the return from the logger statement? Though it compiles like this, it looks unexpected to me as if it were returning a non-undefined value from the logger statement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done.

/** An object to log information to */
private logger: core.Logger = null;
/** An object to log information to. Logs to the JS console by default. */
private logger: core.Logger = console;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: I believe there is also a logger instance in https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/common/console-logger.ts

That does formatting a bit differently from the default console instance I believe. I used console in OC Web because I didn't want to introduce extra bytes of code for the logger, but that's not really much of an issue for Node.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, done.

Change console instance to logger instance (ConsoleLogger).
Remove return from the logger statement.
@mayurkale22 mayurkale22 merged commit 36f63e6 into census-instrumentation:master Mar 8, 2019
@mayurkale22 mayurkale22 deleted the enhancement branch March 8, 2019 19:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants