Java 在X射线控制台AWS中未找到跟踪
我尝试了多种方法,但似乎没有任何效果 这就是我所做的Java 在X射线控制台AWS中未找到跟踪,java,spring,amazon-web-services,maven,aws-xray,Java,Spring,Amazon Web Services,Maven,Aws Xray,我尝试了多种方法,但似乎没有任何效果 这就是我所做的 创建Cloud9实例,启动maven应用程序,添加aws sdk java、x-ray core、x-ray instrumentor、x-ray sdk依赖项,创建DynamoDB客户端运行应用程序,插入数据,但未找到错误子段。手动添加段,错误消失,但没有跟踪 创建SpringBoot应用程序,添加相同的依赖项,添加X射线servlet过滤器,添加开始段,开始子段,没有错误但没有跟踪 我也有更多的方法,但这些方法似乎非常接近。此外,我还没有
我正在尝试创建一个简单的java应用程序,甚至是一个页面来在DynamoDB中插入数据并获取跟踪信息。我没有在java共享节点JS示例中工作的经验,希望这会有所帮助。对此进行了测试:
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}!`));