Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan committed Apr 8, 2020
1 parent 00345c2 commit e0219c1
Show file tree
Hide file tree
Showing 28 changed files with 125 additions and 75 deletions.
11 changes: 7 additions & 4 deletions packages/opentelemetry-api/src/api/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import {

const NOOP_CONTEXT_MANAGER = new NoopContextManager();

const GLOBAL_CONTEXT_MANAGER_API_KEY = Symbol.for("io.opentelemetry.js.api.context");
const GLOBAL_CONTEXT_MANAGER_API_KEY = Symbol.for(
'io.opentelemetry.js.api.context'
);
const API_VERSION = 0;

/**
Expand Down Expand Up @@ -54,18 +56,19 @@ export class ContextAPI {
return NOOP_CONTEXT_MANAGER;
}

(global as any)[GLOBAL_CONTEXT_MANAGER_API_KEY] = function getTraceApi (version: number) {
(global as any)[GLOBAL_CONTEXT_MANAGER_API_KEY] = function getTraceApi(
version: number
) {
if (version !== API_VERSION) {
return NOOP_CONTEXT_MANAGER;
}

return contextManager;
}
};

return contextManager;
}


/**
* Get the currently active context
*/
Expand Down
8 changes: 5 additions & 3 deletions packages/opentelemetry-api/src/api/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Meter } from '../metrics/Meter';
import { MeterProvider } from '../metrics/MeterProvider';
import { NOOP_METER_PROVIDER } from '../metrics/NoopMeterProvider';

const GLOBAL_METRICS_API_KEY = Symbol.for("io.opentelemetry.js.api.metrics");
const GLOBAL_METRICS_API_KEY = Symbol.for('io.opentelemetry.js.api.metrics');
const API_VERSION = 0;

