Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include protos files in bundle directly #3656

Closed
polRk opened this issue Mar 6, 2023 · 1 comment · Fixed by #3705
Closed

Include protos files in bundle directly #3656

polRk opened this issue Mar 6, 2023 · 1 comment · Fixed by #3705
Assignees
Labels
enhancement New feature or request

Comments

@polRk
Copy link

polRk commented Mar 6, 2023

What happened?

I'm using esbuild to build my server in single .mjs file.
And i got an error with ReferenceError: __dirname is not defined
image

@opentelemetry/otlp-grpc-exporter-base/build/src/util.js
Try to load protos files in run time, not build time. Do not do that.

const includeDirs = [path.resolve(__dirname, "..", "protos")];
protoLoader2.load

Steps to Reproduce

Build project with esbuild

esbuild --platform=node --format=esm --bundle

Expected Result

Protos files present in library bundle in build time.

Actual Result

Library try to load protos in run time.

Additional Details

Building for esm, running in node 18.8

OpenTelemetry Setup Code

It doesn't metter

package.json

"@opentelemetry/api": "1.4.0",
    "@opentelemetry/exporter-metrics-otlp-grpc": "^0.35.1",
    "@opentelemetry/exporter-metrics-otlp-http": "0.35.1",
    "@opentelemetry/exporter-prometheus": "0.35.1",
    "@opentelemetry/exporter-trace-otlp-grpc": "0.35.1",
    "@opentelemetry/exporter-trace-otlp-http": "0.35.1",
    "@opentelemetry/instrumentation": "0.35.1",
    "@opentelemetry/instrumentation-graphql": "0.33.0",
    "@opentelemetry/instrumentation-grpc": "0.35.1",
    "@opentelemetry/instrumentation-http": "0.35.1",
    "@opentelemetry/resources": "1.9.1",
    "@opentelemetry/sdk-metrics": "1.9.1",
    "@opentelemetry/sdk-trace-node": "1.9.1",
    "@opentelemetry/semantic-conventions": "1.9.1",

Relevant log output

graphql  | file:///usr/home/app/server.mjs:26961
graphql  |       const includeDirs = [path.resolve(__dirname, "..", "protos")];
graphql  |                                         ^
graphql  | 
graphql  | ReferenceError: __dirname is not defined
graphql  |     at onInit (file:///usr/home/app/server.mjs:26961:41)
graphql  |     at Immediate.<anonymous> (file:///usr/home/app/server.mjs:27164:11)
graphql  |     at process.processImmediate (node:internal/timers:471:21)
graphql  | 
graphql  | Node.js v18.8.0
@polRk polRk added bug Something isn't working triage labels Mar 6, 2023
@polRk polRk changed the title Build proto file with bundle Include protos files in bundle directly Mar 6, 2023
@dyladan dyladan added enhancement New feature or request and removed bug Something isn't working triage labels Mar 15, 2023
@dyladan
Copy link
Member

dyladan commented Mar 15, 2023

I'm removing the bug label since we don't claim to support this. As you said, this is caused by dynamically loading proto files. There have been other requests for this in the past and they seem to be coming more frequently so we should probably look into this soon. I know some people have already done some work looking into statically generated grpc clients, but they ran into compatibility issues with our existing export transformations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants