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

Commit

Permalink
Simplify bundling udp_sender (#530)
Browse files Browse the repository at this point in the history
Add a helper function in src/thrift.js that returns an absolute path to
agent.thrift, without using "../". This is done to simplify bundling with
webpack or esbuild: assume an app is bundled to /app/index.js, if we resolve
a path to "../thrift-idl/etc", the file will be loaded from /thrift-idl/etc,
which is at the root of the filesystem.

Adjust README to support udp-sender.

This commit is a continuation of #441.

Signed-off-by: Thorsten Nadel <18720251+punkfest@users.noreply.github.com>
  • Loading branch information
Thorsten Nadel authored Oct 30, 2021
1 parent 0271b4d commit 8aca762
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ In order to bundle the library using webpack, e.g. for uploading code to an AWS
from: require.resolve('jaeger-client/dist/src/jaeger-idl/thrift/jaeger.thrift'),
to: 'jaeger-idl/thrift/jaeger.thrift',
},
{
from: require.resolve('jaeger-client/dist/src/thriftrw-idl/agent.thrift'),
to: 'thriftrw-idl/agent.thrift',
},
]),
];
}
Expand Down
3 changes: 2 additions & 1 deletion crossdock/test/endtoend_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import EndToEndHandler from '../src/endtoend_handler';
import path from 'path';
import request from 'request';
import JaegerTestUtils from '../../src/test_util';
import ThriftUtils from '../../src/thrift';
import { Thrift } from 'thriftrw';
import bodyParser from 'body-parser';
import express from 'express';
Expand All @@ -32,7 +33,7 @@ describe('Endtoend Handler should', () => {
server = dgram.createSocket('udp4');
server.bind(PORT, HOST);
thrift = new Thrift({
entryPoint: path.join(__dirname, '../../src/thriftrw-idl/agent.thrift'),
entryPoint: ThriftUtils.buildAgentThriftPath(),
allowOptionalArguments: true,
allowFilesystemAccess: true,
});
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/udp_sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class UDPSender {
this._logger.error(`error sending spans over UDP: ${err}`);
});
this._agentThrift = new Thrift({
entryPoint: path.join(__dirname, '../thriftrw-idl/agent.thrift'),
entryPoint: ThriftUtils.buildAgentThriftPath(),
allowOptionalArguments: true,
allowFilesystemAccess: true,
});
Expand Down
4 changes: 4 additions & 0 deletions src/thrift.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default class ThriftUtils {
return fs.readFileSync(path.join(__dirname, './jaeger-idl/thrift/jaeger.thrift'), 'ascii');
}

static buildAgentThriftPath(): string {
return path.join(__dirname, './thriftrw-idl/agent.thrift');
}

static getThriftTags(initialTags: Array<Tag>): Array<any> {
let thriftTags = [];
for (let i = 0; i < initialTags.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion test/udp_sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function createUdpSenderTest(options) {
sender = new UDPSender({ host: options.host, socketType: options.socketType });
sender.setProcess(reporter._process);
thrift = new Thrift({
entryPoint: path.join(__dirname, '../src/thriftrw-idl/agent.thrift'),
entryPoint: ThriftUtils.buildAgentThriftPath(),
allowOptionalArguments: true,
allowFilesystemAccess: true,
});
Expand Down

0 comments on commit 8aca762

Please sign in to comment.