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

Commit 8aca762

Browse files
author
Thorsten Nadel
authored
Simplify bundling udp_sender (#530)
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 <[email protected]>
1 parent 0271b4d commit 8aca762

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ In order to bundle the library using webpack, e.g. for uploading code to an AWS
282282
from: require.resolve('jaeger-client/dist/src/jaeger-idl/thrift/jaeger.thrift'),
283283
to: 'jaeger-idl/thrift/jaeger.thrift',
284284
},
285+
{
286+
from: require.resolve('jaeger-client/dist/src/thriftrw-idl/agent.thrift'),
287+
to: 'thriftrw-idl/agent.thrift',
288+
},
285289
]),
286290
];
287291
}

crossdock/test/endtoend_handler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import EndToEndHandler from '../src/endtoend_handler';
1717
import path from 'path';
1818
import request from 'request';
1919
import JaegerTestUtils from '../../src/test_util';
20+
import ThriftUtils from '../../src/thrift';
2021
import { Thrift } from 'thriftrw';
2122
import bodyParser from 'body-parser';
2223
import express from 'express';
@@ -32,7 +33,7 @@ describe('Endtoend Handler should', () => {
3233
server = dgram.createSocket('udp4');
3334
server.bind(PORT, HOST);
3435
thrift = new Thrift({
35-
entryPoint: path.join(__dirname, '../../src/thriftrw-idl/agent.thrift'),
36+
entryPoint: ThriftUtils.buildAgentThriftPath(),
3637
allowOptionalArguments: true,
3738
allowFilesystemAccess: true,
3839
});

src/reporters/udp_sender.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default class UDPSender {
5252
this._logger.error(`error sending spans over UDP: ${err}`);
5353
});
5454
this._agentThrift = new Thrift({
55-
entryPoint: path.join(__dirname, '../thriftrw-idl/agent.thrift'),
55+
entryPoint: ThriftUtils.buildAgentThriftPath(),
5656
allowOptionalArguments: true,
5757
allowFilesystemAccess: true,
5858
});

src/thrift.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export default class ThriftUtils {
2828
return fs.readFileSync(path.join(__dirname, './jaeger-idl/thrift/jaeger.thrift'), 'ascii');
2929
}
3030

31+
static buildAgentThriftPath(): string {
32+
return path.join(__dirname, './thriftrw-idl/agent.thrift');
33+
}
34+
3135
static getThriftTags(initialTags: Array<Tag>): Array<any> {
3236
let thriftTags = [];
3337
for (let i = 0; i < initialTags.length; i++) {

test/udp_sender.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function createUdpSenderTest(options) {
6666
sender = new UDPSender({ host: options.host, socketType: options.socketType });
6767
sender.setProcess(reporter._process);
6868
thrift = new Thrift({
69-
entryPoint: path.join(__dirname, '../src/thriftrw-idl/agent.thrift'),
69+
entryPoint: ThriftUtils.buildAgentThriftPath(),
7070
allowOptionalArguments: true,
7171
allowFilesystemAccess: true,
7272
});

0 commit comments

Comments
 (0)