Reputation: 6736
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,
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
Reputation: 1245
I compile your code with 2 changes.
tonic_build::compile_protos("proto/helloworld.proto")
in buld.rslet 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