You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2020/07/26 03:51:37 UTC
[skywalking-nodejs] 12/23: Reformat code styles
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-nodejs.git
commit 20709adb64a5866ed043250f443884f3c283c2d6
Author: kezhenxu94 <ke...@163.com>
AuthorDate: Wed Jun 24 17:42:45 2020 +0800
Reformat code styles
---
src/agent/Buffer.ts | 4 +-
src/agent/protocol/grpc/AuthInterceptor.ts | 23 ++++----
src/agent/protocol/grpc/GrpcProtocol.ts | 4 +-
src/agent/protocol/grpc/SegmentObjectAdapter.ts | 72 +++++++++++++------------
src/trace/Component.ts | 4 +-
src/trace/ID.ts | 3 +-
src/trace/NewID.ts | 3 +-
src/trace/context/CarrierItem.ts | 3 +-
src/trace/context/DummyContext.ts | 1 -
src/trace/span/DummySpan.ts | 3 +-
src/trace/span/EntrySpan.ts | 8 +--
src/trace/span/ExitSpan.ts | 8 +--
src/trace/span/LocalSpan.ts | 8 +--
src/trace/span/Span.ts | 16 +++---
src/trace/span/StackedSpan.ts | 2 +-
15 files changed, 83 insertions(+), 79 deletions(-)
diff --git a/src/agent/Buffer.ts b/src/agent/Buffer.ts
index 48f6181..6f0736c 100644
--- a/src/agent/Buffer.ts
+++ b/src/agent/Buffer.ts
@@ -48,7 +48,5 @@ class Buffer {
}
export default new Buffer(
- Number.isSafeInteger(config.maxBufferSize)
- ? Number.parseInt(config.maxBufferSize, 10)
- : 1000,
+ Number.isSafeInteger(config.maxBufferSize) ? Number.parseInt(config.maxBufferSize, 10) : 1000,
);
diff --git a/src/agent/protocol/grpc/AuthInterceptor.ts b/src/agent/protocol/grpc/AuthInterceptor.ts
index e8d12b7..0d93a51 100644
--- a/src/agent/protocol/grpc/AuthInterceptor.ts
+++ b/src/agent/protocol/grpc/AuthInterceptor.ts
@@ -21,16 +21,19 @@ import * as grpc from 'grpc';
import { InterceptingCall, Listener, Metadata, Requester } from 'grpc';
import config from '../../../config/AgentConfig';
-type Options = { [key: string]: string | number }
+type Options = { [key: string]: string | number };
export default function AuthInterceptor(options: Options, nextCall: (options: Options) => InterceptingCall) {
- return new grpc.InterceptingCall(nextCall(options), new class implements Requester {
- // tslint:disable-next-line:ban-types
- start(metadata: Metadata, listener: Listener, next: Function) {
- if (config.authorization) {
- metadata.add('Authentication', config.authorization);
+ return new grpc.InterceptingCall(
+ nextCall(options),
+ new (class implements Requester {
+ // tslint:disable-next-line:ban-types
+ start(metadata: Metadata, listener: Listener, next: Function) {
+ if (config.authorization) {
+ metadata.add('Authentication', config.authorization);
+ }
+ next(metadata, listener);
}
- next(metadata, listener);
- }
- });
-};
+ })(),
+ );
+}
diff --git a/src/agent/protocol/grpc/GrpcProtocol.ts b/src/agent/protocol/grpc/GrpcProtocol.ts
index f5462f6..4875459 100644
--- a/src/agent/protocol/grpc/GrpcProtocol.ts
+++ b/src/agent/protocol/grpc/GrpcProtocol.ts
@@ -22,7 +22,6 @@ import HeartbeatClient from '../../../agent/protocol/grpc/clients/HeartbeatClien
import TraceReportClient from '../../../agent/protocol/grpc/clients/TraceReportClient';
export default class GrpcProtocol implements Protocol {
-
get isConnected(): boolean {
return HeartbeatClient.isConnected && TraceReportClient.isConnected;
}
@@ -34,5 +33,4 @@ export default class GrpcProtocol implements Protocol {
report() {
TraceReportClient.start();
}
-
-};
+}
diff --git a/src/agent/protocol/grpc/SegmentObjectAdapter.ts b/src/agent/protocol/grpc/SegmentObjectAdapter.ts
index 3909323..0ffa8e8 100644
--- a/src/agent/protocol/grpc/SegmentObjectAdapter.ts
+++ b/src/agent/protocol/grpc/SegmentObjectAdapter.ts
@@ -28,42 +28,46 @@ import Segment from '../../../trace/context/Segment';
export default class SegmentObjectAdapter extends SegmentObject {
constructor(segment: Segment) {
super();
- this
- .setService(config.serviceName)
+ this.setService(config.serviceName)
.setServiceinstance(config.serviceInstance)
.setTraceid(segment.relatedTraces[0].toString())
.setTracesegmentid(segment.segmentId.toString())
- .setSpansList(segment.spans.map(span => new SpanObject()
- .setSpanid(span.id)
- .setParentspanid(span.parentId)
- .setStarttime(span.startTime)
- .setEndtime(span.endTime)
- .setOperationname(span.operation)
- .setPeer(span.peer)
- .setSpantype(span.type)
- .setSpanlayer(span.layer)
- .setComponentid(span.component.id)
- .setIserror(span.errored)
- .setLogsList(span.logs.map(log => new Log()
- .setTime(log.timestamp)
- .setDataList(log.items.map(logItem => new KeyStringValuePair()
- .setKey(logItem.key)
- .setValue(logItem.val),
- )),
- ))
- .setTagsList(span.tags.map(tag => new KeyStringValuePair()
- .setKey(tag.key)
- .setValue(tag.val),
- ))
- .setRefsList(span.refs.map(ref => new SegmentReference()
- .setReftype(RefType.CROSSPROCESS)
- .setTraceid(ref.traceId.toString())
- .setParenttracesegmentid(ref.segmentId.toString())
- .setParentspanid(ref.spanId)
- .setParentservice(ref.service)
- .setParentserviceinstance(ref.serviceInstance)
- .setNetworkaddressusedatpeer(ref.clientAddress),
- )),
- ));
+ .setSpansList(
+ segment.spans.map((span) =>
+ new SpanObject()
+ .setSpanid(span.id)
+ .setParentspanid(span.parentId)
+ .setStarttime(span.startTime)
+ .setEndtime(span.endTime)
+ .setOperationname(span.operation)
+ .setPeer(span.peer)
+ .setSpantype(span.type)
+ .setSpanlayer(span.layer)
+ .setComponentid(span.component.id)
+ .setIserror(span.errored)
+ .setLogsList(
+ span.logs.map((log) =>
+ new Log()
+ .setTime(log.timestamp)
+ .setDataList(
+ log.items.map((logItem) => new KeyStringValuePair().setKey(logItem.key).setValue(logItem.val)),
+ ),
+ ),
+ )
+ .setTagsList(span.tags.map((tag) => new KeyStringValuePair().setKey(tag.key).setValue(tag.val)))
+ .setRefsList(
+ span.refs.map((ref) =>
+ new SegmentReference()
+ .setReftype(RefType.CROSSPROCESS)
+ .setTraceid(ref.traceId.toString())
+ .setParenttracesegmentid(ref.segmentId.toString())
+ .setParentspanid(ref.spanId)
+ .setParentservice(ref.service)
+ .setParentserviceinstance(ref.serviceInstance)
+ .setNetworkaddressusedatpeer(ref.clientAddress),
+ ),
+ ),
+ ),
+ );
}
}
diff --git a/src/trace/Component.ts b/src/trace/Component.ts
index 30d0ee4..299140d 100644
--- a/src/trace/Component.ts
+++ b/src/trace/Component.ts
@@ -22,7 +22,5 @@ export class Component {
static HTTP = new Component(2);
static HTTP_SERVER = new Component(49);
- constructor(public id: number) {
- }
-
+ constructor(public id: number) {}
}
diff --git a/src/trace/ID.ts b/src/trace/ID.ts
index fa961b7..4e6fc56 100644
--- a/src/trace/ID.ts
+++ b/src/trace/ID.ts
@@ -20,8 +20,7 @@
import { v4 as uuid } from 'uuid';
export default class ID {
- constructor(public rawId: string = uuid().replace(/-/gi, '')) {
- }
+ constructor(public rawId: string = uuid().replace(/-/gi, '')) {}
public toString = (): string => {
return this.rawId;
diff --git a/src/trace/NewID.ts b/src/trace/NewID.ts
index 3db214f..e01c469 100644
--- a/src/trace/NewID.ts
+++ b/src/trace/NewID.ts
@@ -19,5 +19,4 @@
import ID from '../trace/ID';
-export default class NewID extends ID {
-}
+export default class NewID extends ID {}
diff --git a/src/trace/context/CarrierItem.ts b/src/trace/context/CarrierItem.ts
index 2d58a9f..99b2fa2 100644
--- a/src/trace/context/CarrierItem.ts
+++ b/src/trace/context/CarrierItem.ts
@@ -20,6 +20,5 @@
export class CarrierItem {
value!: string;
- constructor(public key: string) {
- }
+ constructor(public key: string) {}
}
diff --git a/src/trace/context/DummyContext.ts b/src/trace/context/DummyContext.ts
index f41ebbe..54a98e8 100644
--- a/src/trace/context/DummyContext.ts
+++ b/src/trace/context/DummyContext.ts
@@ -75,5 +75,4 @@ export default class DummyContext implements Context {
restore(snapshot: Snapshot) {
// Big Bang ~
}
-
}
diff --git a/src/trace/span/DummySpan.ts b/src/trace/span/DummySpan.ts
index 2d65f8e..f5387c8 100644
--- a/src/trace/span/DummySpan.ts
+++ b/src/trace/span/DummySpan.ts
@@ -19,5 +19,4 @@
import Span from '../../trace/span/Span';
-export default class DummySpan extends Span {
-}
+export default class DummySpan extends Span {}
diff --git a/src/trace/span/EntrySpan.ts b/src/trace/span/EntrySpan.ts
index 8f2ebdb..bede555 100644
--- a/src/trace/span/EntrySpan.ts
+++ b/src/trace/span/EntrySpan.ts
@@ -28,9 +28,11 @@ export default class EntrySpan extends StackedSpan {
maxDepth = 0;
constructor(options: SpanCtorOptions) {
- super(Object.assign(options, {
- type: SpanType.ENTRY,
- }));
+ super(
+ Object.assign(options, {
+ type: SpanType.ENTRY,
+ }),
+ );
}
start(): this {
diff --git a/src/trace/span/ExitSpan.ts b/src/trace/span/ExitSpan.ts
index d9d67a3..5b3fb8b 100644
--- a/src/trace/span/ExitSpan.ts
+++ b/src/trace/span/ExitSpan.ts
@@ -25,9 +25,11 @@ import { ContextCarrier } from '../context/ContextCarrier';
export default class ExitSpan extends StackedSpan {
constructor(options: SpanCtorOptions) {
- super(Object.assign(options, {
- type: SpanType.EXIT,
- }));
+ super(
+ Object.assign(options, {
+ type: SpanType.EXIT,
+ }),
+ );
}
start(): this {
diff --git a/src/trace/span/LocalSpan.ts b/src/trace/span/LocalSpan.ts
index dc4651d..0fbbe62 100644
--- a/src/trace/span/LocalSpan.ts
+++ b/src/trace/span/LocalSpan.ts
@@ -22,8 +22,10 @@ import { SpanType } from '../../proto/language-agent/Tracing_pb';
export default class LocalSpan extends Span {
constructor(options: SpanCtorOptions) {
- super(Object.assign(options, {
- type: SpanType.LOCAL,
- }));
+ super(
+ Object.assign(options, {
+ type: SpanType.LOCAL,
+ }),
+ );
}
}
diff --git a/src/trace/span/Span.ts b/src/trace/span/Span.ts
index a5972b3..decfcf3 100644
--- a/src/trace/span/Span.ts
+++ b/src/trace/span/Span.ts
@@ -59,7 +59,7 @@ export default abstract class Span {
endTime = 0;
errored = false;
- constructor(options: SpanCtorOptions & { type: SpanType; }) {
+ constructor(options: SpanCtorOptions & { type: SpanType }) {
this.context = options.context;
this.operation = options.operation;
this.type = options.type;
@@ -110,10 +110,10 @@ export default abstract class Span {
this.tags.push(Object.assign({}, tag));
}
- const sameTags = this.tags.filter(it => it.key === tag.key);
+ const sameTags = this.tags.filter((it) => it.key === tag.key);
if (sameTags.length) {
- sameTags.forEach(it => it.val = tag.val);
+ sameTags.forEach((it) => (it.val = tag.val));
} else {
this.tags.push(Object.assign({}, tag));
}
@@ -125,10 +125,12 @@ export default abstract class Span {
this.errored = true;
this.logs.push({
timestamp: new Date().getTime(),
- items: [{
- key: 'Stack',
- val: error.stack,
- } as LogItem],
+ items: [
+ {
+ key: 'Stack',
+ val: error.stack,
+ } as LogItem,
+ ],
} as Log);
return this;
}
diff --git a/src/trace/span/StackedSpan.ts b/src/trace/span/StackedSpan.ts
index d06a8bc..1839cf6 100644
--- a/src/trace/span/StackedSpan.ts
+++ b/src/trace/span/StackedSpan.ts
@@ -27,7 +27,7 @@ const logger = createLogger(__filename);
export default class StackedSpan extends Span {
depth = 0;
- constructor(options: SpanCtorOptions & { type: SpanType; }) {
+ constructor(options: SpanCtorOptions & { type: SpanType }) {
super(options);
}