mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Adds type definitions for 'jaeger-client' (#35796)
Adds type definitions and tests Adds package configuration for external types Adds tsconfig and tslint config Adds target Typescript version header to support 'opentracing' external types
This commit is contained in:
parent
cec8eb31ac
commit
a39cadfd2a
90
types/jaeger-client/index.d.ts
vendored
Normal file
90
types/jaeger-client/index.d.ts
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
// Type definitions for jaeger-client 3.15
|
||||
// Project: https://github.com/jaegertracing/jaeger-client-node#readme
|
||||
// Definitions by: jgeth <https://github.com/jgeth>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
// opentracing requires typescript version ^2.1
|
||||
import * as opentracing from "opentracing";
|
||||
import * as prometheus from "prom-client";
|
||||
|
||||
// Counter tracks the number of times an event has occurred
|
||||
export interface Counter {
|
||||
// Adds the given value to the counter.
|
||||
increment(delta: number): void;
|
||||
}
|
||||
|
||||
// Gauge returns instantaneous measurements of something as an int64 value
|
||||
export interface Gauge {
|
||||
// Update the gauge to the value passed in.
|
||||
update(value: number): void;
|
||||
}
|
||||
|
||||
export interface Logger {
|
||||
info(msg: string): void;
|
||||
error(msg: string): void;
|
||||
}
|
||||
|
||||
export interface MetricsFactory {
|
||||
createCounter(name: string, tags: any): Counter;
|
||||
createTimer(name: string, tags: any): Timer;
|
||||
createGauge(name: string, tags: any): Gauge;
|
||||
}
|
||||
|
||||
export interface Reporter {
|
||||
// TODO: use span type opentracing.Span from package 'opentracing' which fails DTS linting on import 2019-05-28 jgeth
|
||||
report(span: opentracing.Span): void;
|
||||
close(callback?: () => void): void;
|
||||
setProcess(serviceName: string, tags: any): void;
|
||||
}
|
||||
|
||||
export interface ReporterConfig {
|
||||
logSpans?: boolean;
|
||||
agentHost?: string;
|
||||
agentPort?: number;
|
||||
flushIntervalMs?: number;
|
||||
}
|
||||
|
||||
export interface SamplerConfig {
|
||||
type: string;
|
||||
param: number;
|
||||
host?: string;
|
||||
port?: number;
|
||||
refreshIntervalMs?: number;
|
||||
}
|
||||
|
||||
// Timer tracks how long an operation took and also computes percentiles.
|
||||
export interface Timer {
|
||||
// Records the time passed in.
|
||||
record(value: number): void;
|
||||
}
|
||||
|
||||
export interface TracingConfig {
|
||||
serviceName?: string;
|
||||
disable?: boolean;
|
||||
sampler?: SamplerConfig;
|
||||
reporter?: ReporterConfig;
|
||||
}
|
||||
|
||||
export interface TracingOptions {
|
||||
reporter?: Reporter;
|
||||
metrics?: PrometheusMetricsFactory;
|
||||
logger?: Logger;
|
||||
tags?: any;
|
||||
}
|
||||
|
||||
export function initTracer(
|
||||
tracingConfig: TracingConfig,
|
||||
tracingOptions: TracingOptions
|
||||
): opentracing.Tracer;
|
||||
|
||||
export function initTracerFromEnv(
|
||||
tracingConfig: TracingConfig,
|
||||
tracingOptions: TracingOptions
|
||||
): opentracing.Tracer;
|
||||
|
||||
export class PrometheusMetricsFactory {
|
||||
constructor(client: typeof prometheus, serviceName: string);
|
||||
createCounter(name: string, tags: {}): Counter;
|
||||
createGauge(name: string, tags: {}): Gauge;
|
||||
}
|
||||
10
types/jaeger-client/jaeger-client-tests.ts
Normal file
10
types/jaeger-client/jaeger-client-tests.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import * as jaegerClient from "jaeger-client";
|
||||
import * as promClient from "prom-client";
|
||||
|
||||
const tracingConfig: jaegerClient.TracingConfig = {};
|
||||
const tracingOptions: jaegerClient.TracingOptions = {};
|
||||
|
||||
jaegerClient.initTracer(tracingConfig, tracingOptions);
|
||||
jaegerClient.initTracerFromEnv(tracingConfig, tracingOptions);
|
||||
|
||||
const metrics = new jaegerClient.PrometheusMetricsFactory(promClient, "foo");
|
||||
7
types/jaeger-client/package.json
Normal file
7
types/jaeger-client/package.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"opentracing": "~0.14.3",
|
||||
"prom-client": "~11.3.0"
|
||||
}
|
||||
}
|
||||
16
types/jaeger-client/tsconfig.json
Normal file
16
types/jaeger-client/tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "jaeger-client-tests.ts"]
|
||||
}
|
||||
1
types/jaeger-client/tslint.json
Normal file
1
types/jaeger-client/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user