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

Add trace params#311

Merged
mayurkale22 merged 11 commits intocensus-instrumentation:masterfrom
vigneshtdev:add-trace-params
Jan 31, 2019
Merged

Add trace params#311
mayurkale22 merged 11 commits intocensus-instrumentation:masterfrom
vigneshtdev:add-trace-params

Conversation

@vigneshtdev
Copy link
Copy Markdown
Contributor

Addresses #285.
Unit Tests included as well.

@codecov-io
Copy link
Copy Markdown

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.

logger?: Logger;
}

/** Specify the deafault Tracer Paramaters */
Copy link
Copy Markdown
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
Copy Markdown
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?)


// }

export interface TraceParameters {
Copy link
Copy Markdown
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?

logger: loggerTypes.Logger = logger.logger();

/** maxAnnotationEvents is max number of annotation events per span */
numberOfAnnontationEventsPerSpan?: number;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

this.logger = this.config.logger || logger.logger();
this.sampler = SamplerBuilder.getSampler(config.samplingRate);
if (config.traceParameters != null) {
this.numberOfAnnontationEventsPerSpan =
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

* span
*/
numberOfAnnontationEventsPerSpan?: number;
/** numberOfMessageEventsPerSpan is number of message events per span */
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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.

/** 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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

Copy link
Copy Markdown
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
Copy Markdown
Member

@vigneshtdev is this ready to merge?

@vigneshtdev
Copy link
Copy Markdown
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
@vigneshtdev vigneshtdev deleted the add-trace-params branch January 31, 2019 18:13
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