davsclaus commented on code in PR #27226:
URL: https://github.com/apache/camel/pull/27226#discussion_r4163317945
##########
components/camel-telemetry-dev/src/main/java/org/apache/camel/telemetrydev/DevSpanAdapter.java:
##########
@@ -29,8 +31,11 @@
public class DevSpanAdapter implements Span {
- private List<LogEntry> logEntries = new ArrayList<>();
- private final Map<String, String> tags = new HashMap<>();
+ // ConcurrentHashMap: tags (including isDone) are written from exchange
threads and read
+ // from the collector thread without explicit synchronization.
Review Comment:
Nit (optional, non-blocking): there's no dedicated collector thread. The
reader is the exchange thread that closes the last span
(`InMemoryCollector.get()` and later `DevTraceFormat`). Maybe:
```suggestion
// ConcurrentHashMap: tags (including isDone) are written from exchange
threads and read
// from other exchange threads when the trace is collected and formatted.
```
##########
components/camel-telemetry-dev/src/main/java/org/apache/camel/telemetrydev/DevSpanAdapter.java:
##########
@@ -58,7 +65,9 @@ public void setError(boolean error) {
@JsonAnySetter
@Override
public void setTag(String key, String value) {
- this.tags.put(key, value);
+ if (key != null && value != null) {
Review Comment:
Note for users of camel-telemetry-dev: tags with null values are no longer
kept, so the JSON trace output no longer contains `"key": null` entries. I
think that's fine (reads still return null), just pointing it out.
##########
components/camel-telemetry-dev/src/main/java/org/apache/camel/telemetrydev/DevSpanAdapter.java:
##########
@@ -71,11 +80,13 @@ public void log(Map<String, String> fields) {
}
public List<LogEntry> getLogEntries() {
- return new ArrayList<>(this.logEntries);
+ synchronized (logEntries) {
Review Comment:
Nit (optional, non-blocking): the `synchronized (logEntries)` block isn't
strictly needed here (same in `MockSpanAdapter.logEntries()`). `new
ArrayList<>(Collection)` calls `toArray()`, and the synchronized list already
locks that call. It does no harm, so fine to keep.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]