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

Exporting TracerBase as a separate @opencensus/nodejs-base package #495

Merged

Conversation

hekike
Copy link
Contributor

@hekike hekike commented May 3, 2019

As @opencensus/nodejs exports a Tracing instance as default, which also initializes CLS I would like to propose a new @opencensus/nodejs-base package to avoid breaking change for existing customers. The existing @opencensus/nodejs become a thin layer on the new @opencensus/nodejs-base after this change.

The alternative solution would be to only export Tracing and TracingBase classes and let the user initialize them. It would also require to start CLS only when Tracing is initialized instead of the current global instance. This would be a breaking change.

This PR is related to #484

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.

I like this idea of splitting out the complexity of the CLS based tracer and giving the option of fully manual spans.

I left a few comments. I think we should wait for @mayurkale22 to come back Monday to get this approved and merged.

},
"dependencies": {
"@opencensus/core": "^0.0.11",
"@opencensus/instrumentation-all": "^0.0.11",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you still need this dependency if no plugins are pulled in by default?

@@ -33,7 +33,7 @@ enum HookState {
*/
export class PluginLoader {
/** The tracer */
private tracer: Tracer;
private tracer: Tracer|TracerBase;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this just be TracerBase since Tracer inherits from it? Same below.

rootSpan.end();
});
```
For manual insturmentation see the `@opencensus/nodejs-base` package.
Copy link
Contributor

Choose a reason for hiding this comment

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

What if someone wants both automatic and manual instrumentation? I would think they would be able to do it by using the @opencensus/nodejs package as well? Maybe we should still have the doc above, but mention that if you only want manual instrumentation to see the @opencensus/nodejs-base package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a very good point, I'll revert it and add the extra context.

@hekike hekike force-pushed the feat/export-base-tracing branch from 275eca0 to 5665abe Compare May 6, 2019 20:55
Copy link
Member

@mayurkale22 mayurkale22 left a comment

Choose a reason for hiding this comment

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

Please fix the build. Also update CHANGELOG.md

# of contributors, see the revision history in source control.

Google LLC
CESAR Team (www.cesar.org.br)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should remove "CESAR Team" and if you want add "Netflix".


For automatic insturmentation see the `@opencensus/nodejs` package.

### Manually Instrument an Application
Copy link
Member

Choose a reason for hiding this comment

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

Nit: s/Instrument/Instrumenting to maintain consistency.

@@ -0,0 +1,2 @@
fixes:
- "::packages/opencensus-nodejs/"
Copy link
Member

Choose a reason for hiding this comment

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

s/opencensus-nodejs/opencensus-nodejs-base?

@@ -0,0 +1,132 @@
/**
* Copyright 2018, OpenCensus Authors
Copy link
Member

Choose a reason for hiding this comment

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

Nit: s/2018/2019

@@ -61,6 +63,8 @@ tracing.tracer.startRootSpan(rootSpanOptions, (rootSpan) => {
});
```

For manual only instrumentation see the `@opencensus/nodejs-base` package.
Copy link
Member

Choose a reason for hiding this comment

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

You may want to add link for the @opencensus/nodejs-base package.

"extend": "^3.0.2",
"require-in-the-middle": "^4.0.0"
"@opencensus/nodejs-base": "^0.0.11",
"@opencensus/instrumentation-all": "^0.0.11"
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Move @opencensus/instrumentation-all above @opencensus/nodejs-base to keep the ordering intact.

@hekike
Copy link
Contributor Author

hekike commented May 7, 2019

@mayurkale22 thanks for the review. I'm trying to fix the build for days now and I couldn't figure out what's happening. It was passing on my machine earlier, now with a clean copy, I can least reproduce it. I feel it's more a mono repo thing and I'm missing something. Any chance you have a hint?

@hekike
Copy link
Contributor Author

hekike commented May 8, 2019

@mayurkale22 I could figure out, both CI and your comments are fixed now.

@codecov-io
Copy link

codecov-io commented May 8, 2019

Codecov Report

Merging #495 into master will decrease coverage by 0.29%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #495     +/-   ##
=========================================
- Coverage   94.97%   94.68%   -0.3%     
=========================================
  Files         145      145             
  Lines       10091    10231    +140     
  Branches      882      870     -12     
=========================================
+ Hits         9584     9687    +103     
- Misses        507      544     +37
Impacted Files Coverage Δ
src/zpages-frontend/page-handlers/templates-dir.ts 80% <0%> (-20%) ⬇️
test/test-http2.ts 79.47% <0%> (-17.35%) ⬇️
src/trace/propagation/noop-propagation.ts 40% <0%> (-10%) ⬇️
src/common/noop-logger.ts 11.11% <0%> (-5.56%) ⬇️
test/test-instana.ts 85.18% <0%> (-3.71%) ⬇️
src/detect-resource.ts 90.9% <0%> (-1.95%) ⬇️
test/test-detect-resource.ts 99.13% <0%> (-0.38%) ⬇️
src/internal/string-utils.ts 100% <0%> (ø) ⬆️
test/test-tag-map.ts 100% <0%> (ø) ⬆️
src/binary-format.ts 100% <0%> (ø) ⬆️
... and 32 more

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 96a6ab7...f0f27de. Read the comment docs.

Copy link
Member

@mayurkale22 mayurkale22 left a comment

Choose a reason for hiding this comment

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

Overall looks good to me, added a few comments.

package.json Outdated
@@ -6,6 +6,7 @@
"types": "build/src/index.d.ts",
"repository": "census-instrumentation/opencensus-node",
"scripts": {
"fix": "lerna run fix",
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, I would prefer to do this kind of (unrelated) changes in separate PR, just to keep PR clean and small. :)

describe('start()', () => {
let aTracingBase: core.Tracing;
const tracing = new TracingBase();
// tslint:disable:no-any
Copy link
Member

Choose a reason for hiding this comment

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

Could you please remove this TSLint rule flag?

@@ -1,5 +1,5 @@
/**
* Copyright 2018, OpenCensus Authors
* Copyright 2019, OpenCensus Authors
Copy link
Member

Choose a reason for hiding this comment

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

Usually, we don't update the copyright header when we touch the file.

@hekike
Copy link
Contributor Author

hekike commented May 8, 2019

@mayurkale22 thanks, fixed and separate PR opened for lerna fix #508

@mayurkale22
Copy link
Member

Just wondering: What do you think about renaming this package to either @opencensus/basictracer-nodejs or @opencensus/basictracer or @opencensus/basetracer-nodejs or something similar? For me, existing @opencensus/nodejs name does not make good sense, but it is hard to change that at this moment.

@hekike
Copy link
Contributor Author

hekike commented May 8, 2019

I also don't like the current name, but wouldn't it be worst to have two different naming concepts in the same project? I would keep the current naming convention in OpenCensus and fix it in OpenTelemetry.

@mayurkale22
Copy link
Member

Ok makes sense.

@hekike
Copy link
Contributor Author

hekike commented May 8, 2019

For OpenTelemetry, I don't even think we need nodejs in the naming. npm is for JS packages.
it could be just:

  • @opencensus/basictracer
  • @opencensus/tracer

Or even more building block philosophy:

  • @opencensus/tracer (basic tracer)
  • @opencensus/context-propagation (cls)
  • @opencensus/automatic (starting tracer with cls: @opencensus/tracer wrapped with @opencensus/context-propagation)

@mayurkale22
Copy link
Member

I will merge this later today, if no other comments from either @draffensperger or @justindsmith

@hekike
Copy link
Contributor Author

hekike commented May 9, 2019

@mayurkale22 can we also cut a release when it's merged?

@mayurkale22 mayurkale22 added this to the Release 0.0.12 milestone May 9, 2019
@mayurkale22
Copy link
Member

@mayurkale22 can we also cut a release when it's merged?

Sure, I would like to include #503 and #510 (if possible #454). FYI (Release Milestone) : https://github.com/census-instrumentation/opencensus-node/milestone/3. I will cut a release later tomorrow. Is that ok?

@hekike
Copy link
Contributor Author

hekike commented May 9, 2019

Perfect, thanks!

@mayurkale22 mayurkale22 merged commit 53dab13 into census-instrumentation:master May 9, 2019
@mayurkale22
Copy link
Member

@mayurkale22 can we also cut a release when it's merged?

The release (0.0.12) is completed for @opencensus/* packages. PTAL.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants