zipkin-javascript-opentracing
Advanced tools
Comparing version 1.3.3 to 1.4.0
# Changelog | ||
## 1.3.0 | ||
- Update of `peerDependencies`, so that zipkin v2 schema is supported | ||
- Fix babel transpilation directory | ||
* Update of `peerDependencies`, so that zipkin v2 schema is supported | ||
* Fix babel transpilation directory | ||
## 1.2.0 | ||
Issues arised with [`react-scripts` throwing an error that this library is not transpiled](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify). To fix it we introduced babel and now ship with a transpiled `lib/` folder | ||
Issues arised with [`react-scripts` throwing an error that this library is not | ||
transpiled](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify). | ||
To fix it we introduced babel and now ship with a transpiled `lib/` folder | ||
## 1.1.0 | ||
- [PR#10](https://github.com/costacruise/zipkin-javascript-opentracing/pull/10) adding support for a more simplified setup: | ||
* [PR#10](https://github.com/costacruise/zipkin-javascript-opentracing/pull/10) | ||
adding support for a more simplified setup: | ||
```js | ||
@@ -17,5 +23,5 @@ const ZipkinOpentracing = require("zipkin-javascript-opentracing"); | ||
const tracer = new ZipkinOpentracing({ | ||
serviceName: 'My Service', | ||
endpoint: "http://localhost:9411", | ||
kind: 'client', | ||
serviceName: "My Service", | ||
endpoint: "http://localhost:9411", | ||
kind: "client" | ||
}); | ||
@@ -26,2 +32,4 @@ ``` | ||
- [PR#9](https://github.com/costacruise/zipkin-javascript-opentracing/pull/9) moving dev dependencies up to peer dependencies, breaking change for clients using older versions of `opentracing`, `zipkin` or `zipkin-transport-http` | ||
* [PR#9](https://github.com/costacruise/zipkin-javascript-opentracing/pull/9) | ||
moving dev dependencies up to peer dependencies, breaking change for clients | ||
using older versions of `opentracing`, `zipkin` or `zipkin-transport-http` |
@@ -37,3 +37,21 @@ "use strict"; | ||
// copied from https://github.com/openzipkin/zipkin-js/blob/master/packages/zipkin/src/tracer/randomTraceId.js | ||
var startSpanAnnotation = { | ||
client: Annotation.ClientSend, | ||
local: Annotation.ClientSend, // waiting for local PR in zipkin to get merged | ||
server: Annotation.ServerRecv | ||
}; | ||
var addressAnnotation = { | ||
client: Annotation.ClientAddr, | ||
local: Annotation.ClientAddr, // waiting for local PR in zipkin to get merged | ||
server: Annotation.ServerAddr | ||
}; | ||
var finishSpanAnnotation = { | ||
client: Annotation.ClientRecv, | ||
local: Annotation.ClientRecv, // waiting for local PR in zipkin to get merged | ||
server: Annotation.ServerSend | ||
}; | ||
// copied from https://github.com/openzipkin/zipkin-js/blob/08f86b63a5fd7ded60762f537be1845ede588ffa/packages/zipkin/src/tracer/randomTraceId.js | ||
function randomTraceId() { | ||
@@ -122,8 +140,3 @@ // === Generate a random 64-bit number in fixed-length hex format | ||
tracer.recordServiceName(serviceName); | ||
if (kind === "client") { | ||
tracer.recordAnnotation(new Annotation.ClientSend()); | ||
} else { | ||
tracer.recordAnnotation(new Annotation.ServerRecv()); | ||
} | ||
tracer.recordAnnotation(new startSpanAnnotation[kind]()); | ||
}); | ||
@@ -180,7 +193,3 @@ } | ||
if (kind === "client") { | ||
tracer.recordAnnotation(new Annotation.ClientAddr(address)); | ||
} else { | ||
tracer.recordAnnotation(new Annotation.ServerAddr(address)); | ||
} | ||
tracer.recordAnnotation(new addressAnnotation[kind](address)); | ||
break; | ||
@@ -201,8 +210,3 @@ | ||
tracer.setId(_this3.id); | ||
if (kind === "client") { | ||
tracer.recordAnnotation(new Annotation.ClientRecv()); | ||
} else { | ||
tracer.recordAnnotation(new Annotation.ServerSend()); | ||
} | ||
tracer.recordAnnotation(new finishSpanAnnotation[kind]()); | ||
}); | ||
@@ -244,4 +248,4 @@ } | ||
if (options.kind !== "client" && options.kind !== "server") { | ||
throw new Error('kind option needs to be provided as either "client" or "server"'); | ||
if (options.kind !== "client" && options.kind !== "server" && options.kind !== "local") { | ||
throw new Error('kind option needs to be provided as either "local", "client" or "server"'); | ||
} | ||
@@ -248,0 +252,0 @@ |
{ | ||
"name": "zipkin-javascript-opentracing", | ||
"version": "1.3.3", | ||
"version": "1.4.0", | ||
"description": "An opentracing implementation for zipkin", | ||
@@ -15,3 +15,3 @@ "main": "lib/index.js", | ||
"prepare": "npm run build", | ||
"fmt": "prettier **/*.{js,json,css} --write" | ||
"fmt": "prettier **/*.{js,json,css,md} --write" | ||
}, | ||
@@ -77,3 +77,3 @@ "jest": { | ||
"opentracing": "*", | ||
"prettier": "^1.7.4", | ||
"prettier": "^1.8.1", | ||
"zipkin": ">=0.9.0", | ||
@@ -83,4 +83,4 @@ "zipkin-transport-http": ">=0.9.0" | ||
"lint-staged": { | ||
"*.{js,json,css}": ["prettier --write", "git add"] | ||
"*.{js,json,css,md}": ["prettier --write", "git add"] | ||
} | ||
} |
@@ -7,4 +7,10 @@ # Zipkin-Javascript-Opentracing [![Build Status](https://travis-ci.org/DanielMSchmidt/zipkin-javascript-opentracing.svg?branch=master)](https://travis-ci.org/DanielMSchmidt/zipkin-javascript-opentracing) [![Coverage Status](https://coveralls.io/repos/github/DanielMSchmidt/zipkin-javascript-opentracing/badge.svg?branch=master)](https://coveralls.io/github/DanielMSchmidt/zipkin-javascript-opentracing?branch=master) | ||
For usage instructions, please see the examples in the [`examples/`](examples/) directory. | ||
There is a [basic](https://github.com/DanielMSchmidt/zipkin-javascript-opentracing/tree/master/example/basic) example that shows how to use the tracer in the context of a single express server and there is an [advanced](https://github.com/DanielMSchmidt/zipkin-javascript-opentracing/tree/master/example/advanced) example that shows how multiple services (express API and frontend) might interact and share a tracing context. | ||
For usage instructions, please see the examples in the [`examples/`](examples/) | ||
directory. There is a | ||
[basic](https://github.com/DanielMSchmidt/zipkin-javascript-opentracing/tree/master/example/basic) | ||
example that shows how to use the tracer in the context of a single express | ||
server and there is an | ||
[advanced](https://github.com/DanielMSchmidt/zipkin-javascript-opentracing/tree/master/example/advanced) | ||
example that shows how multiple services (express API and frontend) might | ||
interact and share a tracing context. | ||
@@ -15,4 +21,5 @@ ## Limitations | ||
We currently only support HTTP Headers. If you need your own mechanism, feel free to do a PR. | ||
Also we assume that you only inject the HTTP Headers once, otherwise we will send multiple `ClientSend` annotations for you. | ||
We currently only support HTTP Headers. If you need your own mechanism, feel | ||
free to do a PR. Also we assume that you only inject the HTTP Headers once, | ||
otherwise we will send multiple `ClientSend` annotations for you. | ||
@@ -23,3 +30,2 @@ ### Flags | ||
### Follows From (zipkin) | ||
@@ -40,3 +46,4 @@ | ||
All examples need to run zipkin on `"localhost:9411"`. This is best achieved by using docker: | ||
All examples need to run zipkin on `"localhost:9411"`. This is best achieved by | ||
using docker: | ||
@@ -49,8 +56,9 @@ ```bash | ||
To see how to use this library with only one service see `examples/basic`. | ||
You can run the example with `npm run example:basic`. | ||
To see how to use this library with only one service see `examples/basic`. You | ||
can run the example with `npm run example:basic`. | ||
### Advanced | ||
In order to see how different services may pick up spans and extend them, please see the advanced example at `examples/advanced`. | ||
You can run the example with `npm run example:advanced`. | ||
In order to see how different services may pick up spans and extend them, please | ||
see the advanced example at `examples/advanced`. You can run the example with | ||
`npm run example:advanced`. |
@@ -73,2 +73,36 @@ const opentracing = require("opentracing"); | ||
it("should be have kind server, client and local ", () => { | ||
expect(() => { | ||
new Tracer({ | ||
serviceName: "MyService", | ||
recorder: {}, | ||
kind: "client" | ||
}); | ||
}).not.toThrowError(); | ||
expect(() => { | ||
new Tracer({ | ||
serviceName: "MyService", | ||
recorder: {}, | ||
kind: "server" | ||
}); | ||
}).not.toThrowError(); | ||
expect(() => { | ||
new Tracer({ | ||
serviceName: "MyService", | ||
recorder: {}, | ||
kind: "local" | ||
}); | ||
}).not.toThrowError(); | ||
expect(() => { | ||
new Tracer({ | ||
serviceName: "MyService", | ||
recorder: {}, | ||
kind: "peter" | ||
}); | ||
}).toThrowErrorMatchingSnapshot(); | ||
}); | ||
it("should support 128bit trace Ids lengths"); | ||
@@ -75,0 +109,0 @@ |
@@ -24,3 +24,21 @@ const { | ||
// copied from https://github.com/openzipkin/zipkin-js/blob/master/packages/zipkin/src/tracer/randomTraceId.js | ||
const startSpanAnnotation = { | ||
client: Annotation.ClientSend, | ||
local: Annotation.ClientSend, // waiting for local PR in zipkin to get merged | ||
server: Annotation.ServerRecv | ||
}; | ||
const addressAnnotation = { | ||
client: Annotation.ClientAddr, | ||
local: Annotation.ClientAddr, // waiting for local PR in zipkin to get merged | ||
server: Annotation.ServerAddr | ||
}; | ||
const finishSpanAnnotation = { | ||
client: Annotation.ClientRecv, | ||
local: Annotation.ClientRecv, // waiting for local PR in zipkin to get merged | ||
server: Annotation.ServerSend | ||
}; | ||
// copied from https://github.com/openzipkin/zipkin-js/blob/08f86b63a5fd7ded60762f537be1845ede588ffa/packages/zipkin/src/tracer/randomTraceId.js | ||
function randomTraceId() { | ||
@@ -101,8 +119,3 @@ // === Generate a random 64-bit number in fixed-length hex format | ||
tracer.recordServiceName(serviceName); | ||
if (kind === "client") { | ||
tracer.recordAnnotation(new Annotation.ClientSend()); | ||
} else { | ||
tracer.recordAnnotation(new Annotation.ServerRecv()); | ||
} | ||
tracer.recordAnnotation(new startSpanAnnotation[kind]()); | ||
}); | ||
@@ -149,7 +162,3 @@ } | ||
if (kind === "client") { | ||
tracer.recordAnnotation(new Annotation.ClientAddr(address)); | ||
} else { | ||
tracer.recordAnnotation(new Annotation.ServerAddr(address)); | ||
} | ||
tracer.recordAnnotation(new addressAnnotation[kind](address)); | ||
break; | ||
@@ -167,8 +176,3 @@ | ||
tracer.setId(this.id); | ||
if (kind === "client") { | ||
tracer.recordAnnotation(new Annotation.ClientRecv()); | ||
} else { | ||
tracer.recordAnnotation(new Annotation.ServerSend()); | ||
} | ||
tracer.recordAnnotation(new finishSpanAnnotation[kind]()); | ||
}); | ||
@@ -205,5 +209,9 @@ } | ||
if (options.kind !== "client" && options.kind !== "server") { | ||
if ( | ||
options.kind !== "client" && | ||
options.kind !== "server" && | ||
options.kind !== "local" | ||
) { | ||
throw new Error( | ||
'kind option needs to be provided as either "client" or "server"' | ||
'kind option needs to be provided as either "local", "client" or "server"' | ||
); | ||
@@ -210,0 +218,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
472598
37
2027
60
6