Skip to content

Commit 272b4b8

Browse files
ci: gts fix for ci build
Signed-off-by: Olivier Albertini <[email protected]>
1 parent 284aaeb commit 272b4b8

File tree

43 files changed

+154
-373
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+154
-373
lines changed

packages/opentelemetry-basic-tracer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@types/mocha": "^5.2.5",
4242
"@types/node": "^12.6.8",
4343
"codecov": "^3.1.0",
44-
"gts": "^1.0.0",
44+
"gts": "^1.1.0",
4545
"mocha": "^6.1.0",
4646
"nyc": "^14.1.1",
4747
"ts-mocha": "^6.0.0",

packages/opentelemetry-basic-tracer/src/Span.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515
*/
1616

1717
import * as types from '@opentelemetry/types';
18-
import {
19-
randomSpanId,
20-
randomTraceId,
21-
INVALID_SPAN_CONTEXT,
22-
isValid,
23-
} from '@opentelemetry/core';
18+
import { randomSpanId, randomTraceId, INVALID_SPAN_CONTEXT, isValid } from '@opentelemetry/core';
2419
import { performance } from 'perf_hooks';
2520
import { TraceOptions } from '@opentelemetry/types';
2621

@@ -36,19 +31,15 @@ export class Span implements types.Span {
3631
private readonly _links: types.Link[] = [];
3732
private readonly _events: types.Event[] = [];
3833
private _status: types.Status = {
39-
code: types.CanonicalCode.OK,
34+
code: types.CanonicalCode.OK
4035
};
4136
private _name: string;
4237
private _ended = false;
4338
private _startTime: number;
4439
private _endTime = 0;
4540

4641
/** Constructs a new Span instance. */
47-
constructor(
48-
parentTracer: types.Tracer,
49-
spanName: string,
50-
options: types.SpanOptions
51-
) {
42+
constructor(parentTracer: types.Tracer, spanName: string, options: types.SpanOptions) {
5243
this._tracer = parentTracer;
5344
this._name = spanName;
5445
this._spanContext.spanId = randomSpanId();
@@ -132,14 +123,12 @@ export class Span implements types.Span {
132123
kind: this._kind,
133124
status: this._status,
134125
startTime: this._startTime,
135-
endTime: this._endTime,
126+
endTime: this._endTime
136127
});
137128
return `Span${json}`;
138129
}
139130

140-
private _getParentSpanContext(
141-
parent: types.Span | types.SpanContext | undefined
142-
): types.SpanContext | undefined {
131+
private _getParentSpanContext(parent: types.Span | types.SpanContext | undefined): types.SpanContext | undefined {
143132
if (!parent) return undefined;
144133

145134
// parent is a SpanContext

packages/opentelemetry-basic-tracer/src/types.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@
1515
*/
1616

1717
import { ScopeManager } from '@opentelemetry/scope-base';
18-
import {
19-
Attributes,
20-
BinaryFormat,
21-
HttpTextFormat,
22-
Logger,
23-
Sampler,
24-
} from '@opentelemetry/types';
18+
import { Attributes, BinaryFormat, HttpTextFormat, Logger, Sampler } from '@opentelemetry/types';
2519

2620
/**
2721
* BasicTracerConfig provides an interface for configuring a Basic Tracer.

packages/opentelemetry-basic-tracer/test/BasicTracer.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
HttpTraceContext,
2222
NEVER_SAMPLER,
2323
NOOP_SPAN,
24-
NoopLogger,
24+
NoopLogger
2525
} from '@opentelemetry/core';
2626
import { BasicTracer } from '../src/BasicTracer';
2727
import { NoopScopeManager } from '@opentelemetry/scope-base';
@@ -31,39 +31,39 @@ describe('BasicTracer', () => {
3131
describe('constructor', () => {
3232
it('should construct an instance with required only options', () => {
3333
const tracer = new BasicTracer({
34-
scopeManager: new NoopScopeManager(),
34+
scopeManager: new NoopScopeManager()
3535
});
3636
assert.ok(tracer instanceof BasicTracer);
3737
});
3838

3939
it('should construct an instance with binary format', () => {
4040
const tracer = new BasicTracer({
4141
binaryFormat: new BinaryTraceContext(),
42-
scopeManager: new NoopScopeManager(),
42+
scopeManager: new NoopScopeManager()
4343
});
4444
assert.ok(tracer instanceof BasicTracer);
4545
});
4646

4747
it('should construct an instance with http text format', () => {
4848
const tracer = new BasicTracer({
4949
httpTextFormat: new HttpTraceContext(),
50-
scopeManager: new NoopScopeManager(),
50+
scopeManager: new NoopScopeManager()
5151
});
5252
assert.ok(tracer instanceof BasicTracer);
5353
});
5454

5555
it('should construct an instance with logger', () => {
5656
const tracer = new BasicTracer({
5757
logger: new NoopLogger(),
58-
scopeManager: new NoopScopeManager(),
58+
scopeManager: new NoopScopeManager()
5959
});
6060
assert.ok(tracer instanceof BasicTracer);
6161
});
6262

6363
it('should construct an instance with sampler', () => {
6464
const tracer = new BasicTracer({
6565
scopeManager: new NoopScopeManager(),
66-
sampler: ALWAYS_SAMPLER,
66+
sampler: ALWAYS_SAMPLER
6767
});
6868
assert.ok(tracer instanceof BasicTracer);
6969
});
@@ -72,9 +72,9 @@ describe('BasicTracer', () => {
7272
const tracer = new BasicTracer({
7373
defaultAttributes: {
7474
region: 'eu-west',
75-
asg: 'my-asg',
75+
asg: 'my-asg'
7676
},
77-
scopeManager: new NoopScopeManager(),
77+
scopeManager: new NoopScopeManager()
7878
});
7979
assert.ok(tracer instanceof BasicTracer);
8080
});
@@ -83,7 +83,7 @@ describe('BasicTracer', () => {
8383
describe('.startSpan()', () => {
8484
it('should start a span with name only', () => {
8585
const tracer = new BasicTracer({
86-
scopeManager: new NoopScopeManager(),
86+
scopeManager: new NoopScopeManager()
8787
});
8888
const span = tracer.startSpan('my-span');
8989
assert.ok(span);
@@ -92,7 +92,7 @@ describe('BasicTracer', () => {
9292

9393
it('should start a span with name and options', () => {
9494
const tracer = new BasicTracer({
95-
scopeManager: new NoopScopeManager(),
95+
scopeManager: new NoopScopeManager()
9696
});
9797
const span = tracer.startSpan('my-span', {});
9898
assert.ok(span);
@@ -102,7 +102,7 @@ describe('BasicTracer', () => {
102102
it('should return a default span with no sampling', () => {
103103
const tracer = new BasicTracer({
104104
sampler: NEVER_SAMPLER,
105-
scopeManager: new NoopScopeManager(),
105+
scopeManager: new NoopScopeManager()
106106
});
107107
const span = tracer.startSpan('my-span');
108108
assert.deepStrictEqual(span, NOOP_SPAN);
@@ -118,7 +118,7 @@ describe('BasicTracer', () => {
118118
describe('.getCurrentSpan()', () => {
119119
it('should return null with NoopScopeManager', () => {
120120
const tracer = new BasicTracer({
121-
scopeManager: new NoopScopeManager(),
121+
scopeManager: new NoopScopeManager()
122122
});
123123
const currentSpan = tracer.getCurrentSpan();
124124
assert.deepStrictEqual(currentSpan, null);
@@ -128,7 +128,7 @@ describe('BasicTracer', () => {
128128
describe('.withSpan()', () => {
129129
it('should run scope with NoopScopeManager scope manager', done => {
130130
const tracer = new BasicTracer({
131-
scopeManager: new NoopScopeManager(),
131+
scopeManager: new NoopScopeManager()
132132
});
133133
const span = tracer.startSpan('my-span');
134134
tracer.withSpan(span, () => {
@@ -145,7 +145,7 @@ describe('BasicTracer', () => {
145145
describe('.getBinaryFormat()', () => {
146146
it('should get default binary formatter', () => {
147147
const tracer = new BasicTracer({
148-
scopeManager: new NoopScopeManager(),
148+
scopeManager: new NoopScopeManager()
149149
});
150150
assert.ok(tracer.getBinaryFormat() instanceof BinaryTraceContext);
151151
});
@@ -154,7 +154,7 @@ describe('BasicTracer', () => {
154154
describe('.getHttpTextFormat()', () => {
155155
it('should get default HTTP text formatter', () => {
156156
const tracer = new BasicTracer({
157-
scopeManager: new NoopScopeManager(),
157+
scopeManager: new NoopScopeManager()
158158
});
159159
assert.ok(tracer.getHttpTextFormat() instanceof HttpTraceContext);
160160
});

packages/opentelemetry-basic-tracer/test/Span.test.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,15 @@
1616

1717
import * as assert from 'assert';
1818
import { Span } from '../src/Span';
19-
import {
20-
SpanKind,
21-
SpanContext,
22-
TraceOptions,
23-
CanonicalCode,
24-
} from '@opentelemetry/types';
19+
import { SpanKind, SpanContext, TraceOptions, CanonicalCode } from '@opentelemetry/types';
2520
import { NoopTracer } from '@opentelemetry/core';
2621

2722
describe('Span', () => {
2823
const tracer = new NoopTracer();
2924
const spanContext: SpanContext = {
3025
traceId: 'd4cda95b652f4a1592b449d5929fda1b',
3126
spanId: '6e0c63257de34c92',
32-
traceOptions: TraceOptions.SAMPLED,
27+
traceOptions: TraceOptions.SAMPLED
3328
};
3429
const name = 'span1';
3530

@@ -57,7 +52,7 @@ describe('Span', () => {
5752

5853
it('should set an attribute', () => {
5954
const span = new Span(tracer, name, {
60-
attributes: { service: 'service-1' },
55+
attributes: { service: 'service-1' }
6156
});
6257

6358
['String', 'Number', 'Boolean'].map(attType => {
@@ -82,14 +77,14 @@ describe('Span', () => {
8277
const span = new Span(tracer, name, {});
8378
span.setStatus({
8479
code: CanonicalCode.PERMISSION_DENIED,
85-
message: 'This is an error',
80+
message: 'This is an error'
8681
});
8782
});
8883

8984
it('should return toString', () => {
9085
const span = new Span(tracer, name, {
9186
kind: SpanKind.SERVER,
92-
startTime: 100,
87+
startTime: 100
9388
});
9489
const context = span.context();
9590

packages/opentelemetry-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@types/node": "^12.6.8",
4949
"@types/webpack-env": "1.13.9",
5050
"codecov": "^3.1.0",
51-
"gts": "^1.0.0",
51+
"gts": "^1.1.0",
5252
"karma": "^4.1.0",
5353
"karma-chrome-launcher": "^2.2.0",
5454
"karma-mocha": "^1.3.0",

packages/opentelemetry-core/src/context/propagation/BinaryTraceContext.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ const SPAN_ID_OFFSET = SPAN_ID_FIELD_ID_OFFSET + ID_SIZE;
3535
const TRACE_OPTION_FIELD_ID_OFFSET = SPAN_ID_OFFSET + SPAN_ID_SIZE;
3636
const TRACE_OPTIONS_OFFSET = TRACE_OPTION_FIELD_ID_OFFSET + ID_SIZE;
3737

38-
const FORMAT_LENGTH =
39-
4 * ID_SIZE + TRACE_ID_SIZE + SPAN_ID_SIZE + TRACE_OPTION_SIZE;
38+
const FORMAT_LENGTH = 4 * ID_SIZE + TRACE_ID_SIZE + SPAN_ID_SIZE + TRACE_OPTION_SIZE;
4039

4140
export class BinaryTraceContext implements BinaryFormat {
4241
toBytes(spanContext: SpanContext): Uint8Array {
@@ -88,9 +87,7 @@ export class BinaryTraceContext implements BinaryFormat {
8887
}
8988
// See serializeSpanContext for byte offsets.
9089
result.traceId = toHex(buf.slice(TRACE_ID_OFFSET, SPAN_ID_FIELD_ID_OFFSET));
91-
result.spanId = toHex(
92-
buf.slice(SPAN_ID_OFFSET, TRACE_OPTION_FIELD_ID_OFFSET)
93-
);
90+
result.spanId = toHex(buf.slice(SPAN_ID_OFFSET, TRACE_OPTION_FIELD_ID_OFFSET));
9491
result.traceOptions = buf[TRACE_OPTIONS_OFFSET];
9592
return result;
9693
}

packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {
18-
SpanContext,
19-
HttpTextFormat,
20-
TraceOptions,
21-
} from '@opentelemetry/types';
17+
import { SpanContext, HttpTextFormat, TraceOptions } from '@opentelemetry/types';
2218
import { TraceState } from '../../trace/TraceState';
2319

2420
export const TRACE_PARENT_HEADER = 'traceparent';
@@ -37,11 +33,7 @@ function parse(traceParent: string): SpanContext | null {
3733
// tslint:disable-next-line:ban Needed to parse hexadecimal.
3834
const traceOptions = parseInt(option, 16);
3935

40-
if (
41-
!isValidVersion(version) ||
42-
!isValidTraceId(traceId) ||
43-
!isValidSpanId(spanId)
44-
) {
36+
if (!isValidVersion(version) || !isValidTraceId(traceId) || !isValidSpanId(spanId)) {
4537
return null;
4638
}
4739

@@ -67,42 +59,29 @@ function isValidSpanId(spanId: string): boolean {
6759
* https://www.w3.org/TR/trace-context/
6860
*/
6961
export class HttpTraceContext implements HttpTextFormat {
70-
inject(
71-
spanContext: SpanContext,
72-
format: string,
73-
carrier: { [key: string]: unknown }
74-
) {
75-
const traceParent = `${VERSION}-${spanContext.traceId}-${
76-
spanContext.spanId
77-
}-0${Number(spanContext.traceOptions || TraceOptions.UNSAMPLED).toString(
78-
16
79-
)}`;
62+
inject(spanContext: SpanContext, format: string, carrier: { [key: string]: unknown }) {
63+
const traceParent = `${VERSION}-${spanContext.traceId}-${spanContext.spanId}-0${Number(
64+
spanContext.traceOptions || TraceOptions.UNSAMPLED
65+
).toString(16)}`;
8066

8167
carrier[TRACE_PARENT_HEADER] = traceParent;
8268
if (spanContext.traceState) {
8369
carrier[TRACE_STATE_HEADER] = spanContext.traceState.serialize();
8470
}
8571
}
8672

87-
extract(
88-
format: string,
89-
carrier: { [key: string]: unknown }
90-
): SpanContext | null {
73+
extract(format: string, carrier: { [key: string]: unknown }): SpanContext | null {
9174
const traceParentHeader = carrier[TRACE_PARENT_HEADER];
9275
if (!traceParentHeader) return null;
93-
const traceParent = Array.isArray(traceParentHeader)
94-
? traceParentHeader[0]
95-
: traceParentHeader;
76+
const traceParent = Array.isArray(traceParentHeader) ? traceParentHeader[0] : traceParentHeader;
9677
const spanContext = parse(traceParent);
9778
if (!spanContext) return null;
9879

9980
const traceStateHeader = carrier[TRACE_STATE_HEADER];
10081
if (traceStateHeader) {
10182
// If more than one `tracestate` header is found, we merge them into a
10283
// single header.
103-
const state = Array.isArray(traceStateHeader)
104-
? traceStateHeader.join(',')
105-
: traceStateHeader;
84+
const state = Array.isArray(traceStateHeader) ? traceStateHeader.join(',') : traceStateHeader;
10685
spanContext.traceState = new TraceState(state as string);
10786
}
10887
return spanContext;

packages/opentelemetry-core/src/internal/validators.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,5 @@ export function validateKey(key: string): boolean {
3232
* characters (i.e., the range 0x20 to 0x7E) except comma , and =.
3333
*/
3434
export function validateValue(value: string): boolean {
35-
return (
36-
VALID_VALUE_BASE_REGEX.test(value) &&
37-
!INVALID_VALUE_COMMA_EQUAL_REGEX.test(value)
38-
);
35+
return VALID_VALUE_BASE_REGEX.test(value) && !INVALID_VALUE_COMMA_EQUAL_REGEX.test(value);
3936
}

packages/opentelemetry-core/src/trace/NoopSpan.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ import { INVALID_SPAN_CONTEXT } from '../trace/spancontext-utils';
2424
* propagation.
2525
*/
2626
export class NoopSpan implements types.Span {
27-
constructor(
28-
private readonly _spanContext: SpanContext = INVALID_SPAN_CONTEXT
29-
) {}
27+
constructor(private readonly _spanContext: SpanContext = INVALID_SPAN_CONTEXT) {}
3028

3129
// Returns a SpanContext.
3230
context(): types.SpanContext {

0 commit comments

Comments
 (0)