Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

feat: add rootSpan.createChildSpan and change none CLS semantics#731

Merged
kjin merged 5 commits intogoogleapis:masterfrom
kjin:new-child
May 2, 2018
Merged

feat: add rootSpan.createChildSpan and change none CLS semantics#731
kjin merged 5 commits intogoogleapis:masterfrom
kjin:new-child

Conversation

@kjin
Copy link
Copy Markdown
Contributor

@kjin kjin commented Apr 27, 2018

Fixes #719

This PR does two things:

  • In feat: allow "disabling" cls, and relax requirements for creating root spans #728, a new config.clsMechanism option was added where, when set to 'none', a barebones CLS mechanism would be used where when a root span was started, it became the only possible active root span context until it was ended. This PR changes this so that root span context will never be written when clsMechanism is set to 'none'. Instead, the root span context always has a default value of UNTRACED. This affects the behavior of the custom tracing API in the following ways:
    • traceApi.runInRootSpan will always return a root span (unless disallowed by the trace policy), even if run within a function passed to another call to runInRootSpan.
    • traceApi.createChildSpan will always return an UNTRACED child span. This is because root spans can no longer be automatically determined from the root context.
  • To address the second difference above, there is now a rootSpan.createChildSpan which takes the same options as traceApi.createChildSpan. When clsMechanism is set to 'none', the latter will not work, but the former will; when clsMechanism is set to/defaults to 'auto', they should behave the same way.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 27, 2018
@kjin kjin force-pushed the new-child branch 4 times, most recently from 2fdd4cc to 9d00124 Compare April 27, 2018 23:07
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2018

Codecov Report

Merging #731 into master will decrease coverage by 0.04%.
The diff coverage is 91.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #731      +/-   ##
==========================================
- Coverage   90.92%   90.88%   -0.05%     
==========================================
  Files          30       30              
  Lines        1564     1568       +4     
  Branches      302      304       +2     
==========================================
+ Hits         1422     1425       +3     
  Misses         59       59              
- Partials       83       84       +1
Impacted Files Coverage Δ
src/cls.ts 96.15% <100%> (+1.92%) ⬆️
src/cls/null.ts 88.88% <100%> (ø)
src/trace-api.ts 93.4% <84.61%> (-1.04%) ⬇️
src/span-data.ts 93.87% <90%> (-1.37%) ⬇️

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 6e46ed1...978ad95. Read the comment docs.

@kjin kjin force-pushed the new-child branch 3 times, most recently from c3add20 to c3bd690 Compare April 28, 2018 00:11
@kjin
Copy link
Copy Markdown
Contributor Author

kjin commented Apr 28, 2018

/cc @tjmehta

@tjmehta
Copy link
Copy Markdown

tjmehta commented Apr 28, 2018

Wow you are fast @kjin! I am out of town and will check this out tomorrow

Comment thread scripts/check-install.ts Outdated
cwd: installDir
});
await spawnP('npm', ['install', 'typescript', '@types/node', tgz[0]], {
await spawnP('npm', ['install', 'typescript', '@types/node@9', tgz[0]], {

This comment was marked as spam.

This comment was marked as spam.

Comment thread src/cls.ts Outdated

enable(): void {
if (!this.enabled) {
// if this.CLSClass = DefaultCLS, the user specifically asked not to use

This comment was marked as spam.

Comment thread src/span-data.ts
import {Constants, SpanDataType} from './constants';
import {SpanData as SpanData} from './plugin-types';
import * as types from './plugin-types';
import {SpanData, SpanOptions} from './plugin-types';

This comment was marked as spam.

Comment thread src/span-data.ts
}

createChildSpan(options: SpanOptions): SpanData {
options = options || {name: ''};

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Comment thread src/cls.ts Outdated

enable(): void {
if (!this.enabled) {
// if this.CLSClass = NoneCLS, the user specifically asked not to use

This comment was marked as spam.

Comment thread src/span-data.ts

import {Constants, SpanDataType} from './constants';
import {SpanData as SpanData} from './plugin-types';
import * as types from './plugin-types';

This comment was marked as spam.

This comment was marked as spam.

@kjin
Copy link
Copy Markdown
Contributor Author

kjin commented May 1, 2018

@tjmehta Were you able to get a chance to look at the new API? (I understand that it's a sizeable PR -- I think the user-visible changes should mostly be encapsulated in this file)

@kjin kjin merged commit d0009ff into googleapis:master May 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants