Skip to content

Commit b8a19fa

Browse files
author
Aarushi Singh
committed
Fix naming in lgo generator
2 parents 4427cd0 + a5b66f6 commit b8a19fa

File tree

9 files changed

+51
-32
lines changed

9 files changed

+51
-32
lines changed

CONTRIBUTING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Contributing
2+
3+
We love pull requests from everyone, especially if they are to expand the available functionality or address one of the [open issues](https://github.com/cisco-open/test-telemetry-generator/issues). You will need the following to start with:
4+
* Github access, obviously
5+
* JDK 11
6+
* Gradle 5.6.4 or above
7+
8+
Once you have the above setup:
9+
* Clone the project
10+
* Create a new branch on your local machine
11+
* Make the changes and add tests for your changes
12+
* Run all tests in your local using
13+
`./gradlew clean build test` for Linux/Mac
14+
`gradlew.bat clean build test` for Windows
15+
Doing this in local will ensure that the tests pass on the Github workflow too
16+
* Push your branch and open a pull request with a good description of the changes being made
17+
* Someone will review and we may suggest some changes, improvements or alternatives
18+
19+
Thank you and happy coding!

src/main/java/io/opentelemetry/contrib/generator/telemetry/cli/CLIProcessor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private static Options getOptions() {
7979
.desc("Path to the trace definition YAML")
8080
.hasArg()
8181
.build();
82-
Option cisTargetYAML = Option.builder("t")
82+
Option targetEnvYAML = Option.builder("t")
8383
.argName("target")
8484
.desc("Path to the YAML containing details of the environment to target")
8585
.hasArg()
@@ -90,15 +90,15 @@ private static Options getOptions() {
9090
options.addOption(metricDefinition);
9191
options.addOption(logsDefinition);
9292
options.addOption(traceDefinition);
93-
options.addOption(cisTargetYAML);
93+
options.addOption(targetEnvYAML);
9494

9595
HelpFormatter formatter = new HelpFormatter();
9696
formatter.printHelp("test-telemetry-generator-all.jar", options, true);
9797
return options;
9898
}
9999

100-
private static PayloadHandler getPayloadHandler(String cisTargetYAML) {
101-
TargetEnvironmentDetails targetEnvironmentDetails = getCISTargetDetails(cisTargetYAML);
100+
private static PayloadHandler getPayloadHandler(String targetEnvYAML) {
101+
TargetEnvironmentDetails targetEnvironmentDetails = getTargetEnvDetails(targetEnvYAML);
102102
if (StringUtils.defaultString(targetEnvironmentDetails.getUsername()).isBlank()) {
103103
throw new GeneratorException("Missing username in environment target YAML");
104104
}
@@ -126,17 +126,17 @@ private static PayloadHandler getPayloadHandler(String cisTargetYAML) {
126126
new BasicAuthHandler(targetEnvironmentDetails.getUsername(), targetEnvironmentDetails.getPassword()));
127127
}
128128

129-
private static TargetEnvironmentDetails getCISTargetDetails(String cisTargetYAML) {
130-
File yamlFile = new File(cisTargetYAML);
129+
private static TargetEnvironmentDetails getTargetEnvDetails(String targetEnvYAML) {
130+
File yamlFile = new File(targetEnvYAML);
131131
if (!(yamlFile.exists() && yamlFile.canRead())) {
132-
throw new GeneratorException("Unable to read provided CIS target YAML file " + cisTargetYAML);
132+
throw new GeneratorException("Unable to read provided target environment YAML file " + targetEnvYAML);
133133
}
134134

135135
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
136136
try {
137137
return mapper.readValue(yamlFile, TargetEnvironmentDetails.class);
138138
} catch (IOException e) {
139-
throw new GeneratorException("Failed to parse CIS target details YAML " + cisTargetYAML + " due to " + e.getMessage());
139+
throw new GeneratorException("Failed to parse target environment details YAML " + targetEnvYAML + " due to " + e.getMessage());
140140
}
141141
}
142142

src/main/java/io/opentelemetry/contrib/generator/telemetry/jel/methods/LogSeverityGenerator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ private LogSeverityGenerator() {}
3636
/**
3737
* Provides a severity value from the specified severity list based on the frequency specified for each severity.
3838
* Fo eg: severityDistributionCount(["Normal", "Severe", "Warning"], [25, 5, 10])
39-
* In this case, the first 25 events generated will be of Normal severity, followed by 5 Severe events and
40-
* finally 10 Warning events. The cycle repeats itself in the same order.
39+
* In this case, the first 25 logs generated will be of Normal severity, followed by 5 Severe logs and
40+
* finally 10 Warning logs. The cycle repeats itself in the same order.
4141
* @param requestID internal ID for each running generator instance
4242
* @param logName name of the log in log definition
4343
* @param severity list severities
@@ -62,7 +62,7 @@ public static String severityDistributionCount(String requestID, String logName,
6262
/**
6363
* Provides a severity value from the specified severity list based on the percentages specified for each severity.
6464
* Fo eg: severityDistributionPercentage(["Normal", "Severe", "Warning"], [20, 70, 10])
65-
* In this case, if the payload count equals 10 then, 2 events will be of type Normal, 7 will be of type Severe and 1 will be of type Warning.
65+
* In this case, if the payload count equals 10 then, 2 logs will be of type Normal, 7 will be of type Severe and 1 will be of type Warning.
6666
* Note: The sum of frequency percentages in percentageValue should always be equal to 100.
6767
* @param requestID internal ID for each running generator instance
6868
* @param logName name of the log in log definition

src/main/java/io/opentelemetry/contrib/generator/telemetry/logs/LogGeneratorThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void run() {
9393
if (logGeneratorState.getTransportStorage() != null) {
9494
logGeneratorState.getTransportStorage().store(logDefinition.getId(), reportingEntity.getKey(), resourceLogs, responseStatus);
9595
}
96-
log.debug(requestID + ": Complete payload for entity: " + reportingEntity + " in event Definition" + logDefinition.getId() + ": " + resourceLogs);
96+
log.debug(requestID + ": Complete payload for entity: " + reportingEntity + " in log Definition" + logDefinition.getId() + ": " + resourceLogs);
9797
resourceLogsList.clear();
9898
}
9999
currentPayloadCount++;

src/main/java/io/opentelemetry/contrib/generator/telemetry/logs/dto/LogDefinition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public class LogDefinition {
4040
@JsonIgnore
4141
private String id;
4242

43-
public long validate(String requestID, Set<String> allEntityTypes, Integer globalPayloadFrequencySeconds, int eventIndex) {
44-
id = "log_by_OTel_DataGen_" + eventIndex;
43+
public long validate(String requestID, Set<String> allEntityTypes, Integer globalPayloadFrequencySeconds, int logIndex) {
44+
id = "log_by_ttg_" + logIndex;
4545
if (copyCount == null || copyCount < 1) {
4646
copyCount = 1;
4747
}

src/main/java/io/opentelemetry/contrib/generator/telemetry/logs/dto/Logs.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public void validate(String requestID, Set<String> allEntityTypes) {
4040
}
4141
maxPostSeconds = 0;
4242
totalPayloadCount = 0;
43-
int eventIndex = 0;
43+
int logIndex = 0;
4444

4545
for (LogDefinition eachLog: logs) {
46-
maxPostSeconds = Math.max(maxPostSeconds, eachLog.validate(requestID, allEntityTypes, globalPayloadFrequencySeconds, eventIndex));
46+
maxPostSeconds = Math.max(maxPostSeconds, eachLog.validate(requestID, allEntityTypes, globalPayloadFrequencySeconds, logIndex));
4747
totalPayloadCount += eachLog.getPayloadCount();
48-
eventIndex++;
48+
logIndex++;
4949
}
5050
}
5151
}

src/test/java/io/opentelemetry/contrib/generator/telemetry/TestAllGenerators.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public void validateStorageCounts() {
8888
"Mismatch in entity type counts for metric payloads");
8989
Assert.assertEquals(transportStorage.getStoredLogsPayloads().size(), 3,
9090
"Mismatch in entity type counts for log payloads");
91-
Assert.assertEquals(transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_0").size(), 3,
91+
Assert.assertEquals(transportStorage.getStoredLogsPayloads().get("log_by_ttg_0").size(), 3,
9292
"Mismatch in entity type counts for log payloads");
93-
Assert.assertEquals(transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_0").get("pod").size(), 20,
93+
Assert.assertEquals(transportStorage.getStoredLogsPayloads().get("log_by_ttg_0").get("pod").size(), 20,
9494
"Mismatch in entity type counts for log payloads");
9595
Assert.assertEquals(transportStorage.getStoredTracesPayloads().size(), 8,
9696
"Mismatch in entity type counts for trace payloads");

src/test/java/io/opentelemetry/contrib/generator/telemetry/TestAllGeneratorsWithRuntimeMods.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void validateFirstAddOperation() {
9797
String expectedPodIP = "133.29.54.90";
9898
ExportMetricsServiceRequest podMetricPayload = transportStorage.getStoredMetricsPayloads().get("pod::30::10").get(2);
9999
Assert.assertNotNull(podMetricPayload);
100-
ExportLogsServiceRequest podLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_1").get("pod").get(2);
100+
ExportLogsServiceRequest podLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_1").get("pod").get(2);
101101
Assert.assertNotNull(podLogPayload);
102102
Set<String> podIPsFromMetricPayloads = podMetricPayload.getResourceMetricsList().stream()
103103
.map(rm -> rm.getResource().getAttributesList())
@@ -117,7 +117,7 @@ public void validateFirstAddOperation() {
117117
String expectedNodeName = "quaG.node";
118118
ExportMetricsServiceRequest nodeMetricPayload = transportStorage.getStoredMetricsPayloads().get("node::30::10").get(4);
119119
Assert.assertNotNull(nodeMetricPayload);
120-
ExportLogsServiceRequest nodePodPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_0").get("node").get(4);
120+
ExportLogsServiceRequest nodePodPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_0").get("node").get(4);
121121
Assert.assertNotNull(nodePodPayload);
122122
Set<String> nodeNamesFromMetricPayloads = nodeMetricPayload.getResourceMetricsList().stream()
123123
.map(rm -> rm.getResource().getAttributesList())
@@ -137,7 +137,7 @@ public void validateFirstAddOperation() {
137137
String expectedMachineName = "idC.host";
138138
ExportMetricsServiceRequest machineMetricPayload = transportStorage.getStoredMetricsPayloads().get("machine::30::10").get(2);
139139
Assert.assertNotNull(machineMetricPayload);
140-
ExportLogsServiceRequest machineLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_3").get("machine").get(2);
140+
ExportLogsServiceRequest machineLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_3").get("machine").get(2);
141141
Assert.assertNotNull(machineLogPayload);
142142
Set<String> machineNamesFromMetricPayloads = machineMetricPayload.getResourceMetricsList().stream()
143143
.map(rm -> rm.getResource().getAttributesList())
@@ -160,7 +160,7 @@ public void validateFirstRemoveOperation() {
160160
String unexpectedMachineName = "icq.host";
161161
ExportMetricsServiceRequest machineMetricPayload = transportStorage.getStoredMetricsPayloads().get("machine::30::10").get(4);
162162
Assert.assertNotNull(machineMetricPayload);
163-
ExportLogsServiceRequest machineLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_3").get("machine").get(4);
163+
ExportLogsServiceRequest machineLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_3").get("machine").get(4);
164164
Assert.assertNotNull(machineLogPayload);
165165
Set<String> machineNamesFromMetricPayloads = machineMetricPayload.getResourceMetricsList().stream()
166166
.map(rm -> rm.getResource().getAttributesList())
@@ -180,7 +180,7 @@ public void validateFirstRemoveOperation() {
180180
String unexpectedContainerName = "tamt.container";
181181
ExportMetricsServiceRequest containerMetricPayload = transportStorage.getStoredMetricsPayloads().get("container::30::10").get(2);
182182
Assert.assertNotNull(containerMetricPayload);
183-
ExportLogsServiceRequest containerLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_2").get("container").get(2);
183+
ExportLogsServiceRequest containerLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_2").get("container").get(2);
184184
Assert.assertNotNull(containerLogPayload);
185185
Set<String> containerNamesFromMetricPayloads = machineMetricPayload.getResourceMetricsList().stream()
186186
.map(rm -> rm.getResource().getAttributesList())
@@ -204,7 +204,7 @@ public void validateFirstChurnOperation() {
204204
String unexpectedPodIP = "133.29.54.25";
205205
ExportMetricsServiceRequest podMetricPayload = transportStorage.getStoredMetricsPayloads().get("pod::30::10").get(4);
206206
Assert.assertNotNull(podMetricPayload);
207-
ExportLogsServiceRequest podLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_1").get("pod").get(4);
207+
ExportLogsServiceRequest podLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_1").get("pod").get(4);
208208
Assert.assertNotNull(podLogPayload);
209209
Set<String> podIPsFromMetricPayloads = podMetricPayload.getResourceMetricsList().stream()
210210
.map(rm -> rm.getResource().getAttributesList())
@@ -229,7 +229,7 @@ public void validateLastAddOperation() {
229229
String expectedPodIP = "133.29.54.160";
230230
ExportMetricsServiceRequest podMetricPayload = transportStorage.getStoredMetricsPayloads().get("pod::30::10").get(9);
231231
Assert.assertNotNull(podMetricPayload);
232-
ExportLogsServiceRequest podLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_1").get("pod").get(9);
232+
ExportLogsServiceRequest podLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_1").get("pod").get(9);
233233
Assert.assertNotNull(podLogPayload);
234234
Set<String> podIPsFromMetricPayloads = podMetricPayload.getResourceMetricsList().stream()
235235
.map(rm -> rm.getResource().getAttributesList())
@@ -249,7 +249,7 @@ public void validateLastAddOperation() {
249249
String expectedNodeName = "quaL.node";
250250
ExportMetricsServiceRequest nodeMetricPayload = transportStorage.getStoredMetricsPayloads().get("node::30::10").get(9);
251251
Assert.assertNotNull(nodeMetricPayload);
252-
ExportLogsServiceRequest nodeLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_0").get("node").get(9);
252+
ExportLogsServiceRequest nodeLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_0").get("node").get(9);
253253
Assert.assertNotNull(nodeLogPayload);
254254
Set<String> nodeNamesFromMetricPayloads = nodeMetricPayload.getResourceMetricsList().stream()
255255
.map(rm -> rm.getResource().getAttributesList())
@@ -269,7 +269,7 @@ public void validateLastAddOperation() {
269269
String expectedMachineName = "ie6.host";
270270
ExportMetricsServiceRequest machineMetricPayload = transportStorage.getStoredMetricsPayloads().get("machine::30::10").get(9);
271271
Assert.assertNotNull(machineMetricPayload);
272-
ExportLogsServiceRequest machineLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_3").get("machine").get(9);
272+
ExportLogsServiceRequest machineLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_3").get("machine").get(9);
273273
Assert.assertNotNull(machineLogPayload);
274274
Set<String> machineNamesFromMetricPayloads = machineMetricPayload.getResourceMetricsList().stream()
275275
.map(rm -> rm.getResource().getAttributesList())
@@ -292,7 +292,7 @@ public void validateLastRemoveOperation() {
292292
String unexpectedMachineName = "icF.host";
293293
ExportMetricsServiceRequest machineMetricPayload = transportStorage.getStoredMetricsPayloads().get("machine::30::10").get(9);
294294
Assert.assertNotNull(machineMetricPayload);
295-
ExportLogsServiceRequest machineLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_3").get("machine").get(9);
295+
ExportLogsServiceRequest machineLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_3").get("machine").get(9);
296296
Assert.assertNotNull(machineLogPayload);
297297
Set<String> machineNamesFromMetricPayloads = machineMetricPayload.getResourceMetricsList().stream()
298298
.map(rm -> rm.getResource().getAttributesList())
@@ -312,7 +312,7 @@ public void validateLastRemoveOperation() {
312312
String unexpectedContainerName = "tamA.container";
313313
ExportMetricsServiceRequest containerMetricPayload = transportStorage.getStoredMetricsPayloads().get("container::30::10").get(9);
314314
Assert.assertNotNull(containerMetricPayload);
315-
ExportLogsServiceRequest containerLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_2").get("container").get(9);
315+
ExportLogsServiceRequest containerLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_2").get("container").get(9);
316316
Assert.assertNotNull(containerLogPayload);
317317
Set<String> containerNamesFromMetricPayloads = machineMetricPayload.getResourceMetricsList().stream()
318318
.map(rm -> rm.getResource().getAttributesList())
@@ -336,7 +336,7 @@ public void validateLastChurnOperation() {
336336
String unexpectedPodIP = "133.29.54.50";
337337
ExportMetricsServiceRequest podMetricPayload = transportStorage.getStoredMetricsPayloads().get("pod::30::10").get(9);
338338
Assert.assertNotNull(podMetricPayload);
339-
ExportLogsServiceRequest podLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_OTel_DataGen_1").get("pod").get(9);
339+
ExportLogsServiceRequest podLogPayload = transportStorage.getStoredLogsPayloads().get("log_by_ttg_1").get("pod").get(9);
340340
Assert.assertNotNull(podLogPayload);
341341
Set<String> podIPsFromMetricPayloads = podMetricPayload.getResourceMetricsList().stream()
342342
.map(rm -> rm.getResource().getAttributesList())

src/test/java/io/opentelemetry/contrib/generator/telemetry/TestLogsGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ public void testLogsCounts() {
7171
int logEvents1_Count = NODE_COUNT * POST_COUNT_LOG_LOG_1;
7272
int logEvents2_Count = (MACHINE_COUNT + CONTAINER_COUNT_LOG) * POST_COUNT_LOG_LOG_2;
7373
Assert.assertEquals(testStore.getLogsPacketCount(), k8sEvents_Count + logEvents1_Count + logEvents2_Count,
74-
"Mismatch in events count");
74+
"Mismatch in logs count");
7575
}
7676
}

0 commit comments

Comments
 (0)