我正在尝试使用x射线与cognito:
val client: AWSCognitoIdentityProvider =
AWSCognitoIdentityProviderClientBuilder
.standard()
.withCredentials(keysConfig.credentialsProvider)
.withRegion(config.region)
.withClientConfiguration(new ClientConfiguration().withMaxErrorRetry(config.maxErrorRetries))
.withRequestHandlers(new TracingHandler(AWSXRay.getGlobalRecorder))
.build()
但是我得到一堆错误:
SEVERE:抑制AWS x射线上下文缺失异常(SegmentNotFoundException):开始子段命名失败'AWSCognitoIdentityProvider':段无法找到
我正在做一个例子,从:
https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-awssdkclients.html [https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-awssdkclients.html] [1]
我应该在aws xray UI中做一些额外的配置吗?
编辑:我还试图手动删除添加请求处理程序,只是添加一个依赖项:aws-xray-recorder-sdk-aws-sdk-instrumentor但同样的问题…
启用AWS SDK工具将自动为您的AWS调用生成subSegment
。但是在AWS x射线中,子段必须在现有的父segment
下,否则将得到SegmentNotFoundException。
你能尝试用beginSegment()和endsegment()包装你的AWS调用吗?
import com.amazonaws.xray.AWSXRay;
import com.amazonaws.xray.entities.Segment;
try {
segment = AWSXRay.beginSegment("your service name");
// your AWS call
AWSCognito.xxx
} catch (Exception e) {
throw e;
} finally {
AWSXRay.endSegment();
}