1414 * limitations under the License.
1515 */
1616
17- import * as coreTypes from '@opencensus/core' ;
1817import * as webCore from '@opencensus/web-core' ;
1918import * as apiTypes from './api-types' ;
2019
@@ -26,10 +25,10 @@ import * as apiTypes from './api-types';
2625const 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
125123function 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 */
158156interface 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 {
0 commit comments