use of com.amazonaws.xray.entities.AWSLogReference in project aws-xray-sdk-java by aws.
the class EKSPlugin method populateLogReferences.
/**
* Generate log references by calling K8s for Container Insights configuration data.
*/
private void populateLogReferences() {
if (clusterName == null) {
clusterName = ContainerInsightsUtil.getClusterName();
}
AWSLogReference log = new AWSLogReference();
log.setLogGroup(String.format("/aws/containerinsights/%s/application", clusterName));
logReferences.add(log);
}
use of com.amazonaws.xray.entities.AWSLogReference in project aws-xray-sdk-java by aws.
the class EC2Plugin method populateLogReferences.
/**
* Reads the log group configuration file generated by the CloudWatch Agent to discover all log groups being used on this
* instance and populates log reference set with them to be included in trace documents.
*/
public void populateLogReferences() {
String filePath = null;
String programData = System.getenv(WINDOWS_PROGRAM_DATA);
if (StringValidator.isNullOrBlank(programData)) {
for (Path root : fs.getRootDirectories()) {
if (root.toString().equals(LINUX_ROOT)) {
filePath = LINUX_ROOT + LINUX_PATH;
break;
}
}
} else {
filePath = programData + WINDOWS_PATH;
}
if (filePath == null) {
logger.warn("X-Ray could not recognize the file system in use. Expected file system to be Linux or Windows based.");
return;
}
try {
JsonNode logConfigs = JsonUtils.getNodeFromJsonFile(filePath, LOG_CONFIGS);
List<String> logGroups = JsonUtils.getMatchingListFromJsonArrayNode(logConfigs, LOG_GROUP_NAME);
for (String logGroup : logGroups) {
AWSLogReference logReference = new AWSLogReference();
logReference.setLogGroup(logGroup);
logReferences.add(logReference);
}
} catch (IOException e) {
logger.warn("CloudWatch Agent log configuration file not found at " + filePath + ". Install the CloudWatch Agent " + "on this instance to record log references in X-Ray.");
} catch (RuntimeException e) {
logger.warn("An unexpected exception occurred while reading CloudWatch agent log configuration file at " + filePath + ":\n", e);
}
}
Aggregations