Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Fix concurrent modification on logs and tags #500

Merged

Conversation

pavolloffay
Copy link
Member

Fixes #334

Signed-off-by: Pavol Loffay ploffay@redhat.com

@ghost ghost assigned pavolloffay Jul 20, 2018
@ghost ghost added the review label Jul 20, 2018
JaegerSpan span = tracer.buildSpan("foo").start();
span.log("foo");
for (LogData log: span.getLogs()) {
span.log("foo2");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this test failing when ran against the current master?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so

@codecov
Copy link

codecov bot commented Jul 20, 2018

Codecov Report

Merging #500 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master    #500      +/-   ##
===========================================
- Coverage     88.21%   88.2%   -0.02%     
  Complexity      498     498              
===========================================
  Files            65      65              
  Lines          1859    1848      -11     
  Branches        242     239       -3     
===========================================
- Hits           1640    1630      -10     
  Misses          141     141              
+ Partials         78      77       -1
Impacted Files Coverage Δ Complexity Δ
...ain/java/io/jaegertracing/internal/JaegerSpan.java 93.45% <100%> (+0.53%) 47 <4> (+1) ⬆️
...c/main/java/io/jaegertracing/internal/LogData.java 100% <100%> (ø) 4 <1> (-1) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efd00c9...0ff892f. Read the comment docs.

@@ -61,7 +63,7 @@
this.startTimeMicroseconds = startTimeMicroseconds;
this.startTimeNanoTicks = startTimeNanoTicks;
this.computeDurationViaNanoTicks = computeDurationViaNanoTicks;
this.tags = new HashMap<String, Object>();
this.tags = new ConcurrentHashMap<String, Object>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could also remove the synchronized from the tags getter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be removed from other methods too. I will rather do it in a separate PR with more concurrent test and keep this clear. synchronized was not related to the concurrent modifications in this case.

@yurishkuro
Copy link
Member

I am not clear why copy on write is better than normal synchronization.

@bygui86
Copy link

bygui86 commented Jul 23, 2018

@pavolloffay I've just commented on the issue #334 with an update on my repo.
Thanks guys :)

@pavolloffay
Copy link
Member Author

thanks @bygui86, I will fix this anyway as it's a bug

@bygui86
Copy link

bygui86 commented Jul 23, 2018

Thanks a lot @pavolloffay :)
My way is just a workaround to wait for your fix :)

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
@pavolloffay
Copy link
Member Author

@yurishkuro @vprithvi I have changed PR to use only wrap the collection in getters.

In the next PR I will try to get rid of synchronizing on this with a test validating better performance.

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in getters make sense, what was the change to log methods about? Just refactoring?

@@ -23,15 +23,9 @@
private final String message;
private final Map<String, ?> fields;

LogData(long time, String message) {
LogData(long time, Map<String, ?> fields, String message) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would have preferred the message parameter to come before fields

return log(timestampMicroseconds, null, event);
}

private JaegerSpan log(long timestampMicroseconds, Map<String, ?> fields, String event) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would have preferred the message parameter to come before fields

@pavolloffay
Copy link
Member Author

Just refactoring, I think the current version is cleaner - only one method for processing logs. I will update PR to change the parameter order and merge if nobody objects

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants