Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
Refactor Flow files
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuri Shkuro committed Nov 22, 2016
1 parent 39d2ca5 commit 172cf74
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
./node_modules/

[libs]
./src/_interfaces/
./test/_interfaces/
./src/_flow/
./test/_flow/

[options]
unsafe.enable_getters_and_setters=true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 24 additions & 5 deletions src/_interfaces/gauge.js → src/_flow/jaeger-thrift.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,27 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// Gauge returns instantaneous measurements of something as an int64 value
declare interface Gauge {
// Update the gauge to the value passed in.
gauge(value: number): void;
}
declare type Tag = {
key: string,
value: any
};

declare type LogData = {
timestamp: number,
fields: Array<Tag>
};

declare type Process = {
serviceName: string,
tags: Array<Tag>
};

declare type Batch = {
process: Process,
spans: Array<any>
};

declare type Reference = {
type(): string;
referencedContext(): SpanContext;
};
File renamed without changes.
20 changes: 20 additions & 0 deletions src/_interfaces/metric_factory.js → src/_flow/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// Counter tracks the number of times an event has occurred
declare interface Counter {
// Add adds the given value to the counter.
increment(delta: number): void;
}

// Timer tracks how long an operation took and also computes percentiles.
declare interface Timer {
// Records the time passed in.
// TODO what are the units of measurement for the value?
// TODO consider replacing this with Histogram
record(value: number): void;
}

// Gauge returns instantaneous measurements of something as an int64 value
declare interface Gauge {
// Update the gauge to the value passed in.
update(value: number): void;
}

declare interface MetricFactory {
createCounter(name: string, tags: any): Counter;
createTimer(name: string, tags: any): Timer;
Expand Down
File renamed without changes.
77 changes: 16 additions & 61 deletions src/_interfaces/types.js → src/_flow/samlper-thrift.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import SpanContext from '../span_context.js';

declare type Tag = {
key: string,
value: any
};

declare type LogData = {
timestamp: number,
fields: Array<Tag>
};

declare type Process = {
serviceName: string,
tags: Array<Tag>
};

declare type Batch = {
process: Process,
spans: Array<any>
};

declare type Endpoint = {
ipv4: number,
port: number,
serviceName: string
};

declare type Annotation = {
timestamp: number,
value: string,
host: ?Endpoint
};

declare type BinaryAnnotation = {
key: string,
value: any,
annotationType: string,
host: ?Endpoint
};

declare type Reference = {
type(): string;
referencedContext(): SpanContext;
};

declare type startSpanArgs = {
operationName?: string,
childOf?: SpanContext,
references?: Array<Reference>,
tags?: any,
startTime?: number,
};

declare type ProbabilisticSamplingStrategy = {
samplingRate: number
};
Expand All @@ -81,15 +27,24 @@ declare type RateLimitingSamplingStrategy = {
maxTracesPerSecond: number
};

// OperationSamplingStrategy defines a sampling strategy for a given operation
// that randomly samples a fixed percentage of traces.
declare type OperationSamplingStrategy = {
operation: string,
probabilisticSampling: ProbabilisticSamplingStrategy
};

// PerOperationSamplingStrategies defines a collection of sampling strategies
// per operation name, and a pair of parameters for the default sampling strategy
// applicable to unknown operation names.
declare type PerOperationSamplingStrategies = {
defaultSamplingProbability: number,
defaultLowerBoundTracesPerSecond: number,
perOperationStrategies: Array<OperationSamplingStrategy>
}

declare type SamplingStrategyResponse = {
strategyType: number,
probabilisticSampling?: ProbabilisticSamplingStrategy,
rateLimitingSampling?: RateLimitingSamplingStrategy
};

declare type TChannelSpan = {
id: Array<number>,
traceid: Array<number>,
parentid: Array<number>,
flags: number
};
File renamed without changes.
11 changes: 6 additions & 5 deletions src/_interfaces/timer.js → src/_flow/tchannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// Timer tracks how long an envent has occurred.
declare interface Timer {
// Records the time passed in.
record(value: number): void;
}
declare type TChannelSpan = {
id: Array<number>,
traceid: Array<number>,
parentid: Array<number>,
flags: number
};
15 changes: 10 additions & 5 deletions src/_interfaces/counter.js → src/_flow/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// Counter tracks the number of times an event has occurred
declare interface Counter {
// Add adds the given value to the counter.
increment(delta: number): void;
}
import SpanContext from '../span_context.js';

// startSpanOptions is used to type-check Trace.startSpan() options.
declare type startSpanOptions = {
operationName?: string,
childOf?: SpanContext,
references?: Array<Reference>,
tags?: any,
startTime?: number,
};
2 changes: 1 addition & 1 deletion src/metrics/noop/gauge.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
// THE SOFTWARE.

export default class NoopGauge {
gauge(value: number): void {}
update(value: number): void {}
}
2 changes: 1 addition & 1 deletion src/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default class Tracer {
* to represent time values with sub-millisecond accuracy.
* @return {Span} - a new Span object.
**/
startSpan(operationName: string, options: ?startSpanArgs): Span {
startSpan(operationName: string, options: ?startSpanOptions): Span {
// Convert options.childOf to options.references as needed.
options = options || {};
let references = options.references || [];
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/lib/metrics/local/gauge.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class LocalGauge {
this._backend = backend;
}

gauge(value: number): void {
update(value: number): void {
this._backend.gauge(this._name, value, this._tags);
}
}

0 comments on commit 172cf74

Please sign in to comment.