java - Cognito xray - segment not found issue
问题描述
I am trying to use x-ray with cognito:
val client: AWSCognitoIdentityProvider =
AWSCognitoIdentityProviderClientBuilder
.standard()
.withCredentials(keysConfig.credentialsProvider)
.withRegion(config.region)
.withClientConfiguration(new ClientConfiguration().withMaxErrorRetry(config.maxErrorRetries))
.withRequestHandlers(new TracingHandler(AWSXRay.getGlobalRecorder))
.build()
but I get bunch of errors:
SEVERE: Suppressing AWS X-Ray context missing exception (SegmentNotFoundException): Failed to begin subsegment named 'AWSCognitoIdentityProvider': segment cannot be found
I am doing it by an example from:
should I do some extra configuration in the aws xray UI ?
EDIT: I tried also to remove manually adding request handler and just add a dependency: aws-xray-recorder-sdk-aws-sdk-instrumentor but the same issue..
解决方案
启用 AWS 开发工具包工具将自动subSegment
为您的 AWS 调用生成。但在 AWS Xray 中,subSegment 必须在现有父级之下,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();
}
推荐阅读
- python - 我可以将 python 文件中设置的环境变量加载到 bash 脚本吗?
- python - list_value 不能包含包含另一个 list_value 的值
- reporting-services - SSRS 表的精确副本不在页面内
- flutter - 如何从底部导航触发抽屉?
- java - 如何根据某些特定条件从 Java HashMap 中的值获取密钥?
- reactjs - ReactJS 引导按钮作为链接(新标签)
- html - 表头/行中的tailwindcss隐藏类
- git - yum 在 Centos 上安装旧版本的 git
- c# - 是否从 EntityFrameworkQueryableExtensions 中删除了非异步方法?
- python - 渲染模板时烧瓶无法初始化我的课程