/**
Expand Down Expand Up @@ -48,13 +48,15 @@ export class MetricsAPI {
return NOOP_METER_PROVIDER;
}

(global as any)[GLOBAL_METRICS_API_KEY] = function getTraceApi (version: number) {
(global as any)[GLOBAL_METRICS_API_KEY] = function getTraceApi(
version: number
) {
if (version !== API_VERSION) {
return NOOP_METER_PROVIDER;
}

return provider;
}
};

return provider;
}
Expand Down
10 changes: 7 additions & 3 deletions packages/opentelemetry-api/src/api/propagation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import { ContextAPI } from './context';

const contextApi = ContextAPI.getInstance();

const GLOBAL_PROPAGATION_API_KEY = Symbol.for("io.opentelemetry.js.api.propagation");
const GLOBAL_PROPAGATION_API_KEY = Symbol.for(
'io.opentelemetry.js.api.propagation'
);
const API_VERSION = 0;

/**
Expand Down Expand Up @@ -55,13 +57,15 @@ export class PropagationAPI {
return NOOP_HTTP_TEXT_PROPAGATOR;
}

(global as any)[GLOBAL_PROPAGATION_API_KEY] = function getTraceApi (version: number) {
(global as any)[GLOBAL_PROPAGATION_API_KEY] = function getTraceApi(
version: number
) {
if (version !== API_VERSION) {
return NOOP_HTTP_TEXT_PROPAGATOR;
}

return propagator;
}
};

return propagator;
}
Expand Down
8 changes: 5 additions & 3 deletions packages/opentelemetry-api/src/api/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { NOOP_TRACER_PROVIDER } from '../trace/NoopTracerProvider';
import { TracerProvider } from '../trace/tracer_provider';
import { Tracer } from '../trace/tracer';

const GLOBAL_TRACE_API_KEY = Symbol.for("io.opentelemetry.js.api.trace");
const GLOBAL_TRACE_API_KEY = Symbol.for('io.opentelemetry.js.api.trace');
const API_VERSION = 0;

/**
Expand Down Expand Up @@ -48,13 +48,15 @@ export class TraceAPI {
return NOOP_TRACER_PROVIDER;
}

(global as any)[GLOBAL_TRACE_API_KEY] = function getTraceApi (version: number) {
(global as any)[GLOBAL_TRACE_API_KEY] = function getTraceApi(
version: number
) {
if (version !== API_VERSION) {
return NOOP_TRACER_PROVIDER;
}

return provider;
}
};

return this.getTracerProvider();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-api/test/api/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ describe('API', () => {
const dummySpan = new NoopSpan(spanContext);

beforeEach(() => {
context.disable()
context.disable();
trace.disable();
propagation.disable();
metrics.disable();
})
});

it('should not crash', () => {
functions.forEach(fn => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('NodeTracerProvider', () => {
Object.keys(require.cache).forEach(key => delete require.cache[key]);
provider.stop();
contextManager.disable();
context.disable()
context.disable();
});

describe('constructor', () => {
Expand Down
29 changes: 22 additions & 7 deletions packages/opentelemetry-node/test/registration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/

import { context, NoopHttpTextPropagator, propagation, trace } from '@opentelemetry/api';
import {
context,
NoopHttpTextPropagator,
propagation,
trace,
} from '@opentelemetry/api';
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
import { NoopContextManager } from '@opentelemetry/context-base';
import { HttpTraceContext } from '@opentelemetry/core';
Expand All @@ -23,7 +28,7 @@ import { NodeTracerProvider } from '../src';

describe('API registration', () => {
beforeEach(() => {
context.disable()
context.disable();
trace.disable();
propagation.disable();
});
Expand All @@ -32,8 +37,12 @@ describe('API registration', () => {
const tracerProvider = new NodeTracerProvider();
tracerProvider.register();

assert.ok(context['_getContextManager']() instanceof AsyncHooksContextManager);
assert.ok(propagation['_getGlobalPropagator']() instanceof HttpTraceContext);
assert.ok(
context['_getContextManager']() instanceof AsyncHooksContextManager
);
assert.ok(
propagation['_getGlobalPropagator']() instanceof HttpTraceContext
);
assert.ok(trace.getTracerProvider() === tracerProvider);
});

Expand Down Expand Up @@ -62,7 +71,9 @@ describe('API registration', () => {

assert.ok(context['_getContextManager']() instanceof NoopContextManager);

assert.ok(propagation['_getGlobalPropagator']() instanceof HttpTraceContext);
assert.ok(
propagation['_getGlobalPropagator']() instanceof HttpTraceContext
);
assert.ok(trace.getTracerProvider() === tracerProvider);
});

Expand All @@ -72,9 +83,13 @@ describe('API registration', () => {
propagator: null,
});

assert.ok(propagation['_getGlobalPropagator']() instanceof NoopHttpTextPropagator);
assert.ok(
propagation['_getGlobalPropagator']() instanceof NoopHttpTextPropagator
);

assert.ok(context['_getContextManager']() instanceof AsyncHooksContextManager);
assert.ok(
context['_getContextManager']() instanceof AsyncHooksContextManager
);
assert.ok(trace.getTracerProvider() === tracerProvider);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ describe('DocumentLoad Plugin', () => {
});

afterEach(() => {
context.disable()
context.disable();
Object.defineProperty(window.document, 'readyState', {
writable: true,
value: 'complete',
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-express/test/express.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('Express Plugin', () => {

afterEach(() => {
memoryExporter.reset();
context.disable()
context.disable();
});

describe('Instrumenting normal get operations', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-grpc/test/grpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ describe('GrpcPlugin', () => {
});

afterEach(() => {
context.disable()
context.disable();
});

it('should return a plugin', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('HttpPlugin', () => {
});

afterEach(() => {
context.disable()
context.disable();
});

it('should return a plugin', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import { context, SpanKind } from '@opentelemetry/api';
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
import { NoopLogger } from '@opentelemetry/core';
import { NodeTracerProvider } from '@opentelemetry/node';
import { InMemorySpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
import {
InMemorySpanExporter,
SimpleSpanProcessor,
} from '@opentelemetry/tracing';
import * as assert from 'assert';
import axios, { AxiosResponse } from 'axios';
import * as got from 'got';
Expand All @@ -43,7 +46,7 @@ describe('Packages', () => {
});

afterEach(() => {
context.disable()
context.disable();
});
describe('get', () => {
const logger = new NoopLogger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ describe('HttpPlugin Integration tests', () => {
});

afterEach(() => {
context.disable()
})
context.disable();
});
describe('enable()', () => {
before(function(done) {
// mandatory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('HttpsPlugin', () => {

afterEach(() => {
contextManager.disable();
context.disable()
context.disable();
});

it('should return a plugin', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
import { NoopLogger } from '@opentelemetry/core';
import { NodeTracerProvider } from '@opentelemetry/node';
import { Http } from '@opentelemetry/plugin-http';
import { InMemorySpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
import {
InMemorySpanExporter,
SimpleSpanProcessor,
} from '@opentelemetry/tracing';
import * as assert from 'assert';
import axios, { AxiosResponse } from 'axios';
import * as got from 'got';
Expand Down Expand Up @@ -47,8 +50,8 @@ describe('Packages', () => {
});

afterEach(() => {
context.disable()
})
context.disable();
});
describe('get', () => {
const logger = new NoopLogger();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ describe('HttpsPlugin Integration tests', () => {
});

afterEach(() => {
context.disable()
})
context.disable();
});

describe('enable()', () => {
before(function(done) {
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-ioredis/test/ioredis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('ioredis', () => {

afterEach(() => {
contextManager.disable();
context.disable()
context.disable();
});

before(function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-mongodb/test/mongodb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('MongoDBPlugin', () => {
afterEach(done => {
collection.deleteOne({}, done);
contextManager.disable();
context.disable()
context.disable();
});

after(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-mysql/test/mysql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('[email protected]', () => {

afterEach(done => {
contextManager.disable();
context.disable()
context.disable();
memoryExporter.reset();
plugin.disable();
connection.end(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('[email protected]', () => {
plugin.disable();
pgPlugin.disable();
contextManager.disable();
context.disable()
context.disable();
});

it('should return a plugin', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('[email protected]', () => {
memoryExporter.reset();
plugin.disable();
contextManager.disable();
context.disable()
context.disable();
});

it('should return a plugin', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-redis/test/redis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('[email protected]', () => {

afterEach(() => {
contextManager.disable();
context.disable()
context.disable();
});

before(function() {
Expand Down
Loading

0 comments on commit e0219c1

Please sign in to comment.