Skip to content

Commit eeba960

Browse files
authored
Add hasProductChangeEvent check to isEmpty (#8402)
When support for product change events was added, it was not included in the isEmpty method.
1 parent 69e0706 commit eeba960

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

telemetry/src/main/java/datadog/telemetry/EventSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ default boolean isEmpty() {
4949
&& !hasDependencyEvent()
5050
&& !hasMetricEvent()
5151
&& !hasDistributionSeriesEvent()
52-
&& !hasLogMessageEvent();
52+
&& !hasLogMessageEvent()
53+
&& !hasProductChangeEvent();
5354
}
5455

5556
final class Queued implements EventSource {
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package datadog.telemetry
2+
3+
import datadog.telemetry.api.DistributionSeries
4+
import datadog.telemetry.api.Integration
5+
import datadog.telemetry.api.LogMessage
6+
import datadog.telemetry.api.Metric
7+
import datadog.telemetry.dependency.Dependency
8+
import datadog.trace.api.ConfigOrigin
9+
import datadog.trace.api.ConfigSetting
10+
import datadog.trace.api.telemetry.ProductChange
11+
import datadog.trace.test.util.DDSpecification
12+
13+
import java.util.concurrent.LinkedBlockingQueue
14+
15+
class EventSourceTest extends DDSpecification{
16+
17+
void "test isEmpty when adding and clearing #eventType"() {
18+
setup:
19+
final eventQueues = [
20+
configChangeQueue : new LinkedBlockingQueue<ConfigSetting>(),
21+
integrationQueue : new LinkedBlockingQueue<Integration>(),
22+
dependencyQueue : new LinkedBlockingQueue<Dependency>(),
23+
metricQueue : new LinkedBlockingQueue<Metric>(),
24+
distributionSeriesQueue: new LinkedBlockingQueue<DistributionSeries>(),
25+
logMessageQueue : new LinkedBlockingQueue<LogMessage>(),
26+
productChanges : new LinkedBlockingQueue<ProductChange>()
27+
]
28+
29+
def eventSource = new EventSource.Queued(
30+
eventQueues.configChangeQueue,
31+
eventQueues.integrationQueue,
32+
eventQueues.dependencyQueue,
33+
eventQueues.metricQueue,
34+
eventQueues.distributionSeriesQueue,
35+
eventQueues.logMessageQueue,
36+
eventQueues.productChanges
37+
)
38+
39+
expect:
40+
eventSource.isEmpty()
41+
42+
when: "add an event to the queue"
43+
eventQueues[eventQueueName].add(eventInstance)
44+
45+
then: "eventSource should not be empty"
46+
!eventSource.isEmpty()
47+
48+
when: "clear the queue"
49+
eventQueues[eventQueueName].clear()
50+
51+
then: "eventSource should be empty again"
52+
eventSource.isEmpty()
53+
54+
where:
55+
eventType | eventQueueName | eventInstance
56+
"Config Change" | "configChangeQueue" | new ConfigSetting("key", "value", ConfigOrigin.ENV)
57+
"Integration" | "integrationQueue" | new Integration("name", true)
58+
"Dependency" | "dependencyQueue" | new Dependency("name", "version", "type", null)
59+
"Metric" | "metricQueue" | new Metric()
60+
"Distribution Series" | "distributionSeriesQueue" | new DistributionSeries()
61+
"Log Message" | "logMessageQueue" | new LogMessage()
62+
"Product Change" | "productChanges" | new ProductChange()
63+
}
64+
}

0 commit comments

Comments
 (0)