Keval Bhogayata
Keval Bhogayata

Reputation: 6736

How to send OTLP metrics data from node.js to Rust grpc server

Using this particular proto file given below https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/metrics/v1/metrics.proto I have created a grpc server in Rust and implemented the export method like this :

impl MetricsService for MyMetrics {
    async fn export(
        &self,
        request: Request<ExportMetricsServiceRequest>,
    ) -> Result<Response<ExportMetricsServiceResponse>, Status> {
        println!("Got a request from {:?}", request.remote_addr());
        println!("request data ==> {:?}", request);


        let reply = metrics::ExportMetricsServiceResponse {};
        Ok(Response::new(reply))
    }
}

To test this code,

  1. I created a grpc client in node.js with same proto file and called the export method - which worked as expected.

  1. Then, I used otlpmetricsexporter in node.js (instead of making an explicit call to export method), in this case, I am not receiving the request on Rust grpc server.

Getting this error : {"stack":"Error: 12 UNIMPLEMENTED: \n at Object.callErrorFromStatus (/home/acq053/work/src/github.com/middleware-labs/agent-node-metrics/node_modules/@grpc/grpc-js/build/src/call.js:31:26)\n at Object.onReceiveStatus (/home/acq053/work/src/github.com/middleware-labs/agent-node-metrics/node_modules/@grpc/grpc-js/build/src/client.js:189:52)\n at Object.onReceiveStatus (/home/acq053/work/src/github.com/middleware-labs/agent-node-metrics/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:365:141)\n at Object.onReceiveStatus (/home/acq053/work/src/github.com/middleware-labs/agent-node-metrics/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:181)\n at /home/acq053/work/src/github.com/middleware-labs/agent-node-metrics/node_modules/@grpc/grpc-js/build/src/call-stream.js:187:78\n at processTicksAndRejections (internal/process/task_queues.js:75:11)","message":"12 UNIMPLEMENTED: ","code":"12","metadata":"[object Object]","name":"Error"}

My Rust Grpc server is running @ [::1]:50057 so, I used OTEL_EXPORTER_OTLP_ENDPOINT=[::1]:50057 env while running my node.js exporter

What could have gone wrong ?!

_ https://github.com/Bhogayata-Keval/rust-grpc-demo.git

Upvotes: 0

Views: 617

Answers (1)

Zeppi
Zeppi

Reputation: 1245

I compile your code with 2 changes.

  1. remove tonic_build::compile_protos("proto/helloworld.proto")in buld.rs
  2. update let addr = "[::1]:50057".parse().unwrap(); by let addr = "127.0.0.1:50057".parse().unwrap(); in metric.rs.

I ran target/debug/metrics. and I used, grpcurl like client. With the command

./grpcurl -plaintext -import-path ./proto -proto metrics.proto 127.0.0.1:50057 metrics.MetricsService/Export

And result was

{

}

It is the expected result?

Regards

Upvotes: 1

Related Questions