Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into upsampling
Browse files Browse the repository at this point in the history
  • Loading branch information
vprithvi committed Jul 24, 2017
2 parents 8fa31bc + 178dddf commit 39f7dff
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 78 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
sh --registry=https://registry.npmjs.org
Changes by Version
==================

3.6.0 (unreleased)
------------------

- Add support for upsampling (#128)
New features:

- Save baggage in span logs (#129)
- Add support for upsampling (#128)

Bug fixes:

- Trap exceptions from socket.send() (#137) - thanks @frankgreco
- Use ip tag instead of peer.ipv4 in process (#125)


3.5.3 (2017-04-24)
Expand Down
11 changes: 1 addition & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,4 @@ add your name to the copyright section of the licence file.

## Releases

Declaring formal releases requires peer review.

- A reviewer of a pull request should recommend a new version number (patch, minor or major).
- Once your change is merged feel free to bump the version as recommended by the reviewer.
- A new version number should not be cut without peer review unless done by the project maintainer.

### Cutting a new version

TBD

See [RELEASE.md](./RELEASE.md).
126 changes: 63 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,27 @@ must be a function that returns a context with the methods 'getSpan', and 'setSp
and assign the span to the context respectively.

```javascript
import { TChannelBridge } from 'jaeger-client';
import Context from 'some-conformant-context';

function contextFactory() {
return new Context();
};

let bridge = new TChannelBridge(tracer, {contextFactory: contextFactory});
let server = new TChannel({ serviceName: 'server' });
server.listen(4040, '127.0.0.1');
let serverThriftChannel = TChannelAsThrift({
channel: server,
entryPoint: path.join(__dirname, 'thrift', 'echo.thrift') // file path to a thrift file
});

let perProcessOptions = {};
serverThriftChannel.register(server, 'Echo::echo', perProcessOptions, bridge.tracedHandler(
(perProcessOptions, req, head, body, callback) => {
/* Your handler code goes here. */
}
));
import { TChannelBridge } from 'jaeger-client';
import Context from 'some-conformant-context';

function contextFactory() {
return new Context();
};

let bridge = new TChannelBridge(tracer, {contextFactory: contextFactory});
let server = new TChannel({ serviceName: 'server' });
server.listen(4040, '127.0.0.1');
let serverThriftChannel = TChannelAsThrift({
channel: server,
entryPoint: path.join(__dirname, 'thrift', 'echo.thrift') // file path to a thrift file
});

let perProcessOptions = {};
serverThriftChannel.register(server, 'Echo::echo', perProcessOptions, bridge.tracedHandler(
(perProcessOptions, req, head, body, callback) => {
/* Your handler code goes here. */
}
));
```


Expand All @@ -82,53 +82,53 @@ Outbound calls can be made in two ways, shown below.
#### Using encoded channel to create a request and calling `request.send()`

```javascript
import { TChannelBridge } from 'jaeger-client';

let bridge = new TChannelBridge(tracer);
// Create the toplevel client channel.
let client = new TChannel();

// Create the client subchannel that makes requests.
let clientSubChannel = client.makeSubChannel({
serviceName: 'server',
peers: ['127.0.0.1:4040']
});

let encodedThriftChannel = TChannelAsThrift({
channel: clientSubChannel,
entryPoint: path.join(__dirname, 'thrift', 'echo.thrift') // file path to a thrift file
});

// wrap encodedThriftChannel in a tracing decorator
let tracedChannel = bridge.tracedChannel(encodedThriftChannel);

// The encodedThriftChannel's (also true for json encoded channels) request object can call 'send' directly.
let req = tracedChannel.request({
serviceName: 'server',
context: context, // must be passed through from the service handler shown above
headers: { cn: 'echo' }
});

// headers should contain your outgoing tchannel headers if any.
// In this instance 'send' is being called on the request object, and not the channel.
req.send('Echo::echo', headers, { value: 'some-string' });
import { TChannelBridge } from 'jaeger-client';

let bridge = new TChannelBridge(tracer);
// Create the toplevel client channel.
let client = new TChannel();

// Create the client subchannel that makes requests.
let clientSubChannel = client.makeSubChannel({
serviceName: 'server',
peers: ['127.0.0.1:4040']
});

let encodedThriftChannel = TChannelAsThrift({
channel: clientSubChannel,
entryPoint: path.join(__dirname, 'thrift', 'echo.thrift') // file path to a thrift file
});

// wrap encodedThriftChannel in a tracing decorator
let tracedChannel = bridge.tracedChannel(encodedThriftChannel);

// The encodedThriftChannel's (also true for json encoded channels) request object can call 'send' directly.
let req = tracedChannel.request({
serviceName: 'server',
context: context, // must be passed through from the service handler shown above
headers: { cn: 'echo' }
});

// headers should contain your outgoing tchannel headers if any.
// In this instance 'send' is being called on the request object, and not the channel.
req.send('Echo::echo', headers, { value: 'some-string' });
```

#### Using top level channel to create a request and calling `encodedChannel.send(request)`

```javascript
let tracedChannel = bridge.tracedChannel(encodedThriftChannel);

// tracedChannel.channel refers to encodedThriftChannel's inner channel which
// is clientSubChannel in this instance.
let req = tracedChannel.channel.request({
serviceName: 'server',
headers: { cn: 'echo' },
context: context, // must be passed through from the service handler shown above
timeout: someTimeout,
});
// send() can be called directly on the tracing decorator
tracedChannel.send(req, 'Echo::echo', o.headers, { value: 'some-string' }, clientCallback);
let tracedChannel = bridge.tracedChannel(encodedThriftChannel);

// tracedChannel.channel refers to encodedThriftChannel's inner channel which
// is clientSubChannel in this instance.
let req = tracedChannel.channel.request({
serviceName: 'server',
headers: { cn: 'echo' },
context: context, // must be passed through from the service handler shown above
timeout: someTimeout,
});
// send() can be called directly on the tracing decorator
tracedChannel.send(req, 'Echo::echo', o.headers, { value: 'some-string' }, clientCallback);
```

### Debug Traces (Forced Sampling)
Expand Down
35 changes: 35 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Release Process

Declaring formal releases requires peer review.

* A reviewer of a pull request should recommend a new version number (patch, minor or major).
* Once your change is merged feel free to bump the version as recommended by the reviewer.
* A new version number should not be cut without peer review unless done by the project maintainer.

## Publishing a new version

* Decide on the next `major.minor.patch` release number based on [semver](http://semver.org/) guidelines
* Create a pull request titled "Preparing release {version}"
* Update the version in [package.json](./package.json)
* Add an entry to [CHANGELOG.md](./CHANGELOG.md)
* Caption `{version} (yyyy-mm-dd)`
* List significant changes since the last release
* If there are breaking changes, point to documentation / upgrade instructions
* Get the pull request approved and merged
* Create a release on Github
* Tag must be in the format `v{major}.{minor}.{patch}` (note the required `v` prefix)
* Title "Release {major}.{minor}.{patch}"
* Copy the list of changes from the change log to release description
* If there are breaking changes, point to documentation / upgrade instructions
* [optional] Add a thank you note to contributors
* Publish the new version to [NPM](https://www.npmjs.com/package/jaeger-client)
* `git checkout master && git pull`
* `git log --abbrev-commit | head` (expecting to see a tagged commit, e.g. `commit 510cebd (tag: v3.5.3)`)
* `make build-node`
* `npm publish` (requires permissions)
* Create a "Back to developement" pull request
* Increment patch number in [package.json](./package.json) with `dev` suffix, e.g. if the last release was `3.5.3` then change it to `3.5.4dev`
* Add a new entry to [CHANGELOG.md](./CHANGELOG.md)
* Caption `{next_version} (unreleased)`
* In place of the list of changes, add one entry "- nothing yet"
* Get this pull request merged asap
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jaeger-client",
"version": "3.6.0",
"version": "3.6.0dev",
"description": "Jaeger binding for OpenTracing Node",
"license": "MIT",
"keywords": [],
Expand Down
6 changes: 5 additions & 1 deletion src/reporters/udp_sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ export default class UDPSender {
return {err: true, numSpans: numSpans};
}

// TODO(oibe) use callback in send
// https://nodejs.org/api/dgram.html#dgram_socket_send_msg_offset_length_port_address_callback
this._client.on('error', err => {
console.log(`error sending span: ${err}`)
})

this._client.send(thriftBuffer, 0, thriftBuffer.length, this._port, this._host);
this._reset();

Expand Down
20 changes: 19 additions & 1 deletion test/udp_sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
// THE SOFTWARE.

import _ from 'lodash';
import {assert} from 'chai';
import {assert, expect} from 'chai';
import ConstSampler from '../src/samplers/const_sampler.js';
import dgram from 'dgram';
import fs from 'fs';
import path from 'path';
import InMemoryReporter from '../src/reporters/in_memory_reporter.js';
import RemoteReporter from '../src/reporters/remote_reporter.js';
import opentracing from 'opentracing';
import Tracer from '../src/tracer.js';
import {Thrift} from 'thriftrw';
Expand Down Expand Up @@ -249,4 +250,21 @@ describe('udp sender should', () => {
assert.equal(response.err, false);
assert.equal(response.numSpans, 0);
});

it ('flush gracefully handles errors emitted by socket.send', done => {
sender._host = 'foo.bar.com';
sender._port = 1234;
new Tracer(
'test-service-name',
new RemoteReporter(sender),
new ConstSampler(true)
).startSpan('testSpan').finish();
let oldLog = console.log;
console.log = message => {
expect(message).to.have.string('error sending span: Error: getaddrinfo ENOTFOUND');
console.log = oldLog;
done();
};
sender.flush();
});
});

0 comments on commit 39f7dff

Please sign in to comment.