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

Add trace params #311

Merged
merged 11 commits into from
Jan 31, 2019
Merged

Add trace params #311

merged 11 commits into from
Jan 31, 2019

Conversation

vigneshtdev
Copy link
Contributor

Addresses #285.
Unit Tests included as well.

@codecov-io
Copy link

codecov-io commented Jan 28, 2019

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #311      +/-   ##
==========================================
+ Coverage   94.75%   94.79%   +0.04%     
==========================================
  Files         114      114              
  Lines        7603     7663      +60     
  Branches      692      701       +9     
==========================================
+ Hits         7204     7264      +60     
  Misses        399      399
Impacted Files Coverage Δ
src/trace/sampler/sampler.ts 100% <0%> (ø) ⬆️
test/test-sampler.ts 100% <0%> (ø) ⬆️
test/test-tracer.ts 100% <0%> (ø) ⬆️
src/trace/model/tracer.ts 85.58% <0%> (+1.11%) ⬆️

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 de34faf...2dcab54. Read the comment docs.

@@ -70,4 +72,28 @@ export interface TracingConfig {
logger?: Logger;
}

/** Specify the deafault Tracer Paramaters */
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 commented code be removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I saw this was marked as resolved - is the commented out code below intentional? (Or maybe just a commit not pushed yet?)

packages/opencensus-core/src/trace/config/types.ts Outdated Show resolved Hide resolved

// }

export interface TraceParameters {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a top level comment for this interface as a whole?

@@ -46,7 +46,14 @@ export class CoreTracer implements types.Tracer {
sampler: samplerTypes.Sampler;
/** A configuration for starting the tracer */
logger: loggerTypes.Logger = logger.logger();

/** maxAnnotationEvents is max number of annotation events per span */
numberOfAnnontationEventsPerSpan?: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than storing the individual values here, could it just store something like traceParameters: TraceParameters = DEFAULT_TRACE_PARAMETERS?

Then if we add one more parameter later on, we don't need to add it two places.

Copy link
Contributor Author

@vigneshtdev vigneshtdev Jan 30, 2019

Choose a reason for hiding this comment

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

I have a question, do we assume that user won't configure the tracer with parameters having values more than their limit?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I missed the logic of the builder pattern below that capped those values at their limits. If other languages have that cap, we should preserve it for Node I'd think.

In that case, I would recommend making these be top-level attributes (like you have) but be made readonly to prevent changes to them once they are initialized.

packages/opencensus-core/src/trace/model/tracer.ts Outdated Show resolved Hide resolved
@@ -81,6 +88,28 @@ export class CoreTracer implements types.Tracer {
this.config = config;
this.logger = this.config.logger || logger.logger();
this.sampler = SamplerBuilder.getSampler(config.samplingRate);
if (config.traceParameters != null) {
this.numberOfAnnontationEventsPerSpan =
Copy link
Contributor

@draffensperger draffensperger Jan 29, 2019

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 integrating the default values right in line here rather than abstracting it into a builder class?

It could just be something like:

this.numberOfAnnontationEventsPerSpan = 
    Math.min(MAX_NUMBER_OF_ANNOTATION_EVENTS_PER_SPAN, 
        config.traceParameters.numberOfAnnontationEventsPerSpan ||
        MAX_NUMBER_OF_ANNOTATION_EVENTS_PER_SPAN)

and similar for the other parameters.

I personally think the builder pattern, while it makes sense for other languages is not needed in TypeScript.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @draffensperger, builder pattern is not required here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is actually no builder pattern implemented here, but it does have the methods for creating traceParameters so I used the builder suffix for the method. Should I rename the method to something else?

@draffensperger
Copy link
Contributor

Thanks for the contribution, great to have this moving ahead!! I left a number of nit-picky comments - feel free to explain if you disagree on any of these.

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.

Could you please add a line in CHANGELOG.md

packages/opencensus-core/src/trace/config/types.ts Outdated Show resolved Hide resolved
packages/opencensus-core/src/trace/sampler/sampler.ts Outdated Show resolved Hide resolved
packages/opencensus-core/src/trace/sampler/sampler.ts Outdated Show resolved Hide resolved
packages/opencensus-core/test/test-sampler.ts Outdated Show resolved Hide resolved
* span
*/
numberOfAnnontationEventsPerSpan?: number;
/** numberOfMessageEventsPerSpan is number of message events per span */
Copy link

Choose a reason for hiding this comment

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

nit: s/is number/is max number/

Same for attributes and links

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the interface definition, it should just be number of right?

Copy link

Choose a reason for hiding this comment

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

it is a maximum number allowed. So it is a max value.

@@ -42,11 +44,27 @@ export class CoreTracer implements types.Tracer {
private endedTraces: types.RootSpan[] = [];
/** Bit to represent whether trace is sampled or not. */
private readonly IS_SAMPLED = 0x1;
/** Default Limit for Annotations per span */
private readonly DEFAULT_SPAN_MAX_NUM_ANNOTATIONS = 32;
Copy link
Contributor

@draffensperger draffensperger Jan 30, 2019

Choose a reason for hiding this comment

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

Could you make these be top level constants rather than properties of the class (that would be set on each instance)?

Copy link
Member

Choose a reason for hiding this comment

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

+1

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 pending final comments. Thanks for your work on this!

@mayurkale22
Copy link
Member

@vigneshtdev is this ready to merge?

@vigneshtdev
Copy link
Contributor Author

vigneshtdev commented Jan 31, 2019

@vigneshtdev is this ready to merge?

Yeah, you can go ahead and merge it. I don't have merging rights

@mayurkale22 mayurkale22 merged commit f98ec08 into census-instrumentation:master Jan 31, 2019
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.

6 participants