UNPKG

3.07 kBTypeScriptView Raw
1/**
2 * Copyright 2018, OpenCensus Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { TraceParams } from '../config/types';
17import { Sampler } from './types';
18/** Sampler that samples every trace. */
19export declare class AlwaysSampler implements Sampler {
20 readonly description: string;
21 shouldSample(traceId: string): boolean;
22}
23/** Sampler that samples no traces. */
24export declare class NeverSampler implements Sampler {
25 readonly description: string;
26 shouldSample(traceId: string): boolean;
27}
28/** Sampler that samples a given fraction of traces. */
29export declare class ProbabilitySampler implements Sampler {
30 private idUpperBound;
31 readonly description: string;
32 /**
33 * Constructs a new Probability Sampler instance.
34 */
35 constructor(probability: number);
36 /**
37 * Checks if trace belong the sample.
38 * @param traceId Used to check the probability
39 * @returns a boolean. True if the traceId is in probability
40 * False if the traceId is not in probability.
41 */
42 shouldSample(traceId: string): boolean;
43}
44/** Builder class of Samplers */
45export declare class SamplerBuilder {
46 private static readonly ALWAYS;
47 private static readonly NEVER;
48 /**
49 * If probability parameter is bigger then 1 return AlwaysSampler instance.
50 * If probability parameter is less than 0 returns NeverSampler instance.
51 * Else returns a Probability Sampler
52 *
53 * @param probability probability between 0 and 1
54 * @returns a Sampler object
55 */
56 static getSampler(probability: number): Sampler;
57}
58/**
59 * The default sampler is a Probability sampler with the probability set to
60 * 1/10000.
61 */
62export declare const DEFAULT_SAMPLING_RATE = 0.0001;
63/** Default Limit for Annotations per span */
64export declare const DEFAULT_SPAN_MAX_NUM_ANNOTATIONS = 32;
65/** Default limit for Message events per span */
66export declare const DEFAULT_SPAN_MAX_NUM_MESSAGE_EVENTS = 128;
67/** Default limit for Attributes per span */
68export declare const DEFAULT_SPAN_MAX_NUM_ATTRIBUTES = 32;
69/** Default limit for Links per span */
70export declare const DEFAULT_SPAN_MAX_NUM_LINKS = 32;
71/** Builder Class of TraceParams */
72export declare class TraceParamsBuilder {
73 static getNumberOfAnnotationEventsPerSpan(traceParameters: TraceParams): number;
74 static getNumberOfAttributesPerSpan(traceParameters: TraceParams): number;
75 static getNumberOfMessageEventsPerSpan(traceParameters: TraceParams): number;
76 static getNumberOfLinksPerSpan(traceParameters: TraceParams): number;
77}