I have an external request to the aggregator, from which there is a request to the gRPC server. I only get metrics from ingress-gateway to aggregator. and from the aggregator to the grpc service. It turns out that I do not build a complete query dependency tree, but only two parts of it. How can I get the complete dependency tree?
second metrics
my dependencies
<dependency>
<groupId>net.devh</groupId>
<artifactId>grpc-spring-boot-starter</artifactId>
<version>2.12.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.4.5</version>
</dependency>
my code
@Service
public class GrpcService {
@GrpcClient("square")
private SquareRpcGrpc.SquareRpcBlockingStub blockingStub;
@GrpcClient("square")
private SquareRpcGrpc.SquareRpcStub asyncStub;
public Object getSquareResponseUnary(int number){
return IntStream.rangeClosed(1, number)
.mapToObj(i -> Input.newBuilder().setNumber(i).build())
.map(this.blockingStub::findSquareUnary)
.collect(Collectors.toMap(
Output::getNumber,
Output::getResult
));
}
public Object getSquareResponseStream(int number){
CompletableFuture<Map<Integer, Integer>> completableFuture = new CompletableFuture<>();
OutputStreamingResponse outputStreamingResponse = new OutputStreamingResponse(
new HashMap<>(),
completableFuture
);
StreamObserver<Input> squareBiStream = this.asyncStub.findSquareBiStream(outputStreamingResponse);
IntStream.rangeClosed(1, number)
.mapToObj(i -> Input.newBuilder().setNumber(i).build())
.forEach(squareBiStream::onNext);
squareBiStream.onCompleted();
return completableFuture;
}
}
proto file
syntax = "proto3";
package vinsmath;
option java_package = "com.vinsguru.model";
option java_multiple_files = true;
message Input {
int32 number = 1;
}
message Output {
int32 number = 1;
int32 result = 2;
}
service SquareRpc {
rpc findSquareUnary(Input) returns (Output) {};
rpc findSquareBiStream(stream Input) returns (stream Output) {};
}
deployment and svc grpc
apiVersion: v1
kind: Service
metadata:
name: grpc-service
labels:
app: grpc
spec:
type: ClusterIP
selector:
app: grpc
ports:
- name: grpc
protocol: TCP
port: 50101
targetPort: 50101
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: grpc
spec:
selector:
matchLabels:
app: grpc
version: v1
replicas: 1
template:
metadata:
labels:
app: grpc
version: v1
spec:
containers:
- name: grpc
image: 13523661/grpc-square-service:6.9
imagePullPolicy: Always
ports:
- containerPort: 50101
env:
- name: JAEGER_ENDPOINT
value: http://jaeger-collector.istio-system.svc:14268/api/traces
- name: JAEGER_PROPAGATION
value: b3
---
Deployment aggregator
apiVersion: v1
kind: Service
metadata:
name: agr
labels:
app: agr
service: agr
spec:
ports:
- port: 8080
name: http
selector:
app: agr
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: agr-v1
labels:
app: agr
version: v1
spec:
selector:
matchLabels:
app: agr
version: v1
replicas: 1
template:
metadata:
labels:
app: agr
version: v1
spec:
containers:
- name: agr
image: 13523661/aggregator-service:6.9
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
env:
- name: GRPC_CLIENT_SQUARE_ADDRESS
valueFrom:
secretKeyRef:
name: secret-3
key: grpc.client.square.address
- name: REST_SQUARE_SERVICE_ENDPOINT
valueFrom:
secretKeyRef:
name: secret-3
key: rest.square.service.endpoint
- name: JAEGER_ENDPOINT
value: http://jaeger-collector.istio-system.svc:14250/api/traces
- name: JAEGER_PROPAGATION
value: b3
Maybe you have an example of how to get the full tracing span
it works for me
@Configuration public class TracingConfig {
@GrpcGlobalClientInterceptor
TracingClientInterceptor tracingInterceptor(Tracer tracer) {
return TracingClientInterceptor
.newBuilder()
.withTracer(tracer)
.build();
}
}
link https://github.com/opentracing-contrib/java-grpc