Skip to content

Commit 6151b88

Browse files
committed
renamings
1 parent a3b8a93 commit 6151b88

File tree

8 files changed

+54
-54
lines changed

8 files changed

+54
-54
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ If your main question is only "Was this path hit at least once?", you can report
176176

177177
Processor flags:
178178

179-
- `processor.reportAllStacks`
180-
- `true` (default): report every captured event
181-
- `false`: report only first-seen stack hashes within the current dedup window
182-
- `processor.stackHashResetIntervalMillis`
179+
- `processor.enableStackDeduplication`
180+
- `true`: report only first-seen stack hashes within the current dedup window
181+
- `false` (default): report every captured event
182+
- `processor.dedupResetIntervalMillis`
183183
- Periodically clears remembered stack hashes to cap memory usage in long-running JVMs
184-
- In dedup mode (`reportAllStacks: false`): if missing, JCT logs a warning and uses `30000` (30 seconds)
184+
- In dedup mode (`enableStackDeduplication: true`): if missing, JCT logs a warning and uses `30000` (30 seconds)
185185

186186
Example: report only new stacks (good for high-traffic legacy systems)
187187

@@ -190,8 +190,8 @@ processor:
190190
fullQualifiedClass: de.marcelsauer.profiler.processor.udp.AsyncUdpStackProcessor
191191
udpHost: localhost
192192
udpPort: 9999
193-
reportAllStacks: false
194-
stackHashResetIntervalMillis: 300000
193+
enableStackDeduplication: true
194+
dedupResetIntervalMillis: 300000
195195
```
196196
197197
Example: report all stacks (full event stream)
@@ -200,7 +200,7 @@ Example: report all stacks (full event stream)
200200
processor:
201201
fullQualifiedClass: de.marcelsauer.profiler.processor.file.AsyncFileWritingStackProcessor
202202
stackFolderName: /tmp/stacks/
203-
reportAllStacks: true
203+
enableStackDeduplication: false
204204
```
205205
206206
## Message Format

doc/config-sample-file.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ classes:
1010
processor:
1111
fullQualifiedClass: de.marcelsauer.profiler.processor.file.AsyncFileWritingStackProcessor
1212
stackFolderName: /tmp/stacks/
13-
# true = report every captured stack event
14-
reportAllStacks: true
15-
# used in dedup mode (reportAllStacks: false) to reset remembered hashes
16-
stackHashResetIntervalMillis: 300000
13+
# true = enable stack deduplication (only report unique stacks)
14+
enableStackDeduplication: false
15+
# used in dedup mode (enableStackDeduplication: true) to reset remembered hashes
16+
dedupResetIntervalMillis: 300000

doc/config-sample-helloworld-file.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ classes:
77
processor:
88
fullQualifiedClass: de.marcelsauer.profiler.processor.file.AsyncFileWritingStackProcessor
99
stackFolderName: /tmp/stacks/
10-
reportAllStacks: true
11-
stackHashResetIntervalMillis: 300000
10+
enableStackDeduplication: false
11+
dedupResetIntervalMillis: 300000

doc/config-sample-helloworld-tcp.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ processor:
1111
tcpConnectTimeoutMillis: 1000
1212
tcpReconnectDelayMillis: 1000
1313
# true = report every captured stack event
14-
reportAllStacks: true
15-
# used in dedup mode (reportAllStacks: false)
16-
stackHashResetIntervalMillis: 300000
14+
enableStackDeduplication: false
15+
# used in dedup mode (enableStackDeduplication: true)
16+
dedupResetIntervalMillis: 300000
1717

doc/config-sample-helloworld-udp.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ processor:
99
udpHost: localhost
1010
udpPort: 9999
1111
# report only first-seen stacks in a time window
12-
reportAllStacks: false
12+
enableStackDeduplication: true
1313
# reset dedup hashes every 5 minutes to cap memory usage
14-
stackHashResetIntervalMillis: 300000
14+
dedupResetIntervalMillis: 300000

