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

Commit 3b86c76

Browse files
committed
Fix code style.
1 parent 072bfc4 commit 3b86c76

9 files changed

Lines changed: 75 additions & 33 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/**
2+
* Copyright 2018 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
118
export interface ExporterOptions {
219

320
}

packages/opencensus-core/src/internal/clock.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ export class Clock {
2828
}
2929

3030
public end(): void {
31-
if (this._ended) return
31+
if (this._ended){
32+
return
33+
}
3234
this.diff = process.hrtime(this._hrtime)
3335
this._ended = true
3436
}
3537

3638
public get duration(): number {
37-
if (!this._ended) return null
39+
if (!this._ended){
40+
return null
41+
}
3842
var ns = this.diff[0] * 1e9 + this.diff[1]
3943
return ns / 1e6
4044
}

packages/opencensus-core/src/internal/cls-ah.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2017 Google Inc. All Rights Reserved.
2+
* Copyright 2018 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import * as asyncHook from 'async_hooks';
18-
import {Context, Func, Namespace as CLSNamespace} from 'continuation-local-storage';
19-
import {EventEmitter} from 'events';
20-
import * as shimmer from 'shimmer';
17+
import * as asyncHook from 'async_hooks'
18+
import {Context, Func, Namespace as CLSNamespace} from 'continuation-local-storage'
19+
import {EventEmitter} from 'events'
20+
import * as shimmer from 'shimmer'
2121

2222
const wrappedSymbol = Symbol('context_wrapped');
2323
let contexts: {[asyncId: number]: Context;} = {};

packages/opencensus-core/src/internal/cls.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015 Google Inc. All Rights Reserved.
2+
* Copyright 2018 Google Inc. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
import * as CLS from 'continuation-local-storage';
18-
import * as semver from 'semver';
17+
import * as CLS from 'continuation-local-storage'
18+
import * as semver from 'semver'
1919

2020
export type Namespace = CLS.Namespace;
2121
export type Func<T> = CLS.Func<T>;

packages/opencensus-core/src/internal/util.ts

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

17-
import * as crypto from 'crypto';
18-
import * as Debug from "debug";
17+
import * as crypto from 'crypto'
18+
import * as Debug from "debug"
1919

2020
export const debug = Debug("opencensus");
2121

packages/opencensus-core/src/trace/model/span.ts

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

17-
import {Clock} from '../../internal/clock';
18-
import {Trace} from './trace';
17+
import {Clock} from '../../internal/clock'
18+
import {Trace} from './trace'
1919
import {debug, randomSpanId} from '../../internal/util'
2020
import {TraceBaseModel} from '../types/tracetypes'
2121

@@ -53,18 +53,21 @@ export class Span extends TraceBaseModel {
5353

5454
public start() {
5555
super.start();
56-
debug('starting span %o', {id: this.id, traceId: this.traceId, name: this.name })
56+
debug('starting span %o',
57+
{id: this.id,
58+
traceId: this.traceId,
59+
name: this.name})
5760
}
5861

5962
public end(): void {
6063
super.end();
6164
debug('ending span %o',
62-
{spanId: this.id,
63-
traceId: this.trace.id,
64-
name: this.name ,
65-
startTime: this.startTime,
66-
endTime: this.endTime,
67-
duration: this.duration}
65+
{spanId: this.id,
66+
traceId: this.trace.id,
67+
name: this.name ,
68+
startTime: this.startTime,
69+
endTime: this.endTime,
70+
duration: this.duration}
6871
)
6972

7073
}

packages/opencensus-core/src/trace/model/trace.ts

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

17-
import {Span} from './span'
17+
import * as uuid from 'uuid'
18+
19+
import {Span} from './span'
1820
import {Clock} from '../../internal/clock'
19-
import * as uuid from 'uuid';
2021
import {debug} from '../../internal/util'
2122
import {TraceBaseModel} from '../types/tracetypes'
2223

@@ -48,7 +49,11 @@ export class Trace extends TraceBaseModel {
4849
})
4950

5051
debug('ending trace %o',
51-
{id: this.id, name: this.name, startTime: this.startTime, endTime: this.endTime, duration: this.duration})
52+
{id: this.id,
53+
name: this.name,
54+
startTime: this.startTime,
55+
endTime: this.endTime,
56+
duration: this.duration})
5257
}
5358

5459
public startSpan(name: string, type: string) {

packages/opencensus-core/src/trace/model/tracer.ts

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

17-
import * as cls from '../../internal/cls';
17+
import * as cls from '../../internal/cls'
1818
import {Trace} from './trace'
1919
import {Span} from './span'
2020
import {debug} from '../../internal/util'
2121
import {Stackdriver} from '../../exporters/stackdriver/stackdriver'
2222
import {StackdriverOptions} from '../../exporters/stackdriver/options'
23-
import { Exporter } from '../../exporters/exporter';
23+
import { Exporter } from '../../exporters/exporter'
2424

2525
export type Func<T> = (...args: any[]) => T;
2626

2727
export class Tracer {
2828

29-
readonly PLUGINS = ['http', 'https', 'mongodb-core', 'express']
29+
readonly PLUGINS = ['http', 'https', 'mongodb-core', 'express'];
3030

3131
private _active: boolean;
3232
private contextManager: cls.Namespace;
@@ -65,7 +65,9 @@ export class Tracer {
6565
}
6666

6767
public endTrace(): void {
68-
if (!this.currentTrace) return debug('cannot end trace - no active trace found')
68+
if (!this.currentTrace){
69+
return debug('cannot end trace - no active trace found')
70+
}
6971
this.currentTrace.end();
7072
this.addEndedTrace(this.currentTrace);
7173
//this.clearCurrentTrace();
@@ -80,7 +82,7 @@ export class Tracer {
8082
if (!this.currentTrace) {
8183
debug('no current trace found - cannot start a new span');
8284
} else {
83-
newSpan = this.currentTrace.startSpan(name, type)
85+
newSpan = this.currentTrace.startSpan(name, type);
8486
}
8587
return newSpan;
8688
}

packages/opencensus-core/src/trace/types/tracetypes.ts

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

17-
import {Clock} from '../../internal/clock';
17+
import {Clock} from '../../internal/clock'
1818
import {debug, randomSpanId} from '../../internal/util'
1919

2020

@@ -153,15 +153,26 @@ export abstract class TraceBaseModel {
153153
//TODO: review
154154
public truncate() {
155155
if (!this.started) {
156-
debug('calling truncate non-started %s - ignoring %o', this._className, {id: this.id, name: this.name, type: this.type})
156+
debug('calling truncate non-started %s - ignoring %o',
157+
this._className,
158+
{id: this.id,
159+
name: this.name,
160+
type: this.type})
157161
return
158162
} else if (this.ended) {
159-
debug('calling truncate already ended %s - ignoring %o',this._className, {id: this.id, name: this.name, type: this.type})
163+
debug('calling truncate already ended %s - ignoring %o',
164+
this._className,
165+
{id: this.id,
166+
name: this.name,
167+
type: this.type})
160168
return
161169
}
162170
this._truncated = true
163171
this.end()
164-
debug('truncating %s %o', this._className, {id: this.id, name: this.name })
172+
debug('truncating %s %o',
173+
this._className,
174+
{id: this.id,
175+
name: this.name})
165176
}
166177

167178
}

0 commit comments

Comments
 (0)