Permalink
Browse files

Merge, with manual merge fixes

  • Loading branch information...
2 parents 6edcb1f + b9db946 commit 0fd517dca1c29821cad9bced09125f79b1f1a625 bcronin committed Aug 22, 2016
Showing with 78 additions and 65 deletions.
  1. +0 −1 .eslintrc
  2. +1 −0 .gitignore
  3. +1 −0 .travis.yml
  4. +8 −0 README.md
  5. +10 −1 package.json
  6. +52 −0 src/span.js
  7. +0 −53 src/span_context.js
  8. +4 −4 test/imp/noop_imp.js
  9. +2 −6 test/unittest.js
View
@@ -6,7 +6,6 @@
"node": true
},
"globals": {
- "API_CONFORMANCE_CHECKS" : true,
},
"rules": {
"consistent-return": [0],
View
@@ -1,3 +1,4 @@
node_modules/
npm-debug.log
dist/*
+coverage/*
View
@@ -1,3 +1,4 @@
language: node_js
node_js:
- 0.12
+after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
View
@@ -2,6 +2,8 @@
This library is a JavaScript implementation of Open Tracing API. It is intended for use both on the server and in the browser.
+[![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov]
+
## Required Reading
To fully understand this platform API, it's helpful to be familiar with the [OpenTracing project](http://opentracing.io) and
@@ -94,3 +96,9 @@ The API layer uses a [bridge pattern](https://en.wikipedia.org/wiki/Bridge_patte
The "implementation API" - i.e. the interface the API layer expects to be able to call on the implementation - is a proper subset of the API layer itself. The surface area of the implementation API has been reduced in the case where the an API layer method (usually a convenience method of some form) can be expressed in terms of another more general method. For example, `logEvent` can be expressed as a `log` call, therefore the implementation only needs to implement `log`.
For truly implementation-dependent methods, the JavaScript API layer *does* expose `imp()` methods on each major type to allow the implementations to be accessed directly. Use of implementation-dependent methods is discouraged as it immediately makes instrumented code no longer portable. However, the `imp()` call does at least call attention to deviations from the standard API without making implementation-dependent calls impossible.
+
+
+ [ci-img]: https://travis-ci.org/opentracing/opentracing-javascript.svg?branch=master
+ [cov-img]: https://coveralls.io/repos/github/opentracing/opentracing-javascript/badge.svg?branch=master
+ [ci]: https://travis-ci.org/opentracing/opentracing-javascript
+ [cov]: https://coveralls.io/github/opentracing/opentracing-javascript?branch=master
View
@@ -1,10 +1,17 @@
{
"name": "opentracing",
"version": "0.12.0",
+ "licenses": [{
+ "type": "MIT",
+ "url": "https://opensource.org/licenses/MIT"
+ }],
"main": "lib/index.js",
"scripts": {
"prepublish": "npm run webpack",
- "test": "NODE_ENV=debug node node_modules/mocha/bin/mocha -c test/unittest.js --check-leaks",
+ "test": "npm run test-cover",
+ "cover": "npm run test-cover && istanbul check-coverage",
+ "test-cover": "istanbul cover --report lcovonly --print none ./node_modules/.bin/_mocha test/unittest.js -- --check-leaks --color && istanbul report text",
+ "cover-html": "istanbul cover --report html --print none ./node_modules/.bin/_mocha test/unittest.js -- --check-leaks --color && istanbul report text",
"webpack": "npm run webpack-browser-debug && npm run webpack-browser-prod",
"webpack-browser-debug": "BUILD_CONFIG=debug webpack --display-error-details",
"webpack-browser-prod": "BUILD_CONFIG=production webpack --display-error-details"
@@ -41,11 +48,13 @@
"chai": "^3.4.1",
"clone": "^1.0.2",
"colors": "^1.1.2",
+ "coveralls": "^2.11.12",
"eslint": "2.13.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.10.2",
"eslint-plugin-jsx-a11y": "^1.5.5",
"eslint-plugin-react": "^5.2.2",
+ "istanbul": "^0.4.5",
"json-loader": "^0.5.4",
"mocha": "^2.4.5",
"shelljs": "^0.5.3",
View
@@ -195,6 +195,58 @@ export default class Span {
this._imp.finish(finishTime);
}
+ /**
+ * Sets a key:value pair on this Span that also propagates to future
+ * children of the associated Span.
+ *
+ * setBaggageItem() enables powerful functionality given a full-stack
+ * opentracing integration (e.g., arbitrary application data from a web
+ * client can make it, transparently, all the way into the depths of a
+ * storage system), and with it some powerful costs: use this feature with
+ * care.
+ *
+ * IMPORTANT NOTE #1: setBaggageItem() will only propagate baggage items to
+ * *future* causal descendants of the associated Span.
+ *
+ * IMPORTANT NOTE #2: Use this thoughtfully and with care. Every key and
+ * value is copied into every local *and remote* child of the associated
+ * Span, and that can add up to a lot of network and cpu overhead.
+ *
+ * @param {string} key
+ * @param {string} value
+ */
+ setBaggageItem(key, value) {
+ if (process.env.NODE_ENV === 'debug') {
+ if (arguments.length !== 2) {
+ throw new Error('Invalid number of arguments');
+ }
+ }
+ if (this._imp) {
+ this._imp.setBaggageItem(key, value);
+ }
+ }
+
+ /**
+ * Returns the value for a baggage item given its key.
+ *
+ * @param {string} key
+ * The key for the given trace attribute.
+ * @return {string}
+ * String value for the given key, or undefined if the key does not
+ * correspond to a set trace attribute.
+ */
+ getBaggageItem(key) {
+ if (process.env.NODE_ENV === 'debug') {
+ if (arguments.length !== 1) {
+ throw new Error('Invalid number of arguments');
+ }
+ }
+ if (this._imp) {
+ return this._imp.getBaggageItem(key);
+ }
+ return undefined;
+ }
+
// ---------------------------------------------------------------------- //
// Private and non-standard methods
// ---------------------------------------------------------------------- //
View
@@ -11,59 +11,6 @@
* <trace_id, span_id, sampled> tuple).
*/
export default class SpanContext {
-
- /**
- * Sets a key:value pair on this SpanContext that also propagates to future
- * children of the associated Span.
- *
- * setBaggageItem() enables powerful functionality given a full-stack
- * opentracing integration (e.g., arbitrary application data from a web
- * client can make it, transparently, all the way into the depths of a
- * storage system), and with it some powerful costs: use this feature with
- * care.
- *
- * IMPORTANT NOTE #1: setBaggageItem() will only propagate baggage items to
- * *future* causal descendants of the associated Span.
- *
- * IMPORTANT NOTE #2: Use this thoughtfully and with care. Every key and
- * value is copied into every local *and remote* child of the associated
- * Span, and that can add up to a lot of network and cpu overhead.
- *
- * @param {string} key
- * @param {string} value
- */
- setBaggageItem(key, value) {
- if (process.env.NODE_ENV === 'debug') {
- if (arguments.length !== 2) {
- throw new Error('Invalid number of arguments');
- }
- }
- if (this._imp) {
- this._imp.setBaggageItem(key, value);
- }
- }
-
- /**
- * Returns the value for a baggage item given its key.
- *
- * @param {string} key
- * The key for the given trace attribute.
- * @return {string}
- * String value for the given key, or undefined if the key does not
- * correspond to a set trace attribute.
- */
- getBaggageItem(key) {
- if (process.env.NODE_ENV === 'debug') {
- if (arguments.length !== 1) {
- throw new Error('Invalid number of arguments');
- }
- }
- if (this._imp) {
- return this._imp.getBaggageItem(key);
- }
- return undefined;
- }
-
/**
* Constructs a new SpanContext object.
*
@@ -1,9 +1,5 @@
function NoopSpanContextImp() {
};
-NoopSpanContextImp.prototype.setBaggageItem = function (key, value) {
-};
-NoopSpanContextImp.prototype.getBaggageItem = function (key) {
-};
function NoopSpanImp() {
};
@@ -23,6 +19,10 @@ NoopSpanImp.prototype.log = function (fields) {
};
NoopSpanImp.prototype.finish = function (finishTime) {
};
+NoopSpanImp.prototype.setBaggageItem = function (key, value) {
+};
+NoopSpanImp.prototype.getBaggageItem = function (key) {
+};
function NoopTracerImp() {
};
View
@@ -44,12 +44,8 @@ describe('OpenTracing API', function() {
expect(span.log).to.be.a('function');
expect(span.logEvent).to.be.a('function');
expect(span.finish).to.be.a('function');
- });
-
- it('should have the required SpanContext functions', function() {
- var spanContext = Tracer.startSpan('test_operation').context();
- expect(spanContext.setBaggageItem).to.be.a('function');
- expect(spanContext.getBaggageItem).to.be.a('function');
+ expect(span.setBaggageItem).to.be.a('function');
+ expect(span.getBaggageItem).to.be.a('function');
});
it('should enforce the required carrier types', function() {

0 comments on commit 0fd517d

Please sign in to comment.