@@ -23,38 +23,38 @@ const maxNumber = 0xffffffffffffffff;
2323/**
2424 * Class Sampler
2525 */
26- export class Sampler {
27- traceId : string ;
28- private idUpperBound : number ;
26+ export class Sampler {
27+ traceId : string ;
28+ private idUpperBound : number ;
2929
30- /**
31- * @param traceId Used for probability calculation
32- * @param spanId todo: integration with propagation class
33- * @param isRemote todo: integration with propagation class
34- */
35- constructor ( traceId ?:string , spanId ?:string , isRemote ?:boolean ) {
36- if ( traceId ) {
37- this . traceId = traceId ;
38- }
39- }
30+ /**
31+ * @param traceId Used for probability calculation
32+ * @param spanId todo: integration with propagation class
33+ * @param isRemote todo: integration with propagation class
34+ */
35+ constructor ( traceId ?: string , spanId ?: string , isRemote ?: boolean ) {
36+ if ( traceId ) {
37+ this . traceId = traceId ;
38+ }
39+ }
4040
4141 /**
4242 * @description Set idUpperBound with maxNumber
4343 * @returns a Sampler object
4444 */
45- public always ( ) : Sampler {
46- this . idUpperBound = maxNumber ;
47- return this ;
48- }
45+ public always ( ) : Sampler {
46+ this . idUpperBound = maxNumber ;
47+ return this ;
48+ }
4949
5050 /**
5151 * @description Set idUpperBound with minNumber
5252 * @returns a Sampler object
5353 */
54- public never ( ) : Sampler {
55- this . idUpperBound = minNumber ;
56- return this ;
57- }
54+ public never ( ) : Sampler {
55+ this . idUpperBound = minNumber ;
56+ return this ;
57+ }
5858
5959 /**
6060 * @description Set idUpperBound with the probability. If probability
@@ -63,8 +63,8 @@ export class Sampler{
6363 * @param probability probability between 0 and 1
6464 * @returns a Sampler object
6565 */
66- public probability ( probability :number ) : Sampler {
67- if ( probability < minNumber ) {
66+ public probability ( probability : number ) : Sampler {
67+ if ( probability < minNumber ) {
6868 return this . never ( ) ;
6969
7070 } else if ( probability > maxNumber ) {
@@ -74,20 +74,20 @@ export class Sampler{
7474
7575 this . idUpperBound = probability * maxNumber ;
7676 return this ;
77- }
78-
77+ }
78+
7979 /**
8080 * @description
8181 * @param traceId
8282 * @returns a boolean
8383 */
84- public shouldSample ( traceId :string ) :boolean {
84+ public shouldSample ( traceId : string ) : boolean {
8585 const lower_bytes = traceId . substring ( 16 )
8686 const lower_long = parseInt ( lower_bytes , 16 ) ;
8787
88- if ( lower_long <= this . idUpperBound ) {
88+ if ( lower_long <= this . idUpperBound ) {
8989 return true
90- } else {
90+ } else {
9191 return false ;
9292 }
9393 }
0 commit comments