src/main/java/de/marcelsauer/profiler/config/Processor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ public class Processor {
99
public String fullQualifiedClass;
1010

1111
/**
12-
* true: report every captured stack event
13-
* false: report only first-seen stack hashes until periodic reset
12+
* true: report only first-seen stack hashes until periodic reset
13+
* false: report every captured stack event
1414
*/
15-
public boolean reportAllStacks = true;
15+
public boolean enableStackDeduplication = false;
1616

1717
/**
1818
* reset interval for remembered stack hashes in dedup mode to cap memory usage
1919
* null means not explicitly configured
2020
*/
21-
public Long stackHashResetIntervalMillis;
21+
public Long dedupResetIntervalMillis;
2222

2323
public String udpHost = "localhost";
2424
public int udpPort = 9999;

src/main/java/de/marcelsauer/profiler/processor/AbstractAsyncStackProcessor.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public abstract class AbstractAsyncStackProcessor implements StackProcessor {
2121
private static final String JCA_PROCESSOR_THREAD = "jca-processor-thread";
2222
private static final int CAPACITY = 100_000;
2323
private static final int DRAIN_BATCH_SIZE = 2048;
24-
private static final long DEFAULT_STACK_HASH_RESET_INTERVAL_MILLIS = 300_000L;
25-
private static final long DEFAULT_STACK_HASH_RESET_INTERVAL_IN_DEDUP_MODE_MILLIS = 30_000L;
24+
private static final long DEFAULT_DEDUP_RESET_INTERVAL_MILLIS = 300_000L;
25+
private static final long DEFAULT_DEDUP_RESET_INTERVAL_IN_DEDUP_MODE_MILLIS = 30_000L;
2626

2727
/**
2828
* counters
@@ -35,7 +35,7 @@ public abstract class AbstractAsyncStackProcessor implements StackProcessor {
3535
private final List<RecordingEvent> drainBuffer = new ArrayList<>(DRAIN_BATCH_SIZE);
3636
private final List<RecordingEvent> dedupBuffer = new ArrayList<>(DRAIN_BATCH_SIZE);
3737
private final Set<Integer> seenStackHashes = new HashSet<>();
38-
private long nextStackHashResetAtMillis = 0L;
38+
private long nextDedupResetAtMillis = 0L;
3939
private boolean warnedMissingDedupResetInterval;
4040

4141
/**
@@ -145,7 +145,7 @@ private Collection<RecordingEvent> drainNextBatch() {
145145
}
146146

147147
private Collection<RecordingEvent> filterReportableStacks(Collection<RecordingEvent> snapshot) {
148-
if (isReportAllStacks()) {
148+
if (!isStackDeduplicationEnabled()) {
149149
return snapshot;
150150
}
151151

@@ -162,44 +162,44 @@ private Collection<RecordingEvent> filterReportableStacks(Collection<RecordingEv
162162

163163
private void maybeResetSeenStackHashes() {
164164
long now = currentTimeMillis();
165-
if (now < nextStackHashResetAtMillis) {
165+
if (now < nextDedupResetAtMillis) {
166166
return;
167167
}
168168

169169
int clearedCount = seenStackHashes.size();
170170
seenStackHashes.clear();
171-
nextStackHashResetAtMillis = now + getStackHashResetIntervalMillis();
172-
logger.info(String.format("dedup cache purged: cleared %d stack hash(es), next reset in %dms", clearedCount, getStackHashResetIntervalMillis()));
171+
nextDedupResetAtMillis = now + getDedupResetIntervalMillis();
172+
logger.info(String.format("dedup cache purged: cleared %d stack hash(es), next reset in %dms", clearedCount, getDedupResetIntervalMillis()));
173173
}
174174

175175
private void resetDedupWindow() {
176176
seenStackHashes.clear();
177-
nextStackHashResetAtMillis = currentTimeMillis() + getStackHashResetIntervalMillis();
177+
nextDedupResetAtMillis = currentTimeMillis() + getDedupResetIntervalMillis();
178178
}
179179

180-
protected boolean isReportAllStacks() {
181-
return Config.get().processor.reportAllStacks;
180+
protected boolean isStackDeduplicationEnabled() {
181+
return Config.get().processor.enableStackDeduplication;
182182
}
183183

184-
protected long getStackHashResetIntervalMillis() {
185-
Long configuredInterval = getConfiguredStackHashResetIntervalMillis();
184+
protected long getDedupResetIntervalMillis() {
185+
Long configuredInterval = getConfiguredDedupResetIntervalMillis();
186186
if (configuredInterval != null) {
187187
return Math.max(1_000L, configuredInterval);
188188
}
189189

190-
if (!isReportAllStacks()) {
190+
if (isStackDeduplicationEnabled()) {
191191
if (!warnedMissingDedupResetInterval) {
192-
logger.warn("processor.stackHashResetIntervalMillis is not set while processor.reportAllStacks=false. using default 30000ms");
192+
logger.warn("processor.dedupResetIntervalMillis is not set while processor.enableStackDeduplication=true. using default 30000ms");
193193
warnedMissingDedupResetInterval = true;
194194
}
195-
return DEFAULT_STACK_HASH_RESET_INTERVAL_IN_DEDUP_MODE_MILLIS;
195+
return DEFAULT_DEDUP_RESET_INTERVAL_IN_DEDUP_MODE_MILLIS;
196196
}
197197

198-
return DEFAULT_STACK_HASH_RESET_INTERVAL_MILLIS;
198+
return DEFAULT_DEDUP_RESET_INTERVAL_MILLIS;
199199
}
200200

201-
protected Long getConfiguredStackHashResetIntervalMillis() {
202-
return Config.get().processor.stackHashResetIntervalMillis;
201+
protected Long getConfiguredDedupResetIntervalMillis() {
202+
return Config.get().processor.dedupResetIntervalMillis;
203203
}
204204

205205
protected long currentTimeMillis() {

src/test/java/de/marcelsauer/profiler/processor/AbstractAsyncStackProcessorTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void thatQueueIsDrainedInBatchesWithoutLosingEvents() {
4545

4646
@Test
4747
public void thatOnlyNewStacksAreReportedWhenDedupModeIsEnabled() {
48-
TestProcessor processor = new TestProcessor(false, 60_000L);
48+
TestProcessor processor = new TestProcessor(true, 60_000L);
4949
processor.start();
5050

5151
processor.process(newEvent("m1"));
@@ -60,7 +60,7 @@ public void thatOnlyNewStacksAreReportedWhenDedupModeIsEnabled() {
6060

6161
@Test
6262
public void thatSeenHashesAreResetAfterConfiguredInterval() throws InterruptedException {
63-
TestProcessor processor = new TestProcessor(false, 1000L);
63+
TestProcessor processor = new TestProcessor(true, 1000L);
6464
processor.start();
6565

6666
processor.process(newEvent("m1"));
@@ -77,7 +77,7 @@ public void thatSeenHashesAreResetAfterConfiguredInterval() throws InterruptedEx
7777

7878
@Test
7979
public void thatMissingDedupIntervalFallsBackToThirtySeconds() throws InterruptedException {
80-
TestProcessor processor = new TestProcessor(false, null);
80+
TestProcessor processor = new TestProcessor(true, null);
8181
processor.start();
8282

8383
processor.process(newEvent("m1"));
@@ -98,19 +98,19 @@ private RecordingEvent newEvent(String methodName) {
9898
}
9999

100100
private static class TestProcessor extends AbstractAsyncStackProcessor {
101-
private final boolean reportAllStacks;
102-
private final Long configuredStackHashResetIntervalMillis;
101+
private final boolean enableStackDeduplication;
102+
private final Long configuredDedupResetIntervalMillis;
103103
private long nowMillis;
104104
private final AtomicInteger processedCount = new AtomicInteger();
105105
private final List<Integer> batchSizes = Collections.synchronizedList(new ArrayList<Integer>());
106106

107107
TestProcessor() {
108-
this(true, 300_000L);
108+
this(false, 300_000L);
109109
}
110110

111-
TestProcessor(boolean reportAllStacks, Long stackHashResetIntervalMillis) {
112-
this.reportAllStacks = reportAllStacks;
113-
this.configuredStackHashResetIntervalMillis = stackHashResetIntervalMillis;
111+
TestProcessor(boolean enableStackDeduplication, Long dedupResetIntervalMillis) {
112+
this.enableStackDeduplication = enableStackDeduplication;
113+
this.configuredDedupResetIntervalMillis = dedupResetIntervalMillis;
114114
}
115115

116116
@Override
@@ -130,13 +130,13 @@ protected void doProcess(Collection<RecordingEvent> snapshots) {
130130
}
131131

132132
@Override
133-
protected boolean isReportAllStacks() {
134-
return reportAllStacks;
133+
protected boolean isStackDeduplicationEnabled() {
134+
return enableStackDeduplication;
135135
}
136136

137137
@Override
138-
protected Long getConfiguredStackHashResetIntervalMillis() {
139-
return configuredStackHashResetIntervalMillis;
138+
protected Long getConfiguredDedupResetIntervalMillis() {
139+
return configuredDedupResetIntervalMillis;
140140
}
141141

142142
@Override

0 commit comments

Comments
 (0)