
com.undefinedlabs.scope.ScopeSpanContainer Maven / Gradle / Ivy
package com.undefinedlabs.scope;
import io.opentracing.Scope;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
public class ScopeSpanContainer {
private final io.opentracing.Span span;
private final Scope scope;
private ConcurrentMap propagationTagsMap;
private Long timestamp;
private boolean hasSourceConflicts;
public ScopeSpanContainer(final io.opentracing.Span span, final Scope scope) {
this.span = span;
this.scope = scope;
propagationTagsMap = null;
timestamp = null;
hasSourceConflicts = false;
}
public io.opentracing.Span getSpan() {
return span;
}
public Scope getScope() {
return scope;
}
public void setPropagationTimestamp(final long timestamp) {
this.timestamp = timestamp;
}
public Long getPropagationTimestamp() {
return timestamp;
}
public boolean hasSourceConflicts() {
return hasSourceConflicts;
}
public void setHasSourceConflicts(final boolean hasSourceConflicts) {
this.hasSourceConflicts = hasSourceConflicts;
}
public void putPropagationTag(final String key, final Object value) {
if (propagationTagsMap == null) {
propagationTagsMap = new ConcurrentHashMap<>();
}
propagationTagsMap.put(key, value);
}
public Object getPropagationTag(final String key) {
if (propagationTagsMap == null) {
return null;
}
return propagationTagsMap.get(key);
}
public void removePropagationTag(final String key) {
if (propagationTagsMap == null) {
return;
}
propagationTagsMap.remove(key);
}
protected Map getPropagationTagsMap() {
return propagationTagsMap;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final ScopeSpanContainer that = (ScopeSpanContainer) o;
return hasSourceConflicts == that.hasSourceConflicts
&& Objects.equals(span, that.span)
&& Objects.equals(scope, that.scope)
&& Objects.equals(propagationTagsMap, that.propagationTagsMap)
&& Objects.equals(timestamp, that.timestamp);
}
@Override
public int hashCode() {
return Objects.hash(span, scope, propagationTagsMap, timestamp, hasSourceConflicts);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("ScopeSpanContainer{");
sb.append("span=").append(span);
sb.append(", scope=").append(scope);
sb.append(", propagationTagsMap=").append(propagationTagsMap);
sb.append(", timestamp=").append(timestamp);
sb.append(", hasSourceConflicts=").append(hasSourceConflicts);
sb.append('}');
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy