Cloud Run上的Cloud Trace有什么限制吗?

时间:2020-08-31 23:55:47

标签: java google-cloud-platform stackdriver google-cloud-run google-cloud-trace

我正在使用Java在Cloud Run上构建微服务。 因此,我想将CloudTrace用于这些服务。但这并没有我预期的那样。引发DeadlineExceededException

我可以在本地PC上运行相同的服务。在那个时候,这没问题。我可以在CloudTrace上确认跟踪。但是当我在Cloud Run上部署它们时,跟踪不起作用... 你有什么主意吗?

代码在下面。我使用OpenCensus库。

var spanContext = TEXT_FORMAT.extract(request, GETTER);
var builder = Tracing.getTracer()
        .spanBuilderWithRemoteParent(name, spanContext);

builder.setRecordEvents(true)
        .setSampler(Samplers.alwaysSample())
        .startScopedSpan();

try ( var ss = builder.setRecordEvents(true)
        .setSampler(Samplers.alwaysSample())
        .startScopedSpan()) {
    var span = Tracing.getTracer().getCurrentSpan();
    span.putAttribute(HttpTraceAttributeConstants.HTTP_HOST, AttributeValue.stringAttributeValue(host));
    span.putAttribute(HttpTraceAttributeConstants.HTTP_METHOD, AttributeValue.stringAttributeValue(method));
    span.putAttribute(HttpTraceAttributeConstants.HTTP_PATH, AttributeValue.stringAttributeValue(path));

    // Something logic
}

错误在下面。

2020-08-31 15:28:23.065 PDT2020-08-31 22:28:22,462 WARNING [io.ope.tra.exp.ExportComponent] (ExportComponent.ServiceExporterThread-0) Exception thrown by the service export io.opencensus.exporter.trace.stackdriver.StackdriverTraceExporter: com.google.api.gax.rpc.DeadlineExceededException: io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED: ClientCall started after deadline exceeded: -2.199245981s from now
2020-08-31 15:28:23.065 PDT at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:51)
2020-08-31 15:28:23.065 PDT at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:72)
2020-08-31 15:28:23.065 PDT at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:60)
2020-08-31 15:28:23.065 PDT at com.google.api.gax.grpc.GrpcExceptionCallable$ExceptionTransformingFuture.onFailure(GrpcExceptionCallable.java:97)
2020-08-31 15:28:23.065 PDT at com.google.api.core.ApiFutures$1.onFailure(ApiFutures.java:68)
2020-08-31 15:28:23.065 PDT at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1056)
2020-08-31 15:28:23.065 PDT at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:30)
2020-08-31 15:28:23.065 PDT at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1138)
2020-08-31 15:28:23.065 PDT at com.google.common.util.concurrent.AbstractFuture.addListener(AbstractFuture.java:707)
2020-08-31 15:28:23.065 PDT at com.google.common.util.concurrent.ForwardingListenableFuture.addListener(ForwardingListenableFuture.java:45)
2020-08-31 15:28:23.065 PDT at com.google.api.core.ApiFutureToListenableFuture.addListener(ApiFutureToListenableFuture.java:52)
2020-08-31 15:28:23.065 PDT at com.google.common.util.concurrent.Futures.addCallback(Futures.java:1037)
2020-08-31 15:28:23.065 PDT at com.google.api.core.ApiFutures.addCallback(ApiFutures.java:63)
2020-08-31 15:28:23.065 PDT at com.google.api.gax.grpc.GrpcExceptionCallable.futureCall(GrpcExceptionCallable.java:67)

我尝试了可扩展服务代理。有用。 但是我想将跟踪作为应用程序的一部分。

0 个答案:

没有答案