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

Remove @opencensus/core dep for ocagent exporter #23

Merged
merged 2 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,127 changes: 592 additions & 535 deletions packages/opencensus-web-all/package-lock.json

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions packages/opencensus-web-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/opencensus-web-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export * from './trace/model/enums';
export * from './trace/model/attribute-keys';

// Re-export types this uses from @opencensus/core.
export {Annotation, Attributes, Config, Exporter, Link, MessageEvent, Propagation, SpanContext, SpanEventListener, TracerConfig, TraceState} from '@opencensus/core';
export {Annotation, Attributes, BufferConfig, Config, Exporter, ExporterConfig, Link, Logger, MessageEvent, Propagation, SpanContext, SpanEventListener, Status, TracerConfig, TraceState} from '@opencensus/core';

export * from './common/time-util';
export * from './common/url-util';
Expand Down
64 changes: 1 addition & 63 deletions packages/opencensus-web-exporter-ocagent/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions packages/opencensus-web-exporter-ocagent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
"access": "public"
},
"devDependencies": {
"@opencensus/core": "^0.0.9",
"@types/jasmine": "^3.3.4",
"@types/node": "^10.12.18",
"gts": "^0.9.0",
"istanbul-instrumenter-loader": "^3.0.1",
"jasmine": "^3.3.1",
Expand Down
24 changes: 11 additions & 13 deletions packages/opencensus-web-exporter-ocagent/src/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import * as coreTypes from '@opencensus/core';
import * as webCore from '@opencensus/web-core';
import * as apiTypes from './api-types';

Expand All @@ -29,7 +28,7 @@ const RECENT_EPOCH_MS = 1500000000000; // July 13, 2017.
* Converts a RootSpan type from @opencensus/core to the Span JSON structure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change this comment from @opencensus/core -> @opencensus/web-core?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done.

* expected by the OpenCensus Agent's HTTP/JSON (grpc-gateway) API.
*/
export function adaptRootSpan(rootSpan: coreTypes.RootSpan): apiTypes.Span[] {
export function adaptRootSpan(rootSpan: webCore.RootSpan): apiTypes.Span[] {
const adaptedSpans: apiTypes.Span[] = rootSpan.spans.map(adaptSpan);
adaptedSpans.unshift(adaptSpan(rootSpan));
return adaptedSpans;
Expand All @@ -52,7 +51,7 @@ function hexToBase64(hexStr: string): string {
return btoa(hexAsciiCharsStr);
}

function adaptTraceState(coreTraceState?: coreTypes.TraceState):
function adaptTraceState(coreTraceState?: webCore.TraceState):
apiTypes.TraceState {
if (!coreTraceState || !coreTraceState.length) return {};
const entries = coreTraceState.split(',');
Expand All @@ -75,16 +74,15 @@ function adaptValue(value: boolean|string|number): apiTypes.AttributeValue {
return {stringValue: adaptString(String(value))};
}

function adaptAttributes(attributes: coreTypes.Attributes):
apiTypes.Attributes {
function adaptAttributes(attributes: webCore.Attributes): apiTypes.Attributes {
const attributeMap: apiTypes.AttributeMap = {};
for (const key of Object.keys(attributes)) {
attributeMap[key] = adaptValue(attributes[key]);
}
return {attributeMap};
}

function adaptAnnotation(annotation: coreTypes.Annotation): apiTypes.TimeEvent {
function adaptAnnotation(annotation: webCore.Annotation): apiTypes.TimeEvent {
return {
time: adaptTimestampNumber(annotation.timestamp),
annotation: {
Expand All @@ -108,7 +106,7 @@ function adaptTimestampNumber(timestamp: number): string {
return webCore.getIsoDateStrForPerfTime(timestamp);
}

function adaptMessageEvent(messageEvent: coreTypes.MessageEvent):
function adaptMessageEvent(messageEvent: webCore.MessageEvent):
apiTypes.TimeEvent {
return {
time: adaptTimestampNumber(messageEvent.timestamp),
Expand All @@ -123,15 +121,15 @@ function adaptMessageEvent(messageEvent: coreTypes.MessageEvent):
}

function adaptTimeEvents(
annotations: coreTypes.Annotation[],
messageEvents: coreTypes.MessageEvent[]): apiTypes.TimeEvents {
annotations: webCore.Annotation[],
messageEvents: webCore.MessageEvent[]): apiTypes.TimeEvents {
return {
timeEvent: annotations.map(adaptAnnotation)
.concat(messageEvents.map(adaptMessageEvent)),
};
}

function adaptLink(link: coreTypes.Link): apiTypes.Link {
function adaptLink(link: webCore.Link): apiTypes.Link {
return {
traceId: hexToBase64(link.traceId),
spanId: hexToBase64(link.spanId),
Expand All @@ -140,7 +138,7 @@ function adaptLink(link: coreTypes.Link): apiTypes.Link {
};
}

function adaptLinks(links: coreTypes.Link[]): apiTypes.Links {
function adaptLinks(links: webCore.Link[]): apiTypes.Links {
return {link: links.map(adaptLink)};
}

Expand All @@ -154,15 +152,15 @@ function adaptSpanTime(perfTime: number|undefined, fallbackTime: Date) {
webCore.getIsoDateStrForPerfTime(perfTime);
}

/** Interface to represent that a coreTypes.Span may be a webCore.Span */
/** Interface to represent that a webCore.Span may be a webCore.Span */
interface MaybeWebSpan {
startPerfTime?: number;
endPerfTime?: number;
startTime: Date;
endTime: Date;
}

function adaptSpan(span: coreTypes.Span): apiTypes.Span {
function adaptSpan(span: webCore.Span): apiTypes.Span {
// The stackTrace and childSpanCount attributes are not currently supported by
// opencensus-web.
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {BufferConfig, Exporter, RootSpan} from '@opencensus/core';
import {BufferConfig, Exporter, RootSpan} from '@opencensus/web-core';

/**
* Controls the sending of traces to exporters.
Expand Down
2 changes: 1 addition & 1 deletion packages/opencensus-web-exporter-ocagent/src/ocagent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import {Exporter, ExporterConfig, RootSpan} from '@opencensus/core';
import {Exporter, ExporterConfig, RootSpan} from '@opencensus/web-core';

import {adaptRootSpan} from './adapters';
import * as apiTypes from './api-types';
Expand Down
Loading