Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.2.x] Fix concurrent issue in observability #42962

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class OpenTracerBallerinaWrapper {
private static OpenTracerBallerinaWrapper instance = new OpenTracerBallerinaWrapper();
private TracersStore tracerStore;
private final boolean enabled;
private Map<Long, ObserverContext> observerContextList = new HashMap<>();
private ConcurrentMap<Long, ObserverContext> observerContextList = new ConcurrentHashMap<>();
private AtomicLong spanId = new AtomicLong();
private static final int SYSTEM_TRACE_INDICATOR = -1;

Expand Down Expand Up @@ -126,7 +126,10 @@ public boolean finishSpan(Strand strand, long spanId) {
if (!enabled) {
return false;
}
ObserverContext observerContext = observerContextList.get(spanId);
ObserverContext observerContext = null;
if (observerContextList.containsKey(spanId)) {
observerContext = observerContextList.get(spanId);
}
NipunaMadhushan marked this conversation as resolved.
Show resolved Hide resolved
if (observerContext != null) {
if (observerContext.isSystemSpan()) {
ObserveUtils.setObserverContextToCurrentFrame(strand, observerContext.getParent());
Expand All @@ -153,7 +156,10 @@ public boolean addTag(String tagKey, String tagValue, long spanId, Strand strand
if (!enabled) {
return false;
}
ObserverContext observerContext = observerContextList.get(spanId);
ObserverContext observerContext = null;
if (observerContextList.containsKey(spanId)) {
observerContext = observerContextList.get(spanId);
}
NipunaMadhushan marked this conversation as resolved.
Show resolved Hide resolved
if (spanId == -1) {
Optional<ObserverContext> observer = ObserveUtils.getObserverContextOfCurrentFrame(strand);
if (observer.isPresent()) {
Expand Down
Loading