File tree 3 files changed +8
-7
lines changed
3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class Tracer {
13
13
if ( result . done || result . value == null ) {
14
14
throw new Error ( 'Unexpected end of id generator' ) ;
15
15
}
16
- return result . value . toMultibase ( 'base32hex' ) ;
16
+ return result . value . toMultibase ( 'base32hex' ) as SpanId ;
17
17
}
18
18
19
19
protected queueSpanEvent ( evt : SpanEvent ) {
@@ -46,7 +46,7 @@ class Tracer {
46
46
47
47
public async traced < T > (
48
48
name : string ,
49
- parentSpanId : string | undefined ,
49
+ parentSpanId : SpanId | undefined ,
50
50
fn : ( ) => T | Promise < T > ,
51
51
) : Promise < T > {
52
52
const fnProm = async ( ) => {
Original file line number Diff line number Diff line change 1
- type SpanId = string ;
1
+ type SpanId = string & { readonly brand : unique symbol } ;
2
2
3
3
/**
4
4
* A span is a virtual concept, not an actual object. A span is made up of
Original file line number Diff line number Diff line change
1
+ import type { SpanId } from '#tracer/index.js' ;
1
2
import fs from 'fs' ;
2
3
import * as fc from 'fast-check' ;
3
4
import tracer from '#tracer/index.js' ;
4
5
5
6
let parentIndex = 0 ;
6
7
let step = 0 ;
7
- let nestedIds : Array < string > = [ ] ;
8
+ let nestedIds : Array < SpanId > = [ ] ;
8
9
9
10
type Flags = {
10
11
hasForkA : boolean ;
@@ -18,9 +19,9 @@ type Flags = {
18
19
} ;
19
20
20
21
const current : {
21
- parentId ?: string ;
22
- forkAId ?: string ;
23
- forkBId ?: string ;
22
+ parentId ?: SpanId ;
23
+ forkAId ?: SpanId ;
24
+ forkBId ?: SpanId ;
24
25
flags : Flags ;
25
26
} = {
26
27
flags : {
You can’t perform that action at this time.
0 commit comments