From 62ab43d43d6946403986ec51eb9f22e8178d5dc6 Mon Sep 17 00:00:00 2001 From: Dave Raffensperger Date: Mon, 25 Feb 2019 21:07:15 -0500 Subject: [PATCH] Upgrade @opencensus/core dependency (#13) --- .circleci/config.yml | 8 - .../opencensus-web-core/package-lock.json | 16 +- packages/opencensus-web-core/package.json | 2 +- .../src/common/console-logger.ts | 27 --- packages/opencensus-web-core/src/index.ts | 4 +- .../src/trace/model/enums.ts | 206 ++++++++++++++++++ .../src/trace/model/root-span.ts | 22 +- .../src/trace/model/span.ts | 55 ++++- .../src/trace/model/tracer.ts | 15 +- .../src/trace/model/types.ts | 82 ------- .../test/test-root-span.ts | 18 +- .../opencensus-web-core/test/test-span.ts | 2 +- .../opencensus-web-core/test/test-tracer.ts | 3 +- .../package-lock.json | 12 +- .../package.json | 2 +- .../src/adapters.ts | 65 +----- .../src/api-types.ts | 81 +++---- .../test/mock-trace-types.ts | 63 ++---- .../test/test-adapters.ts | 39 ++-- .../test/test-ocagent.ts | 4 +- 20 files changed, 413 insertions(+), 313 deletions(-) delete mode 100644 packages/opencensus-web-core/src/common/console-logger.ts create mode 100644 packages/opencensus-web-core/src/trace/model/enums.ts delete mode 100644 packages/opencensus-web-core/src/trace/model/types.ts diff --git a/.circleci/config.yml b/.circleci/config.yml index 8fd4c540..d63fcbf1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -32,14 +32,6 @@ jobs: # fallback to using the latest cache if no exact match is found - v1-dependencies- - # Remove the mocha type references in @opencensus/core. This has been - # fixed in the upstream package on GitHub, but has not been released on - # NPM yet. We can't install the package directly from GitHub because NPM - # only supports that for packages in the root folder of the repo. - # See https://github.com/census-instrumentation/opencensus-node/pull/254 - - run: npm install || true - - run: find . -type f | grep '@opencensus/core' | xargs sed -i '/types="mocha"/d' - - run: npm install - save_cache: diff --git a/packages/opencensus-web-core/package-lock.json b/packages/opencensus-web-core/package-lock.json index 244db495..a11316ee 100644 --- a/packages/opencensus-web-core/package-lock.json +++ b/packages/opencensus-web-core/package-lock.json @@ -159,9 +159,9 @@ } }, "@opencensus/core": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@opencensus/core/-/core-0.0.8.tgz", - "integrity": "sha512-yUFT59SFhGMYQgX0PhoTR0LBff2BEhPrD9io1jWfF/VDbakRfs6Pq60rjv0Z7iaTav5gQlttJCX2+VPxFWCuoQ==", + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/@opencensus/core/-/core-0.0.9.tgz", + "integrity": "sha512-31Q4VWtbzXpVUd2m9JS6HEaPjlKvNMOiF7lWKNmXF84yUcgfAFL5re7/hjDmdyQbOp32oGc+RFV78jXIldVz6Q==", "dev": true, "requires": { "continuation-local-storage": "^3.2.1", @@ -4037,7 +4037,6 @@ "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -4047,8 +4046,7 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true, - "optional": true + "dev": true } } }, @@ -5346,9 +5344,9 @@ "dev": true }, "shimmer": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.0.tgz", - "integrity": "sha512-xTCx2vohXC2EWWDqY/zb4+5Mu28D+HYNSOuFzsyRDRvI/e1ICb69afwaUwfjr+25ZXldbOLyp+iDUZHq8UnTag==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.1.tgz", + "integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==", "dev": true }, "signal-exit": { diff --git a/packages/opencensus-web-core/package.json b/packages/opencensus-web-core/package.json index 1f0f45d2..5c851409 100644 --- a/packages/opencensus-web-core/package.json +++ b/packages/opencensus-web-core/package.json @@ -42,7 +42,7 @@ "access": "public" }, "devDependencies": { - "@opencensus/core": "^0.0.8", + "@opencensus/core": "^0.0.9", "@types/jasmine": "^3.3.4", "@types/node": "^10.12.18", "gts": "^0.9.0", diff --git a/packages/opencensus-web-core/src/common/console-logger.ts b/packages/opencensus-web-core/src/common/console-logger.ts deleted file mode 100644 index 8724421d..00000000 --- a/packages/opencensus-web-core/src/common/console-logger.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2019, OpenCensus Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as coreTypes from '@opencensus/core'; - -/** - * Logger that writes all log messages to the JS console. - * This lacks the `silly` and `logLevel` properties, which are not needed in - * the upstream @opencensus/core Logger, but the change has not been released - * to NPM set. - * See https://github.com/census-instrumentation/opencensus-node/pull/271 - */ -// tslint:disable-next-line:no-any Used to coerce `console` to Logger because -export const LOGGER = console as any as coreTypes.Logger; diff --git a/packages/opencensus-web-core/src/index.ts b/packages/opencensus-web-core/src/index.ts index ba4e81e1..73ec01b8 100644 --- a/packages/opencensus-web-core/src/index.ts +++ b/packages/opencensus-web-core/src/index.ts @@ -19,11 +19,11 @@ export {RootSpan} from './trace/model/root-span'; export {Span} from './trace/model/span'; export {Tracer} from './trace/model/tracer'; export {Tracing} from './trace/model/tracing'; -export * from './trace/model/types'; +export * from './trace/model/enums'; export * from './trace/model/attribute-keys'; // Re-export types this uses from @opencensus/core. -export {Annotation, Attributes, Link, SpanContext, SpanEventListener, TraceState, Propagation, Exporter, TracerConfig, Config} from '@opencensus/core'; +export {Annotation, Attributes, Config, Exporter, Link, MessageEvent, Propagation, SpanContext, SpanEventListener, TracerConfig, TraceState} from '@opencensus/core'; export * from './common/time-util'; export * from './common/url-util'; diff --git a/packages/opencensus-web-core/src/trace/model/enums.ts b/packages/opencensus-web-core/src/trace/model/enums.ts new file mode 100644 index 00000000..6cb5eada --- /dev/null +++ b/packages/opencensus-web-core/src/trace/model/enums.ts @@ -0,0 +1,206 @@ +/** + * Copyright 2019, OpenCensus Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Trace related enums. These can't be directly imported from + * `@opencensus/core`, because that will create a runtime dependency on it. + * That is because TypeScript enums have a runtime existence, unlike interfaces. + * A runtime dependency on `@opencensus/core` is not good for OpenCensus Web, + * because then it would need to depend on other Node libraries. + * These enums are based on @opencensus/core and the Trace protos. See: + * https://github.com/census-instrumentation/opencensus-proto/blob/master/src/opencensus/proto/trace/v1/trace.proto + * https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-core/src/trace/model/types.ts#L44 + */ + +/** + * Type of link. The relationship of the current span relative to the linked + * span. + */ +export enum LinkType { + /** + * The relationship of the two spans is unknown, or known but other + * than parent-child. + */ + UNSPECIFIED = 0, + /** The linked span is a child of the current span. */ + CHILD_LINKED_SPAN = 1, + /** The linked span is a parent of the current span. */ + PARENT_LINKED_SPAN = 2, +} + +/** + * Type of span. Can be used to specify additional relationships between spans + * in addition to a parent/child relationship. + */ +export enum SpanKind { + /** Unspecified */ + UNSPECIFIED = 0, + /** + * Indicates that the span covers server-side handling of an RPC or other + * remote network request. + */ + SERVER = 1, + /** + * Indicates that the span covers the client-side wrapper around an RPC or + * other remote request. + */ + CLIENT = 2, +} + +/** An enumeration of canonical status codes. */ +export enum CanonicalCode { + /** + * Not an error; returned on success + */ + OK = 0, + /** + * The operation was cancelled (typically by the caller). + */ + CANCELLED = 1, + /** + * Unknown error. An example of where this error may be returned is + * if a status value received from another address space belongs to + * an error-space that is not known in this address space. Also + * errors raised by APIs that do not return enough error information + * may be converted to this error. + */ + UNKNOWN = 2, + /** + * Client specified an invalid argument. Note that this differs + * from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments + * that are problematic regardless of the state of the system + * (e.g., a malformed file name). + */ + INVALID_ARGUMENT = 3, + /** + * Deadline expired before operation could complete. For operations + * that change the state of the system, this error may be returned + * even if the operation has completed successfully. For example, a + * successful response from a server could have been delayed long + * enough for the deadline to expire. + */ + DEADLINE_EXCEEDED = 4, + /** + * Some requested entity (e.g., file or directory) was not found. + */ + NOT_FOUND = 5, + /** + * Some entity that we attempted to create (e.g., file or directory) + * already exists. + */ + ALREADY_EXISTS = 6, + /** + * The caller does not have permission to execute the specified + * operation. PERMISSION_DENIED must not be used for rejections + * caused by exhausting some resource (use RESOURCE_EXHAUSTED + * instead for those errors). PERMISSION_DENIED must not be + * used if the caller can not be identified (use UNAUTHENTICATED + * instead for those errors). + */ + PERMISSION_DENIED = 7, + /** + * Some resource has been exhausted, perhaps a per-user quota, or + * perhaps the entire file system is out of space. + */ + RESOURCE_EXHAUSTED = 8, + /** + * Operation was rejected because the system is not in a state + * required for the operation's execution. For example, directory + * to be deleted may be non-empty, an rmdir operation is applied to + * a non-directory, etc. + * + * A litmus test that may help a service implementor in deciding + * between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: + * + * - Use UNAVAILABLE if the client can retry just the failing call. + * - Use ABORTED if the client should retry at a higher-level + * (e.g., restarting a read-modify-write sequence). + * - Use FAILED_PRECONDITION if the client should not retry until + * the system state has been explicitly fixed. E.g., if an "rmdir" + * fails because the directory is non-empty, FAILED_PRECONDITION + * should be returned since the client should not retry unless + * they have first fixed up the directory by deleting files from it. + * - Use FAILED_PRECONDITION if the client performs conditional + * REST Get/Update/Delete on a resource and the resource on the + * server does not match the condition. E.g., conflicting + * read-modify-write on the same resource. + */ + FAILED_PRECONDITION = 9, + /** + * The operation was aborted, typically due to a concurrency issue + * like sequencer check failures, transaction aborts, etc. + * + * See litmus test above for deciding between FAILED_PRECONDITION, + * ABORTED, and UNAVAILABLE. + */ + ABORTED = 10, + /** + * Operation was attempted past the valid range. E.g., seeking or + * reading past end of file. + * + * Unlike INVALID_ARGUMENT, this error indicates a problem that may + * be fixed if the system state changes. For example, a 32-bit file + * system will generate INVALID_ARGUMENT if asked to read at an + * offset that is not in the range [0,2^32-1], but it will generate + * OUT_OF_RANGE if asked to read from an offset past the current + * file size. + * + * There is a fair bit of overlap between FAILED_PRECONDITION and + * OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific + * error) when it applies so that callers who are iterating through + * a space can easily look for an OUT_OF_RANGE error to detect when + * they are done. + */ + OUT_OF_RANGE = 11, + /** + * Operation is not implemented or not supported/enabled in this service. + */ + UNIMPLEMENTED = 12, + /** + * Internal errors. Means some invariants expected by underlying + * system has been broken. If you see one of these errors, + * something is very broken. + */ + INTERNAL = 13, + /** + * The service is currently unavailable. This is a most likely a + * transient condition and may be corrected by retrying with + * a backoff. + * + * See litmus test above for deciding between FAILED_PRECONDITION, + * ABORTED, and UNAVAILABLE. + */ + UNAVAILABLE = 14, + /** + * Unrecoverable data loss or corruption. + */ + DATA_LOSS = 15, + /** + * The request does not have valid authentication credentials for the + * operation. + */ + UNAUTHENTICATED = 16, +} + +/** An event describing a message sent/received between Spans. */ +export enum MessageEventType { + /** Unknown event type. */ + UNSPECIFIED = 0, + /** Indicates a sent message. */ + SENT = 1, + /** Indicates a received message. */ + RECEIVED = 2, +} diff --git a/packages/opencensus-web-core/src/trace/model/root-span.ts b/packages/opencensus-web-core/src/trace/model/root-span.ts index 94c12dc0..d5234f2a 100644 --- a/packages/opencensus-web-core/src/trace/model/root-span.ts +++ b/packages/opencensus-web-core/src/trace/model/root-span.ts @@ -16,8 +16,8 @@ import * as coreTypes from '@opencensus/core'; import {randomTraceId} from '../../internal/util'; +import {SpanKind} from './enums'; import {Span} from './span'; -import {SpanKind} from './types'; /** Simple mock root span for use in use tests. */ export class RootSpan extends Span implements coreTypes.RootSpan { @@ -46,13 +46,27 @@ export class RootSpan extends Span implements coreTypes.RootSpan { } } - startChildSpan(name?: string, kind?: string): Span { + /** + * Starts a new child span in the root span. + * @param nameOrOptions Span name string or object with `name` and `kind` + * @param kind Span kind if not using options object. + */ + startChildSpan( + nameOrOptions?: string|{name: string, kind: SpanKind}, + kind?: SpanKind): Span { const child = new Span(); child.traceId = this.traceId; child.traceState = this.traceState; - if (name) child.name = name; - if (kind) child.kind = kind; + + const spanName = + typeof nameOrOptions === 'object' ? nameOrOptions.name : nameOrOptions; + const spanKind = + typeof nameOrOptions === 'object' ? nameOrOptions.kind : kind; + if (spanName) child.name = spanName; + if (spanKind) child.kind = spanKind; + child.start(); + child.parentSpanId = this.id; this.spans.push(child); return child; } diff --git a/packages/opencensus-web-core/src/trace/model/span.ts b/packages/opencensus-web-core/src/trace/model/span.ts index b81fe92d..f1d6121f 100644 --- a/packages/opencensus-web-core/src/trace/model/span.ts +++ b/packages/opencensus-web-core/src/trace/model/span.ts @@ -15,10 +15,11 @@ */ import * as coreTypes from '@opencensus/core'; -import {LOGGER} from '../../common/console-logger'; + import {getDateForPerfTime} from '../../common/time-util'; import {randomSpanId} from '../../internal/util'; -import {MessageEvent, SpanKind} from './types'; + +import {CanonicalCode, LinkType, MessageEventType, SpanKind} from './enums'; /** Default span name if none is specified. */ const DEFAULT_SPAN_NAME = 'unnamed'; @@ -50,16 +51,17 @@ export class Span implements coreTypes.Span { name = DEFAULT_SPAN_NAME; /** Kind of span. */ - kind: string = SpanKind.UNSPECIFIED; + kind: SpanKind = SpanKind.UNSPECIFIED; - /** An object to log information to. This is a console logger by default. */ - logger = LOGGER; + /** An object to log information to. Logs to the JS console by default. */ + logger: coreTypes.Logger = console; /** - * HTTP request status associated with this span. Defaults to 0, which - * indicates there is no status associated. + * Status associated with this span. Defaults to OK status. Note that the + * `code` is not an HTTP status, but is a specific trace status code. See: + * https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/HTTP.md#mapping-from-http-status-codes-to-trace-status-codes */ - status = 0; + status: coreTypes.Status = {code: CanonicalCode.OK}; /** A set of attributes, each in the format [KEY]:[VALUE] */ attributes: coreTypes.Attributes = {}; @@ -68,7 +70,7 @@ export class Span implements coreTypes.Span { annotations: coreTypes.Annotation[] = []; /** Event describing messages sent/received between Spans. */ - messageEvents: MessageEvent[] = []; + messageEvents: coreTypes.MessageEvent[] = []; /** Pointers from the current span to another span */ links: coreTypes.Link[] = []; @@ -76,6 +78,27 @@ export class Span implements coreTypes.Span { /** Start time of the span as measured by the browser performance clock. */ startPerfTime = 0; + /** + * Number of dropped attributes. This is always zero because OpenCensus web + * does not implement attribute dropping (but may be done by agent on export). + */ + readonly droppedAttributesCount = 0; + + /** Number of dropped links. Always zero for OpenCensus web. */ + readonly droppedLinksCount = 0; + + /** Number of dropped annotations. Always zero for OpenCensus web. */ + readonly droppedAnnotationsCount = 0; + + /** Number of dropped message events. Always zero for OpenCensus web. */ + readonly droppedMessageEventsCount = 0; + + /** + * Trace parameter configuration. Not used by OpenCensus Web, but + * kept for interface compatibility with @opencensus/core. + */ + readonly activeTraceParams = {}; + /** Start time of the span as a Date. */ get startTime(): Date { return getDateForPerfTime(this.startPerfTime); @@ -146,7 +169,7 @@ export class Span implements coreTypes.Span { * @param attributes A set of attributes on the link. */ addLink( - traceId: string, spanId: string, type: string, + traceId: string, spanId: string, type: LinkType, attributes: coreTypes.Attributes = {}) { this.links.push({traceId, spanId, type, attributes}); } @@ -158,10 +181,20 @@ export class Span implements coreTypes.Span { * Defaults to `performance.now()`. */ addMessageEvent( - type: string, id: string, timestamp: number = performance.now()) { + type: MessageEventType, id: string, + timestamp: number = performance.now()) { this.messageEvents.push({type, id, timestamp}); } + /** + * Sets a status to the span. + * @param code The canonical status code. + * @param message optional A developer-facing error message. + */ + setStatus(code: CanonicalCode, message?: string) { + this.status = {code, message}; + } + /** Starts span by setting `startTime` to now. */ start() { this.startPerfTime = performance.now(); diff --git a/packages/opencensus-web-core/src/trace/model/tracer.ts b/packages/opencensus-web-core/src/trace/model/tracer.ts index a1546d70..e6a08856 100644 --- a/packages/opencensus-web-core/src/trace/model/tracer.ts +++ b/packages/opencensus-web-core/src/trace/model/tracer.ts @@ -15,7 +15,6 @@ */ import * as coreTypes from '@opencensus/core'; -import {LOGGER} from '../../common/console-logger'; import {NoHeadersPropagation} from '../propagation/no_headers_propagation'; import {AlwaysSampler} from '../sampler/sampler'; import {RootSpan} from './root-span'; @@ -35,8 +34,8 @@ export class Tracer implements coreTypes.Tracer { */ sampler = new AlwaysSampler(); - /** An object to log information to. This is a console logger by default. */ - logger = LOGGER; + /** An object to log information to. Logs to the JS console by default. */ + logger: coreTypes.Logger = console; /** Trace context header propagation behavior. */ propagation = NO_HEADERS_PROPAGATION; @@ -50,13 +49,19 @@ export class Tracer implements coreTypes.Tracer { */ active = true; + /** + * Trace parameter configuration. Not used by OpenCensus Web, but + * kept for interface compatibility with @opencensus/core. + */ + readonly activeTraceParams = {}; + /** * Starts the tracer. This makes the tracer active and sets `logger` and * `propagation` based on the given config. The `samplingRate` property of * `config` is currently ignored. */ start(config: coreTypes.TracerConfig): Tracer { - this.logger = config.logger || LOGGER; + this.logger = config.logger || console; this.propagation = config.propagation || NO_HEADERS_PROPAGATION; return this; } @@ -114,7 +119,7 @@ export class Tracer implements coreTypes.Tracer { * @param kind Span kind * @returns The new Span instance started */ - startChildSpan(name?: string, kind?: string): Span { + startChildSpan(name?: string, kind?: coreTypes.SpanKind): Span { return this.currentRootSpan.startChildSpan(name, kind); } diff --git a/packages/opencensus-web-core/src/trace/model/types.ts b/packages/opencensus-web-core/src/trace/model/types.ts deleted file mode 100644 index 94d25107..00000000 --- a/packages/opencensus-web-core/src/trace/model/types.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright 2019, OpenCensus Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// TODO(draffensperger): Remove these once the new @opencensus/core version is -// pushed that has these enums/fields natively. - -/** - * Type of span. Can be used to specify additional relationships between spans - * in addition to a parent/child relationship. - */ -export enum SpanKind { - UNSPECIFIED = '', - /** - * Indicates that the span covers server-side handling of an RPC or other - * remote network request. - */ - SERVER = 'SERVER', - /** - * Indicates that the span covers the client-side wrapper around an RPC or - * other remote request. - */ - CLIENT = 'CLIENT', -} - -/** - * The relationship of the current span relative to the linked span: child, - * parent, or unspecified. - */ -export enum LinkType { - /** - * The relationship of the two spans is unknown, or known but other than - * parent-child. - */ - UNSPECIFIED = '', - /** The linked span is a child of the current span */ - CHILD_LINKED_SPAN = 'CHILD_LINKED_SPAN', - - /** The linked span is a parent of the current span. */ - PARENT_LINKED_SPAN = 'PARENT_LINKED_SPAN', -} - -/** Indicates whether the message was sent or received. */ -export enum MessageEventType { - /** Unknown event type. */ - UNSPECIFIED = '', - /** Indicates a sent message. */ - SENT = 'SENT', - /** Indicates a received message. */ - RECEIVED = 'RECEIVED', -} - -/** - * An event describing a message sent/received between Spans. - */ -export interface MessageEvent { - /** A timestamp for the event. */ - timestamp: number; - /** Indicates whether the message was sent or received. */ - type: string; - /** An identifier for the MessageEvent's message. */ - id: string; - /** The number of uncompressed bytes sent or received. */ - uncompressedSize?: number; - /** - * The number of compressed bytes sent or received. If zero or - * undefined, assumed to be the same size as uncompressed. - */ - compressedSize?: number; -} diff --git a/packages/opencensus-web-core/test/test-root-span.ts b/packages/opencensus-web-core/test/test-root-span.ts index 139807af..bd9149f7 100644 --- a/packages/opencensus-web-core/test/test-root-span.ts +++ b/packages/opencensus-web-core/test/test-root-span.ts @@ -14,9 +14,9 @@ * limitations under the License. */ +import {SpanKind} from '../src/trace/model/enums'; import {RootSpan} from '../src/trace/model/root-span'; import {Tracer} from '../src/trace/model/tracer'; -import {SpanKind} from '../src/trace/model/types'; describe('RootSpan', () => { let tracer: Tracer; @@ -62,6 +62,22 @@ describe('RootSpan', () => { expect(childSpan.traceState).toBe('a=b'); expect(childSpan.name).toBe('child1'); expect(childSpan.kind).toBe(SpanKind.CLIENT); + expect(childSpan.parentSpanId).toBe(root.id); + expect(root.spans).toEqual([childSpan]); + }); + + it('allows specifying span options object with name and kind', () => { + root.traceId = '00000000000000000000000000000001'; + root.traceState = 'a=b'; + + const childSpan = + root.startChildSpan({name: 'child1', kind: SpanKind.CLIENT}); + + expect(childSpan.traceId).toBe('00000000000000000000000000000001'); + expect(childSpan.traceState).toBe('a=b'); + expect(childSpan.name).toBe('child1'); + expect(childSpan.kind).toBe(SpanKind.CLIENT); + expect(childSpan.parentSpanId).toBe(root.id); expect(root.spans).toEqual([childSpan]); }); }); diff --git a/packages/opencensus-web-core/test/test-span.ts b/packages/opencensus-web-core/test/test-span.ts index 911c997d..5f9ab8e8 100644 --- a/packages/opencensus-web-core/test/test-span.ts +++ b/packages/opencensus-web-core/test/test-span.ts @@ -14,8 +14,8 @@ * limitations under the License. */ +import {LinkType, MessageEventType} from '../src/trace/model/enums'; import {Span} from '../src/trace/model/span'; -import {LinkType, MessageEventType} from '../src/trace/model/types'; describe('Span', () => { let span: Span; diff --git a/packages/opencensus-web-core/test/test-tracer.ts b/packages/opencensus-web-core/test/test-tracer.ts index cbd7d08e..6dfb6215 100644 --- a/packages/opencensus-web-core/test/test-tracer.ts +++ b/packages/opencensus-web-core/test/test-tracer.ts @@ -15,10 +15,9 @@ */ import * as coreTypes from '@opencensus/core'; - +import {SpanKind} from '../src/trace/model/enums'; import {RootSpan} from '../src/trace/model/root-span'; import {Tracer} from '../src/trace/model/tracer'; -import {SpanKind} from '../src/trace/model/types'; describe('Tracer', () => { let tracer: Tracer; diff --git a/packages/opencensus-web-exporter-ocagent/package-lock.json b/packages/opencensus-web-exporter-ocagent/package-lock.json index 957b1574..80de76dc 100644 --- a/packages/opencensus-web-exporter-ocagent/package-lock.json +++ b/packages/opencensus-web-exporter-ocagent/package-lock.json @@ -159,9 +159,9 @@ } }, "@opencensus/core": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@opencensus/core/-/core-0.0.8.tgz", - "integrity": "sha512-yUFT59SFhGMYQgX0PhoTR0LBff2BEhPrD9io1jWfF/VDbakRfs6Pq60rjv0Z7iaTav5gQlttJCX2+VPxFWCuoQ==", + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/@opencensus/core/-/core-0.0.9.tgz", + "integrity": "sha512-31Q4VWtbzXpVUd2m9JS6HEaPjlKvNMOiF7lWKNmXF84yUcgfAFL5re7/hjDmdyQbOp32oGc+RFV78jXIldVz6Q==", "dev": true, "requires": { "continuation-local-storage": "^3.2.1", @@ -5346,9 +5346,9 @@ "dev": true }, "shimmer": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.0.tgz", - "integrity": "sha512-xTCx2vohXC2EWWDqY/zb4+5Mu28D+HYNSOuFzsyRDRvI/e1ICb69afwaUwfjr+25ZXldbOLyp+iDUZHq8UnTag==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.1.tgz", + "integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==", "dev": true }, "signal-exit": { diff --git a/packages/opencensus-web-exporter-ocagent/package.json b/packages/opencensus-web-exporter-ocagent/package.json index fca475ad..68414fe8 100644 --- a/packages/opencensus-web-exporter-ocagent/package.json +++ b/packages/opencensus-web-exporter-ocagent/package.json @@ -43,7 +43,7 @@ "access": "public" }, "devDependencies": { - "@opencensus/core": "^0.0.8", + "@opencensus/core": "^0.0.9", "@types/jasmine": "^3.3.4", "@types/node": "^10.12.18", "gts": "^0.9.0", diff --git a/packages/opencensus-web-exporter-ocagent/src/adapters.ts b/packages/opencensus-web-exporter-ocagent/src/adapters.ts index 1ea08123..688a5419 100644 --- a/packages/opencensus-web-exporter-ocagent/src/adapters.ts +++ b/packages/opencensus-web-exporter-ocagent/src/adapters.ts @@ -64,18 +64,6 @@ function adaptTraceState(coreTraceState?: coreTypes.TraceState): return apiTraceState; } -function adaptSpanKind(coreKind: string): apiTypes.SpanKind { - switch (coreKind) { - case 'SERVER': { - return apiTypes.SpanKind.SERVER; - } - case 'CLIENT': { - return apiTypes.SpanKind.CLIENT; - } - default: { return apiTypes.SpanKind.UNSPECIFIED; } - } -} - function adaptValue(value: boolean|string|number): apiTypes.AttributeValue { const valType = typeof value; if (valType === 'boolean') { @@ -120,38 +108,17 @@ function adaptTimestampNumber(timestamp: number): string { return webCore.getIsoDateStrForPerfTime(timestamp); } -function adaptMessageEventType(type: string): apiTypes.MessageEventType { - switch (type) { - case 'SENT': { - return apiTypes.MessageEventType.SENT; - } - case 'RECEIVED': { - return apiTypes.MessageEventType.RECEIVED; - } - default: { return apiTypes.MessageEventType.UNSPECIFIED; } - } -} - function adaptMessageEvent(messageEvent: coreTypes.MessageEvent): apiTypes.TimeEvent { - const apiMessageEvent: apiTypes.MessageEvent = { - // tslint:disable-next-line:ban Needed to parse hexadecimal. - id: String(parseInt(messageEvent.id, 16)), - type: adaptMessageEventType(messageEvent.type), - }; - // TODO(draffensperger): Remove this extra logic once there is a new - // @opencensus/core release with message event size types - if ((messageEvent as webCore.MessageEvent).uncompressedSize) { - apiMessageEvent.uncompressedSize = - (messageEvent as webCore.MessageEvent).uncompressedSize; - } - if ((messageEvent as webCore.MessageEvent).compressedSize) { - apiMessageEvent.compressedSize = - (messageEvent as webCore.MessageEvent).compressedSize; - } return { time: adaptTimestampNumber(messageEvent.timestamp), - messageEvent: apiMessageEvent, + messageEvent: { + // tslint:disable-next-line:ban Needed to parse hexadecimal. + id: String(parseInt(messageEvent.id, 16)), + type: messageEvent.type, // Enum values match proto values + uncompressedSize: messageEvent.uncompressedSize, + compressedSize: messageEvent.compressedSize, + }, }; } @@ -164,23 +131,11 @@ function adaptTimeEvents( }; } -function adaptLinkType(type: string): apiTypes.LinkType { - switch (type) { - case 'CHILD_LINKED_SPAN': { - return apiTypes.LinkType.CHILD_LINKED_SPAN; - } - case 'PARENT_LINKED_SPAN': { - return apiTypes.LinkType.PARENT_LINKED_SPAN; - } - default: { return apiTypes.LinkType.UNSPECIFIED; } - } -} - function adaptLink(link: coreTypes.Link): apiTypes.Link { return { traceId: hexToBase64(link.traceId), spanId: hexToBase64(link.spanId), - type: adaptLinkType(link.type), + type: link.type, // Enum values match proto values attributes: adaptAttributes(link.attributes), }; } @@ -216,14 +171,14 @@ function adaptSpan(span: coreTypes.Span): apiTypes.Span { tracestate: adaptTraceState(span.traceState), parentSpanId: hexToBase64(span.parentSpanId), name: adaptString(span.name), - kind: adaptSpanKind(span.kind), + kind: span.kind, // Enum values match proto values. startTime: adaptSpanTime((span as MaybeWebSpan).startPerfTime, span.startTime), endTime: adaptSpanTime((span as MaybeWebSpan).endPerfTime, span.endTime), attributes: adaptAttributes(span.attributes), timeEvents: adaptTimeEvents(span.annotations, span.messageEvents), links: adaptLinks(span.links), - status: adaptStatus(span.status), + status: span.status, sameProcessAsParentSpan: !span.remoteParent, }; } diff --git a/packages/opencensus-web-exporter-ocagent/src/api-types.ts b/packages/opencensus-web-exporter-ocagent/src/api-types.ts index 525739da..9ff384f2 100644 --- a/packages/opencensus-web-exporter-ocagent/src/api-types.ts +++ b/packages/opencensus-web-exporter-ocagent/src/api-types.ts @@ -107,6 +107,24 @@ export type TraceState = { [key: string]: string }; +/** Unspecified span kind. */ +export type SpanKindUnspecified = 0; +/** + * Indicates that the span covers server-side handling of an RPC or other + * remote network request. + */ +export type SpanKindServer = 1; +/** + * Indicates that the span covers the client-side wrapper around an RPC or + * other remote request. + */ +export type SpanKindClient = 2; +/** + * Type of span. Can be used to specify additional relationships between spans + * in addition to a parent/child relationship. + */ +export type SpanKind = SpanKindUnspecified|SpanKindServer|SpanKindClient; + /** * A span represents a single operation within a trace. Spans can be nested to * form a trace tree. Often, a trace contains a root span that describes the @@ -225,6 +243,22 @@ export interface Attributes { droppedAttributesCount?: number; } +/** + * The relationship of the two spans is unknown, or known but other than + * parent-child. + */ +export type LinkTypeUnspecified = 0; +/** The linked span is a child of the current span. */ +export type LinkTypeChildLinkedSpan = 1; +/** The linked span is a parent of the current span. */ +export type LinkTypeParentLinkedSpan = 2; +/** + * The relationship of the current span relative to the linked span: child, + * parent, or unspecified. + */ +export type LinkType = + LinkTypeUnspecified|LinkTypeChildLinkedSpan|LinkTypeParentLinkedSpan; + /** * A pointer from the current span to another span in the same trace or in a * different trace. For example, this can be used in batching operations, where @@ -252,19 +286,6 @@ export interface Link { attributes?: Attributes; } -/** - * The relationship of the current span relative to the linked span: child, - * parent, or unspecified. - TYPE_UNSPECIFIED: The relationship of the two - * spans is unknown, or known but other than parent-child. - CHILD_LINKED_SPAN: - * The linked span is a child of the current span. - PARENT_LINKED_SPAN: The - * linked span is a parent of the current span. - */ -export enum LinkType { - UNSPECIFIED = 0, - CHILD_LINKED_SPAN = 1, - PARENT_LINKED_SPAN = 2, -} - /** * A collection of links, which are references from this span to a span in the * same or different trace. @@ -281,19 +302,6 @@ export interface Links { droppedLinksCount?: number; } -/** - * Type of span. Can be used to specify additional relationships between spans - * in addition to a parent/child relationship. - SPAN_KIND_UNSPECIFIED: - * Unspecified. - SERVER: Indicates that the span covers server-side handling - * of an RPC or other remote network request. - CLIENT: Indicates that the span - * covers the client-side wrapper around an RPC or other remote request. - */ -export enum SpanKind { - UNSPECIFIED = 0, - SERVER = 1, - CLIENT = 2, -} - /** * A time-stamped annotation or message event in the Span. */ @@ -401,6 +409,16 @@ export interface Annotation { attributes?: Attributes; } +/** Unknown message event type. */ +export type MessageEventTypeUnspecified = 0; +/** Indicates a sent message. */ +export type MessageEventTypeSent = 1; +/** Indicates a received message. */ +export type MessageEventTypeReceived = 2; +/** Indicates whether the message was sent or received. */ +export type MessageEventType = + MessageEventTypeUnspecified|MessageEventTypeSent|MessageEventTypeReceived; + /** * An event describing a message sent/received between Spans. */ @@ -428,17 +446,6 @@ export interface MessageEvent { compressedSize?: string|number; } -/** - * Indicates whether the message was sent or received. - TYPE_UNSPECIFIED: - * Unknown event type. - SENT: Indicates a sent message. - RECEIVED: Indicates - * a received message. - */ -export enum MessageEventType { - UNSPECIFIED = 0, - SENT = 1, - RECEIVED = 2, -} - /** * The value of an Attribute. */ diff --git a/packages/opencensus-web-exporter-ocagent/test/mock-trace-types.ts b/packages/opencensus-web-exporter-ocagent/test/mock-trace-types.ts index 90e775a1..c0fc8a7e 100644 --- a/packages/opencensus-web-exporter-ocagent/test/mock-trace-types.ts +++ b/packages/opencensus-web-exporter-ocagent/test/mock-trace-types.ts @@ -14,37 +14,8 @@ * limitations under the License. */ -import {Annotation, Attributes, Link, Logger, MessageEvent, RootSpan, Span, SpanContext, TraceState} from '@opencensus/core'; - -/** - * A no-op Logger implementation to enable MockSpan to implement the Span type - * from `@opencensus/core`. We can't use the `ConsoleLogger` from - * `@opencensus/core`, because that would cause the webpack build to try to pull - * in other Node.js specific dependencies. - */ -export class MockLogger implements Logger { - readonly level = ''; - // tslint:disable-next-line:no-any - error(message: any, ...args: any[]) { - throw new Error('Not implemented'); - } - // tslint:disable-next-line:no-any - warn(message: any, ...args: any[]) { - throw new Error('Not implemented'); - } - // tslint:disable-next-line:no-any - info(message: any, ...args: any[]) { - throw new Error('Not implemented'); - } - // tslint:disable-next-line:no-any - debug(message: any, ...args: any[]) { - throw new Error('Not implemented'); - } - // tslint:disable-next-line:no-any - silly(message: any, ...args: any[]) { - throw new Error('Not implemented'); - } -} +import {Annotation, Attributes, CanonicalCode, Link, Logger, MessageEvent, RootSpan, Span, SpanContext, Status, TraceState} from '@opencensus/core'; +import {LinkType, MessageEventType, SpanKind} from '@opencensus/web-core'; /** Helper interface for specifying the parameters of a MockSpan. */ export interface MockSpanParams { @@ -52,8 +23,8 @@ export interface MockSpanParams { remoteParent?: boolean; parentSpanId?: string; name: string; - kind?: string; - status?: number; + kind?: SpanKind; + status?: Status; attributes?: Attributes; annotations?: Annotation[]; messageEvents?: MessageEvent[]; @@ -74,9 +45,9 @@ export class MockSpan implements Span { readonly remoteParent: boolean; readonly parentSpanId: string; readonly name: string; - readonly kind: string; - readonly status: number; - readonly logger: Logger = new MockLogger(); + readonly kind: SpanKind; + readonly status: Status; + readonly logger: Logger = console; readonly attributes: Attributes; readonly annotations: Annotation[]; readonly messageEvents: MessageEvent[]; @@ -89,6 +60,11 @@ export class MockSpan implements Span { readonly startTime: Date; readonly endTime: Date; readonly spanContext: SpanContext; + readonly activeTraceParams = {}; + readonly droppedAttributesCount = 0; + readonly droppedAnnotationsCount = 0; + readonly droppedLinksCount = 0; + readonly droppedMessageEventsCount = 0; get duration(): number { return this.endTime.getTime() - this.startTime.getTime(); @@ -99,8 +75,8 @@ export class MockSpan implements Span { remoteParent = false, parentSpanId = '', name, - kind = 'SPAN_KIND_UNSPECIFIED', - status = 0, + kind = SpanKind.UNSPECIFIED, + status = {code: 0}, attributes = {}, annotations = [], messageEvents = [], @@ -140,7 +116,8 @@ export class MockSpan implements Span { } addLink( - traceId: string, spanId: string, type: string, attributes?: Attributes) { + traceId: string, spanId: string, type: LinkType, + attributes?: Attributes) { throw new Error('Not implemented'); } @@ -148,7 +125,11 @@ export class MockSpan implements Span { throw new Error('Not implemented'); } - addMessageEvent(type: string, id: string, timestamp?: number) { + addMessageEvent(type: MessageEventType, id: string, timestamp?: number) { + throw new Error('Not implemented'); + } + + setStatus(code: CanonicalCode, message?: string) { throw new Error('Not implemented'); } @@ -171,7 +152,7 @@ export class MockRootSpan extends MockSpan implements RootSpan { super(spanParams); } - startChildSpan(name: string, type: string): Span { + startChildSpan(name: string, type: SpanKind): Span { throw new Error('Not implemented'); } } diff --git a/packages/opencensus-web-exporter-ocagent/test/test-adapters.ts b/packages/opencensus-web-exporter-ocagent/test/test-adapters.ts index f8af71ab..17795e12 100644 --- a/packages/opencensus-web-exporter-ocagent/test/test-adapters.ts +++ b/packages/opencensus-web-exporter-ocagent/test/test-adapters.ts @@ -20,6 +20,11 @@ import {adaptRootSpan} from '../src/adapters'; import * as apiTypes from '../src/api-types'; import {MockRootSpan, MockSpan} from './mock-trace-types'; +const API_SPAN_KIND_UNSPECIFIED: apiTypes.SpanKindUnspecified = 0; +const API_SPAN_KIND_SERVER: apiTypes.SpanKindServer = 1; +const API_LINK_TYPE_CHILD_LINKED_SPAN: apiTypes.LinkTypeChildLinkedSpan = 1; +const API_MESSAGE_EVENT_TYPE_SENT: apiTypes.MessageEventTypeSent = 1; + describe('Core to API Span adapters', () => { it('adapts @opencensus/core span to grpc-gateway properties', () => { const coreRootSpan: coreTypes.RootSpan = new MockRootSpan( @@ -28,7 +33,7 @@ describe('Core to API Span adapters', () => { traceId: '69f223f58668171cedf0c9eab06f0d36', parentSpanId: 'b56a50b90c653f00', name: 'test1', - kind: 'SERVER', + kind: webTypes.SpanKind.SERVER, startTime: new Date(1535683887003), endTime: new Date(1535683887005), attributes: { @@ -47,14 +52,14 @@ describe('Core to API Span adapters', () => { links: [{ traceId: '79f223f58668171cedf0c9eab06f0d36', spanId: 'b56a50b90c653f00', - type: 'CHILD_LINKED_SPAN', + type: webTypes.LinkType.CHILD_LINKED_SPAN, attributes: { 'd': 'def', 'e': 456, 'f': true, }, }], - status: 404, + status: {code: 7}, }, []); @@ -63,7 +68,7 @@ describe('Core to API Span adapters', () => { spanId: 'pWpQuQxlPwA=', parentSpanId: 'tWpQuQxlPwA=', name: {value: 'test1'}, - kind: apiTypes.SpanKind.SERVER, + kind: API_SPAN_KIND_SERVER, startTime: '2018-08-31T02:51:27.003Z', endTime: '2018-08-31T02:51:27.005Z', attributes: { @@ -91,7 +96,7 @@ describe('Core to API Span adapters', () => { link: [{ traceId: 'efIj9YZoFxzt8MnqsG8NNg==', spanId: 'tWpQuQxlPwA=', - type: apiTypes.LinkType.CHILD_LINKED_SPAN, + type: API_LINK_TYPE_CHILD_LINKED_SPAN, attributes: { attributeMap: { 'd': {stringValue: {value: 'def'}}, @@ -101,7 +106,7 @@ describe('Core to API Span adapters', () => { }, }], }, - status: {code: 404}, + status: {code: 7}, sameProcessAsParentSpan: true, tracestate: {}, }; @@ -139,14 +144,14 @@ describe('Core to API Span adapters', () => { tracestate: {}, parentSpanId: '', name: {value: 'root'}, - kind: apiTypes.SpanKind.UNSPECIFIED, + kind: API_SPAN_KIND_UNSPECIFIED, startTime: '2018-08-31T02:51:27.001Z', endTime: '2018-08-31T02:51:27.009Z', attributes: {attributeMap: {}}, timeEvents: {timeEvent: []}, sameProcessAsParentSpan: true, links: {link: []}, - status: {}, + status: {code: 0}, }, { traceId: 'ifIj9YZoFxzt8MnqsG8NNg==', @@ -154,14 +159,14 @@ describe('Core to API Span adapters', () => { tracestate: {}, parentSpanId: 'pmpQuQxlPwA=', name: {value: 'child'}, - kind: apiTypes.SpanKind.UNSPECIFIED, + kind: API_SPAN_KIND_UNSPECIFIED, startTime: '2018-08-31T02:51:27.003Z', endTime: '2018-08-31T02:51:27.005Z', attributes: {attributeMap: {}}, timeEvents: {timeEvent: []}, sameProcessAsParentSpan: true, links: {link: []}, - status: {}, + status: {code: 0}, }, ]; expect(apiSpans).toEqual(expectedApiSpans); @@ -181,9 +186,7 @@ describe('Core to API Span adapters', () => { type: webTypes.MessageEventType.SENT, uncompressedSize: 22, compressedSize: 15, - // TODO(draffensperger): remove the `as coreTypes.MessageEvent` once core - // interface has new fields. - } as coreTypes.MessageEvent]; + }]; const webRootSpan = new webTypes.RootSpan(tracer); webRootSpan.spans = [webSpan1]; webRootSpan.startPerfTime = 5.001; @@ -205,7 +208,7 @@ describe('Core to API Span adapters', () => { tracestate: {}, parentSpanId: '', name: {value: 'unnamed'}, - kind: apiTypes.SpanKind.UNSPECIFIED, + kind: API_SPAN_KIND_UNSPECIFIED, startTime: '2019-01-20T16:00:00.005001000Z', endTime: '2019-01-20T16:00:00.030000001Z', attributes: {attributeMap: {}}, @@ -229,7 +232,7 @@ describe('Core to API Span adapters', () => { ], }, links: {link: []}, - status: {}, + status: {code: 0}, sameProcessAsParentSpan: true, }, { @@ -238,7 +241,7 @@ describe('Core to API Span adapters', () => { tracestate: {}, parentSpanId: '', name: {value: 'unnamed'}, - kind: apiTypes.SpanKind.UNSPECIFIED, + kind: API_SPAN_KIND_UNSPECIFIED, startTime: '2019-01-20T16:00:00.010100000Z', endTime: '2019-01-20T16:00:00.020113000Z', attributes: {attributeMap: {}}, @@ -247,14 +250,14 @@ describe('Core to API Span adapters', () => { time: '2019-01-20T16:00:00.019002000Z', messageEvent: { id: '1', - type: apiTypes.MessageEventType.SENT, + type: API_MESSAGE_EVENT_TYPE_SENT, uncompressedSize: 22, compressedSize: 15, }, }], }, links: {link: []}, - status: {}, + status: {code: 0}, sameProcessAsParentSpan: true, }, ]; diff --git a/packages/opencensus-web-exporter-ocagent/test/test-ocagent.ts b/packages/opencensus-web-exporter-ocagent/test/test-ocagent.ts index 2a539bd2..dd347a78 100644 --- a/packages/opencensus-web-exporter-ocagent/test/test-ocagent.ts +++ b/packages/opencensus-web-exporter-ocagent/test/test-ocagent.ts @@ -43,7 +43,7 @@ const SPAN1_API_JSON: apiTypes.Span = { attributes: {attributeMap: {}}, timeEvents: {timeEvent: []}, links: {link: []}, - status: {}, + status: {code: 0}, sameProcessAsParentSpan: true, }; const SPAN2_API_JSON: apiTypes.Span = { @@ -58,7 +58,7 @@ const SPAN2_API_JSON: apiTypes.Span = { attributes: {attributeMap: {}}, timeEvents: {timeEvent: []}, links: {link: []}, - status: {}, + status: {code: 0}, sameProcessAsParentSpan: true, };