diff --git a/.gitignore b/.gitignore index de76725c8..23eadc1e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ coverage/ node_modules/ npm-debug.log +dist/ .idea/ *.iml diff --git a/.istanbul.yml b/.istanbul.yml new file mode 100644 index 000000000..389032fa4 --- /dev/null +++ b/.istanbul.yml @@ -0,0 +1,7 @@ +instrumentation: + root: src + include-all-sources: true + verbose: true + excludes: ["./dist"] +reporting: + dir: "coverage" diff --git a/entrypoint.js b/entrypoint.js new file mode 100644 index 000000000..657280bea --- /dev/null +++ b/entrypoint.js @@ -0,0 +1,27 @@ +var initTracer = require('./dist/src/index.js').initTracer; +var ConstSampler = require('./dist/src/samplers/const_sampler.js').default; +var ProbabilisticSampler = require('./dist/src/samplers/probabilistic_sampler.js').default; +var RateLimitingSampler = require('./dist/src/samplers/ratelimiting_sampler.js').default; +var RemoteSampler = require('./dist/src/samplers/remote_sampler.js').default; +var CompositeReporter = require('./dist/src/reporters/composite_reporter.js').default; +var InMemoryReporter = require('./dist/src/reporters/in_memory_reporter.js').default; +var LoggingReporter = require('./dist/src/reporters/logging_reporter.js').default; +var NoopReporter = require('./dist/src/reporters/noop_reporter.js').default; +var RemoteReporter = require('./dist/src/reporters/remote_reporter.js').default; +var SpanContext = require('./dist/src/span_context.js').default; +var TestUtils = require('./dist/src/test_util.js').default + +module.exports = { + initTracer: initTracer, + ConstSampler: ConstSampler, + ProbabilisticSampler: ProbabilisticSampler, + RateLimitingSampler: RateLimitingSampler, + RemoteSampler: RemoteSampler, + CompositeReporter: CompositeReporter, + InMemoryReporter: InMemoryReporter, + LoggingReporter: LoggingReporter, + NoopReporter: NoopReporter, + RemoteReporter: RemoteReporter, + TestUtils: TestUtils, + SpanContext: SpanContext +}; diff --git a/package.json b/package.json index 092a6a0ac..784bdb3e3 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "licence": "MIT", "keywords": [], "author": "oibe ", - "main": "./dist/src/index.js", + "main": "./entrypoint.js", "repository": { "type": "git", "url": "git://github.com/uber/jaeger-client-node.git" @@ -48,7 +48,7 @@ "lodash": "^4.15.0", "minimist": "1.2.0", "mocha": "^3.0.1", - "opentracing": "git://github.com/opentracing/opentracing-javascript.git#575e8149aadba97d27e9cadff3b8e47a15c2db09", + "opentracing": "^0.13.0", "rsvp": "^3.3.1", "sinon": "^1.17.5", "uber-licence": "^2.0.2", @@ -64,7 +64,7 @@ "flow": "flow; test $? -eq 0 -o $? -eq 2", "lint": "eslint $(ls src/ | grep '.js$') && echo '# linter passed'", "lint-ci": "npm run lint && echo '# TODO: ADD npm run check-license'", - "test": "npm run flow & npm run lint && ./node_modules/mocha/bin/mocha --compilers js:babel-core/register", + "test": "make build-node; npm run flow & npm run lint && ./node_modules/mocha/bin/mocha --compilers js:babel-core/register", "test-ci": "npm run test && npm run lint-ci && npm run cover", "show-cover": "open coverage/lcov-report/index.html" } diff --git a/src/configuration.js b/src/configuration.js index 89984745b..a4fbb0713 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -139,14 +139,14 @@ export default class Configuration { if (config.disable) { return new opentracing.Tracer(); } else { + if (config.sampler) { + sampler = Configuration._getSampler(config); + } else { + sampler = new RemoteSampler(config.serviceName); + } + if (!options.reporter) { reporter = Configuration._getReporter(config, options); - - if (config.sampler) { - sampler = Configuration._getSampler(config); - } else { - sampler = new RemoteSampler(config.serviceName); - } } else { reporter = options.reporter; } diff --git a/test/entrypoint.js b/test/entrypoint.js new file mode 100644 index 000000000..c37781629 --- /dev/null +++ b/test/entrypoint.js @@ -0,0 +1,39 @@ +// Copyright (c) 2016 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import {expect} from 'chai'; +import entrypoint from '../entrypoint'; + +describe('entrypoint', () => { + it ('should import and create objects without error', () => { + expect(entrypoint.initTracer).to.be.a('function'); + expect(entrypoint.ConstSampler).to.be.a('function'); + expect(entrypoint.ProbabilisticSampler).to.be.a('function'); + expect(entrypoint.RateLimitingSampler).to.be.a('function'); + expect(entrypoint.RemoteSampler).to.be.a('function'); + expect(entrypoint.CompositeReporter).to.be.a('function'); + expect(entrypoint.InMemoryReporter).to.be.a('function'); + expect(entrypoint.LoggingReporter).to.be.a('function'); + expect(entrypoint.NoopReporter).to.be.a('function'); + expect(entrypoint.RemoteReporter).to.be.a('function'); + expect(entrypoint.TestUtils).to.be.a('function'); + expect(entrypoint.SpanContext).to.be.a('function'); + }); +});