Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

All spans of a trace share sampling state #377

Merged
merged 33 commits into from
Aug 29, 2019

Conversation

yurishkuro
Copy link
Member

@yurishkuro yurishkuro commented Aug 26, 2019

Replaces #372

Part of solution for #379

tiffon and others added 14 commits August 26, 2019 18:18
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
@codecov
Copy link

codecov bot commented Aug 27, 2019

Codecov Report

Merging #377 into master will decrease coverage by 0.46%.
The diff coverage is 99.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #377      +/-   ##
==========================================
- Coverage   99.01%   98.54%   -0.47%     
==========================================
  Files          44       48       +4     
  Lines        1721     1853     +132     
  Branches      337      352      +15     
==========================================
+ Hits         1704     1826     +122     
- Misses         17       27      +10
Impacted Files Coverage Δ
src/configuration.js 98.95% <100%> (ø) ⬆️
src/span.js 100% <100%> (ø) ⬆️
src/span_context.js 92.74% <100%> (-7.26%) ⬇️
src/samplers/v2/sampling_state.js 100% <100%> (ø)
src/samplers/constants.js 100% <100%> (ø)
src/tracer.js 100% <100%> (ø) ⬆️
src/samplers/v2/base.js 100% <100%> (ø)
src/samplers/_adapt_sampler.js 97.14% <97.14%> (ø)
... and 3 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 5da0f31...ecf631e. Read the comment docs.

Yuri Shkuro added 5 commits August 27, 2019 16:03
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
@@ -68,7 +68,7 @@
"precommit": "lint-staged",
"test": "make test",
"test-dist": "mocha dist/test/ dist/test/baggage/ dist/test/throttler/ dist/test/samplers/ dist/test/metrics/",
"test-all": "npm run test-core && npm run test-samplers && npm run test-crossdock && npm run test-baggage && npm run test-throttler && npm run test-prom-metrics",
"test-all": "npm run test-core && npm run test-samplers && npm run test-baggage && npm run test-throttler && npm run test-prom-metrics && npm run test-crossdock",
Copy link
Member Author

Choose a reason for hiding this comment

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

moved crossdock test in the last position

@@ -224,7 +224,7 @@ export default class Configuration {
}

if (options.logger) {
options.logger.info(`Initializing Jaeger Tracer with ${reporter.name()} and ${sampler.name()}`);
options.logger.info(`Initializing Jaeger Tracer with ${reporter} and ${sampler}`);
Copy link
Member Author

Choose a reason for hiding this comment

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

don't need to rely on name() function, toString should work.

Yuri Shkuro added 8 commits August 27, 2019 20:00
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Copy link
Contributor

@vprithvi vprithvi left a comment

Choose a reason for hiding this comment

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

Need to go through again

"args": ["--timeout", "999999", "--compilers", "js:babel-core/register", "--colors", "${file}"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
// "runtimeVersion": "10",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: invalid JSON

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's fine, actually. It's not a real JSON file. If you open VSCode settings as JSON, it has other comments, like

// Place your settings in this file to overwrite the default settings

/**
* Sampler methods return SamplingDecision struct.
*/
declare type SamplingDecision = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should call this SamplingResult because it contains information in addition to the decision (0/1) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think "decision" is a more accurate term. It does not mean that it's a primitive yes/no value (cf. Supreme Court decision - lots of additional details), yet it's a decision that is not yet implemented, whereas "result" would be the consequence of implementing that decision.

}

onSetTag(span: Span, key: string, value: any): SamplingDecision {
return { sample: false, retryable: true, tags: null };
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a comment with some reasoning would be useful when we look at this later

Copy link
Member Author

Choose a reason for hiding this comment

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

I have them in the class comment.


let _instanceId = 0;

export default class BaseSamplerV2 implements Sampler {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

at this point it's not used, until we resolve the babel issue with inheritance. I could remove it, it will still be in the PR history.

Copy link
Contributor

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 it if we are not using it

_final: boolean = false;

// Span ID of the local root span, i.e. the first span in this process for this trace.
_localRootSpanIdStr: ?string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename this to firstInProcessSpanIdStr? (go client has a var called firstInProcess...)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think 'local root' is a good name, and I've seen it used in other places (zipkin, OC).

*
* This field exists to help distinguish between when a span can have a properly
* correlated operation name -> sampling rate mapping, and when it cannot.
* Adaptive sampling uses the operation name of a span to correlate it with
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the part about adaptive sampling live elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

it will, remember this is a change that aims to keep status quo.

* then adaptive sampling cannot associate the operation name with the proper sampling rate.
* In order to correct this we allow a span to be written to, so that we can re-sample
* it in the case that an operation name is set after span creation. Situations
* where a span context's sampling decision is finalized include:
Copy link
Contributor

Choose a reason for hiding this comment

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

Are all of these situations still accurate?

Copy link
Member Author

Choose a reason for hiding this comment

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

as of this diff, yes

const _childId = idIsStr ? null : childId;
const _childIdStr = idIsStr ? childId : null;
return new SpanContext(
this._traceId, // traceId
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of these comments?

Copy link
Member Author

Choose a reason for hiding this comment

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

I find it hard to read without them, especially then values don't match the argument meaning, as in this._spanId, // parentId

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should improve this constructor (in a different diff?)

Yuri Shkuro added 4 commits August 28, 2019 18:53
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
@yurishkuro yurishkuro merged commit 0fae741 into jaegertracing:master Aug 29, 2019

ctx.traceId = randomId;
ctx.spanId = randomId;
ctx.parentId = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a test in the adaptor that explicitly checks that parentId is null (as opposed to undefined) for a newly created span - do you think this behavior is expected and relied upon elsewhere else?

Copy link
Member Author

Choose a reason for hiding this comment

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

we should restore it, probably assign null explicitly in the constructor

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

Successfully merging this pull request may close these issues.

3 participants