Skip to content

Commit 920085e

Browse files
authored
improves tracing of fate operations (#5362)
Made three improvments to tracing of fate operations. Included the fate id in tracing of fate operations. The tracing data for fate operations would include the class name twice, changed this to `<class name>::<method name>`. Included the delay that isReady returns in the trace data.
1 parent 9186574 commit 920085e

File tree

1 file changed

+21
-4
lines changed
  • server/manager/src/main/java/org/apache/accumulo/manager/tableOps

1 file changed

+21
-4
lines changed

server/manager/src/main/java/org/apache/accumulo/manager/tableOps/TraceRepo.java

+21-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.apache.accumulo.manager.tableOps;
2020

21+
import org.apache.accumulo.core.fate.FateTxId;
2122
import org.apache.accumulo.core.fate.Repo;
2223
import org.apache.accumulo.core.trace.TraceUtil;
2324
import org.apache.accumulo.core.trace.thrift.TInfo;
@@ -30,6 +31,9 @@
3031

3132
public class TraceRepo<T> implements Repo<T> {
3233

34+
private static final String ID_ATTR = "accumulo.fate.id";
35+
private static final String DELAY_ATTR = "accumulo.fate.delay";
36+
3337
private static final long serialVersionUID = 1L;
3438

3539
TInfo tinfo;
@@ -40,11 +44,22 @@ public TraceRepo(Repo<T> repo) {
4044
tinfo = TraceUtil.traceInfo();
4145
}
4246

47+
private static void setAttributes(long tid, Span span) {
48+
if (span.isRecording()) {
49+
span.setAttribute(ID_ATTR, FateTxId.formatTid(tid));
50+
}
51+
}
52+
4353
@Override
4454
public long isReady(long tid, T environment) throws Exception {
45-
Span span = TraceUtil.startFateSpan(repo.getClass(), repo.getName(), tinfo);
55+
Span span = TraceUtil.startFateSpan(repo.getClass(), "isReady", tinfo);
4656
try (Scope scope = span.makeCurrent()) {
47-
return repo.isReady(tid, environment);
57+
setAttributes(tid, span);
58+
var delay = repo.isReady(tid, environment);
59+
if (span.isRecording()) {
60+
span.setAttribute(DELAY_ATTR, delay + "ms");
61+
}
62+
return delay;
4863
} catch (Exception e) {
4964
TraceUtil.setException(span, e, true);
5065
throw e;
@@ -55,8 +70,9 @@ public long isReady(long tid, T environment) throws Exception {
5570

5671
@Override
5772
public Repo<T> call(long tid, T environment) throws Exception {
58-
Span span = TraceUtil.startFateSpan(repo.getClass(), repo.getName(), tinfo);
73+
Span span = TraceUtil.startFateSpan(repo.getClass(), "call", tinfo);
5974
try (Scope scope = span.makeCurrent()) {
75+
setAttributes(tid, span);
6076
Repo<T> result = repo.call(tid, environment);
6177
if (result == null) {
6278
return null;
@@ -72,8 +88,9 @@ public Repo<T> call(long tid, T environment) throws Exception {
7288

7389
@Override
7490
public void undo(long tid, T environment) throws Exception {
75-
Span span = TraceUtil.startFateSpan(repo.getClass(), repo.getName(), tinfo);
91+
Span span = TraceUtil.startFateSpan(repo.getClass(), "undo", tinfo);
7692
try (Scope scope = span.makeCurrent()) {
93+
setAttributes(tid, span);
7794
repo.undo(tid, environment);
7895
} catch (Exception e) {
7996
TraceUtil.setException(span, e, true);

0 commit comments

Comments
 (0)