- Notifications
You must be signed in to change notification settings - Fork 983
Description
What happened?
Steps to Reproduce
Summary: collector does not receive the right user agent header as per spec from grpc exporters. Instead it sends the default value from the grpc library
Use this repo to reproduce the error https://github.com/david-luna/otel-js-grpc-exporter-ua-bug
Expected Result
User agent header contains the right value as per spec
OTel-OTLP-Exporter-JavaScript/X.Y.Z Actual Result
We get the default value from the lib
grpc-node-js/1.13.4 Additional Details
The grpc client seems to override the user-Agent metadata with some specific client options. Here's is the code that sets the user agent in @grpc/grpc-js
https://github.com/grpc/grpc-node/blob/a8a020339c7eab1347a343a512ad17a4aea4bfdb/packages/grpc-js/src/transport.ts#L144-L149
Most probably the solution would be to use grpc.primary_user_agent and grpc.secondary_user_agent options when creating the client instead of setting a metadata field.
PS: Kudos to @trentm and @xrmx for the analysis and insights about this issue.
OpenTelemetry Setup Code
package.json
Relevant log output
Output from the mock collector in debug mode. > otel-js-grpc-exporter-ua-bug@1.0.0 start:otlp > GRPC_VERBOSITY=DEBUG GRPC_TRACE=all npx @elastic/mockotlpserver {"name":"mockotlpserver","level":30,"msg":"OTLP/HTTP listening at http://127.0.0.1:4318/","time":"2025-08-20T17:22:39.102Z"} D 2025-08-20T17:22:39.103Z | v1.13.4 67201 | server | (1) Server constructed D 2025-08-20T17:22:39.104Z | v1.13.4 67201 | server | (1) bindAsync port=localhost:4317 D 2025-08-20T17:22:39.105Z | v1.13.4 67201 | dns_resolver | Resolver constructed for target dns:localhost:4317 D 2025-08-20T17:22:39.105Z | v1.13.4 67201 | backoff | {0} constructed initialDelay=1000 multiplier=1.6 jitter=0.2 maxDelay=120000 D 2025-08-20T17:22:39.106Z | v1.13.4 67201 | backoff | {0} runOnce() D 2025-08-20T17:22:39.106Z | v1.13.4 67201 | backoff | {0} runTimer(delay=1000) D 2025-08-20T17:22:39.107Z | v1.13.4 67201 | dns_resolver | Looking up DNS hostname localhost D 2025-08-20T17:22:39.109Z | v1.13.4 67201 | backoff | {0} reset() running=true D 2025-08-20T17:22:39.109Z | v1.13.4 67201 | backoff | {0} runTimer(delay=1997) D 2025-08-20T17:22:39.110Z | v1.13.4 67201 | backoff | {0} stop() D 2025-08-20T17:22:39.110Z | v1.13.4 67201 | dns_resolver | Resolved addresses for target dns:localhost:4317: [127.0.0.1:4317,::1:4317] D 2025-08-20T17:22:39.110Z | v1.13.4 67201 | server | (1) Attempting to bind 127.0.0.1:4317 D 2025-08-20T17:22:39.111Z | v1.13.4 67201 | server | (1) Attempting to bind [::1]:4317 D 2025-08-20T17:22:39.111Z | v1.13.4 67201 | server | (1) Successfully bound 127.0.0.1:4317 D 2025-08-20T17:22:39.111Z | v1.13.4 67201 | server | (1) Successfully bound [::1]:4317 {"name":"mockotlpserver","level":30,"msg":"OTLP/gRPC listening at http://localhost:4317/","time":"2025-08-20T17:22:39.112Z"} D 2025-08-20T17:23:06.987Z | v1.13.4 67201 | server | (1) Connection established by client 127.0.0.1:57501 D 2025-08-20T17:23:06.990Z | v1.13.4 67201 | server_call | Received call to method /opentelemetry.proto.collector.trace.v1.TraceService/Export at address null D 2025-08-20T17:23:06.991Z | v1.13.4 67201 | server_call | Request to /opentelemetry.proto.collector.trace.v1.TraceService/Export received headers {"user-agent":["grpc-node-js/1.13.4"],"grpc-accept-encoding":["identity,deflate,gzip"],"accept-encoding":["identity"],"grpc-timeout":["9990m"],"content-type":["application/grpc"],"te":["trailers"]} D 2025-08-20T17:23:06.991Z | v1.13.4 67201 | server_call | Request to /opentelemetry.proto.collector.trace.v1.TraceService/Export start called D 2025-08-20T17:23:06.991Z | v1.13.4 67201 | server_call | Request to /opentelemetry.proto.collector.trace.v1.TraceService/Export startRead called D 2025-08-20T17:23:06.991Z | v1.13.4 67201 | server_call | Request to /opentelemetry.proto.collector.trace.v1.TraceService/Export received data frame of size 3043 D 2025-08-20T17:23:06.997Z | v1.13.4 67201 | server_call | Request to /opentelemetry.proto.collector.trace.v1.TraceService/Export startRead called D 2025-08-20T17:23:06.998Z | v1.13.4 67201 | server_call | Request to /opentelemetry.proto.collector.trace.v1.TraceService/Export sent data frame of size 5Operating System and Version
N/A
Runtime and Version
N/A