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

Commit 03e637a

Browse files
Remove @opencensus/core dep for ocagent exporter (#23)
1 parent cdb3151 commit 03e637a

13 files changed

Lines changed: 685 additions & 913 deletions

File tree

packages/opencensus-web-all/package-lock.json

Lines changed: 592 additions & 535 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencensus-web-core/package-lock.json

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencensus-web-core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export * from './trace/model/enums';
2323
export * from './trace/model/attribute-keys';
2424

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

2828
export * from './common/time-util';
2929
export * from './common/url-util';

packages/opencensus-web-exporter-ocagent/package-lock.json

Lines changed: 1 addition & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencensus-web-exporter-ocagent/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@
4343
"access": "public"
4444
},
4545
"devDependencies": {
46-
"@opencensus/core": "^0.0.9",
4746
"@types/jasmine": "^3.3.4",
48-
"@types/node": "^10.12.18",
4947
"gts": "^0.9.0",
5048
"istanbul-instrumenter-loader": "^3.0.1",
5149
"jasmine": "^3.3.1",

packages/opencensus-web-exporter-ocagent/src/adapters.ts

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

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

@@ -26,10 +25,10 @@ import * as apiTypes from './api-types';
2625
const RECENT_EPOCH_MS = 1500000000000; // July 13, 2017.
2726

2827
/**
29-
* Converts a RootSpan type from @opencensus/core to the Span JSON structure
28+
* Converts a RootSpan type from @opencensus/web-core to the Span JSON structure
3029
* expected by the OpenCensus Agent's HTTP/JSON (grpc-gateway) API.
3130
*/
32-
export function adaptRootSpan(rootSpan: coreTypes.RootSpan): apiTypes.Span[] {
31+
export function adaptRootSpan(rootSpan: webCore.RootSpan): apiTypes.Span[] {
3332
const adaptedSpans: apiTypes.Span[] = rootSpan.spans.map(adaptSpan);
3433
adaptedSpans.unshift(adaptSpan(rootSpan));
3534
return adaptedSpans;
@@ -52,7 +51,7 @@ function hexToBase64(hexStr: string): string {
5251
return btoa(hexAsciiCharsStr);
5352
}
5453

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

78-
function adaptAttributes(attributes: coreTypes.Attributes):
79-
apiTypes.Attributes {
77+
function adaptAttributes(attributes: webCore.Attributes): apiTypes.Attributes {
8078
const attributeMap: apiTypes.AttributeMap = {};
8179
for (const key of Object.keys(attributes)) {
8280
attributeMap[key] = adaptValue(attributes[key]);
8381
}
8482
return {attributeMap};
8583
}
8684

87-
function adaptAnnotation(annotation: coreTypes.Annotation): apiTypes.TimeEvent {
85+
function adaptAnnotation(annotation: webCore.Annotation): apiTypes.TimeEvent {
8886
return {
8987
time: adaptTimestampNumber(annotation.timestamp),
9088
annotation: {
@@ -108,7 +106,7 @@ function adaptTimestampNumber(timestamp: number): string {
108106
return webCore.getIsoDateStrForPerfTime(timestamp);
109107
}
110108

111-
function adaptMessageEvent(messageEvent: coreTypes.MessageEvent):
109+
function adaptMessageEvent(messageEvent: webCore.MessageEvent):
112110
apiTypes.TimeEvent {
113111
return {
114112
time: adaptTimestampNumber(messageEvent.timestamp),
@@ -123,15 +121,15 @@ function adaptMessageEvent(messageEvent: coreTypes.MessageEvent):
123121
}
124122

125123
function adaptTimeEvents(
126-
annotations: coreTypes.Annotation[],
127-
messageEvents: coreTypes.MessageEvent[]): apiTypes.TimeEvents {
124+
annotations: webCore.Annotation[],
125+
messageEvents: webCore.MessageEvent[]): apiTypes.TimeEvents {
128126
return {
129127
timeEvent: annotations.map(adaptAnnotation)
130128
.concat(messageEvents.map(adaptMessageEvent)),
131129
};
132130
}
133131

134-
function adaptLink(link: coreTypes.Link): apiTypes.Link {
132+
function adaptLink(link: webCore.Link): apiTypes.Link {
135133
return {
136134
traceId: hexToBase64(link.traceId),
137135
spanId: hexToBase64(link.spanId),
@@ -140,7 +138,7 @@ function adaptLink(link: coreTypes.Link): apiTypes.Link {
140138
};
141139
}
142140

143-
function adaptLinks(links: coreTypes.Link[]): apiTypes.Links {
141+
function adaptLinks(links: webCore.Link[]): apiTypes.Links {
144142
return {link: links.map(adaptLink)};
145143
}
146144

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

157-
/** Interface to represent that a coreTypes.Span may be a webCore.Span */
155+
/** Interface to represent that a webCore.Span may be a webCore.Span */
158156
interface MaybeWebSpan {
159157
startPerfTime?: number;
160158
endPerfTime?: number;
161159
startTime: Date;
162160
endTime: Date;
163161
}
164162

165-
function adaptSpan(span: coreTypes.Span): apiTypes.Span {
163+
function adaptSpan(span: webCore.Span): apiTypes.Span {
166164
// The stackTrace and childSpanCount attributes are not currently supported by
167165
// opencensus-web.
168166
return {

packages/opencensus-web-exporter-ocagent/src/exporter-buffer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

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

1919
/**
2020
* Controls the sending of traces to exporters.

packages/opencensus-web-exporter-ocagent/src/ocagent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

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

1919
import {adaptRootSpan} from './adapters';
2020
import * as apiTypes from './api-types';

0 commit comments

Comments
 (0)