在X射线控制台AWS中找不到跟踪



我尝试了多种方法,但似乎什么都不起作用

以下是我所做的,

  1. 创建了一个Cloud9实例,启动了一个maven应用程序,添加了aws-sdk-java、x射线核心、x射线仪器、x射线sdk依赖项,创建了DynamoDB客户端运行了该应用程序,插入了数据,但找不到错误子段。手动添加段,错误消失,但没有跟踪
  2. 创建Spring Boot应用程序,添加相同的依赖项,添加Xray servlet过滤器,添加开始段,开始子段,没有错误但没有跟踪

我也有更多的方法,但这些方法似乎非常接近。此外,我还没有安装任何代理或守护程序。有人能说出我哪里错了吗?

我正在尝试创建一个简单的java应用程序,甚至是一个页面来在DynamoDB中插入数据并获取跟踪

我没有在这里进行java共享的经验NodeJS示例希望这会有所帮助。测试如下:https://github.com/aws-samples/aws-xray-sdk-node-sample

const AWSXRay = require('aws-xray-sdk');
const XRayExpress = AWSXRay.express;
const express = require('express');
// Capture all AWS clients we create
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
AWS.config.update({region: process.env.DEFAULT_AWS_REGION || 'us-west-2'});
// Capture all outgoing https requests
AWSXRay.captureHTTPsGlobal(require('https'));
const https = require('https');
// Capture MySQL queries
const mysql = AWSXRay.captureMySQL(require('mysql'));
const app = express();
const port = 3000;
app.use(XRayExpress.openSegment('SampleSite'));
app.get('/', (req, res) => {
const seg = AWSXRay.getSegment();
const sub = seg.addNewSubsegment('customSubsegment');
setTimeout(() => {
sub.close();
res.sendFile(`${process.cwd()}/index.html`);
}, 500);
});
app.get('/aws-sdk/', (req, res) => {
const ddb = new AWS.DynamoDB();
const ddbPromise = ddb.listTables().promise();
ddbPromise.then(function(data) {
res.send(`ListTables result:n ${JSON.stringify(data)}`);
}).catch(function(err) {
res.send(`Encountered error while calling ListTables: ${err}`);
});
});
app.get('/http-request/', (req, res) => {
const endpoint = 'https://amazon.com/';
https.get(endpoint, (response) => {
response.on('data', () => {});
response.on('error', (err) => {
res.send(`Encountered error while making HTTPS request: ${err}`);
});
response.on('end', () => {
res.send(`Successfully reached ${endpoint}.`);
});
});
});
app.get('/mysql/', (req, res) => {
const mysqlConfig = require('./mysql-config.json');
const config = mysqlConfig.config;
const table = mysqlConfig.table;
if (!config.user || !config.database || !config.password || !config.host || !table) {
res.send('Please correctly populate mysql-config.json');
return;
}
const connection = mysql.createConnection(config);
connection.query(`SELECT * FROM ${table}`, (err, results, fields) => {
if (err) {
res.send(`Encountered error while querying ${table}: ${err}`);
return;
}
res.send(`Retrieved the following results from ${table}:n${results}`);
});
connection.end();
});
app.use(XRayExpress.closeSegment());
app.listen(port, () => console.log(`Example app listening on port ${port}!`));

最新更新