Always read thrift defs from ./ to better support bundling#441
Always read thrift defs from ./ to better support bundling#441yurishkuro merged 1 commit intojaegertracing:masterfrom
./ to better support bundling#441Conversation
Always reading the jaeger thrift definition file from the root dir (src)
allows consumers to bundle jaeger-client, e.g. for uploading code to an
AWS lambda function.
To bundle jaeger-client with webpack for example, the thrift file needs
to be copied into the output directory of the bundle like this:
```js
{
plugins: [
new CopyPlugin([
{
from: require.resolve(
'jaeger-client/dist/src/jaeger-idl/thrift/jaeger.thrift'
),
to: 'jaeger-idl/thrift/jaeger.thrift'
}
])
]
}
```
With this in place `fs.readFileSync` will be able to find the file.
Signed-off-by: Hendrik Liebau <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #441 +/- ##
=======================================
Coverage 98.71% 98.72%
=======================================
Files 50 50
Lines 2031 2035 +4
Branches 383 383
=======================================
+ Hits 2005 2009 +4
Misses 26 26
Continue to review full report at Codecov.
|
yurishkuro
left a comment
There was a problem hiding this comment.
The refactoring LGTM, but I am not clear if it changes anything. How does it "Allow jaeger-client to be bundled"? Please elaborate.
I recall we had another PR (#424) to actually embed the thrift definitions into a JS file, but the author didn't have cycles to finish it.
|
With my change it is guaranteed that the thrift file is always loaded with a path that is relative to |
./ to better support bundling
…racing#441) Always reading the jaeger thrift definition file from the root dir (src) allows consumers to bundle jaeger-client, e.g. for uploading code to an AWS lambda function. To bundle jaeger-client with webpack for example, the thrift file needs to be copied into the output directory of the bundle like this: ```js { plugins: [ new CopyPlugin([ { from: require.resolve( 'jaeger-client/dist/src/jaeger-idl/thrift/jaeger.thrift' ), to: 'jaeger-idl/thrift/jaeger.thrift' } ]) ] } ``` With this in place `fs.readFileSync` will be able to find the file. Signed-off-by: Hendrik Liebau <[email protected]> Signed-off-by: Kresna <[email protected]>
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]>
Always reading the jaeger thrift definition file from the root dir (i.e.
src) allows consumers to bundlejaeger-client, e.g. for uploading code to an AWS lambda function.To bundle
jaeger-clientwithwebpackfor example, the thrift file needs to be copied into the output directory of the bundle like this:With this in place
fs.readFileSyncwill be able to find the file.Signed-off-by: Hendrik Liebau [email protected]