18
18
*/
19
19
package org .apache .accumulo .manager .tableOps ;
20
20
21
+ import org .apache .accumulo .core .fate .FateTxId ;
21
22
import org .apache .accumulo .core .fate .Repo ;
22
23
import org .apache .accumulo .core .trace .TraceUtil ;
23
24
import org .apache .accumulo .core .trace .thrift .TInfo ;
30
31
31
32
public class TraceRepo <T > implements Repo <T > {
32
33
34
+ private static final String ID_ATTR = "accumulo.fate.id" ;
35
+ private static final String DELAY_ATTR = "accumulo.fate.delay" ;
36
+
33
37
private static final long serialVersionUID = 1L ;
34
38
35
39
TInfo tinfo ;
@@ -40,11 +44,22 @@ public TraceRepo(Repo<T> repo) {
40
44
tinfo = TraceUtil .traceInfo ();
41
45
}
42
46
47
+ private static void setAttributes (long tid , Span span ) {
48
+ if (span .isRecording ()) {
49
+ span .setAttribute (ID_ATTR , FateTxId .formatTid (tid ));
50
+ }
51
+ }
52
+
43
53
@ Override
44
54
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 );
46
56
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 ;
48
63
} catch (Exception e ) {
49
64
TraceUtil .setException (span , e , true );
50
65
throw e ;
@@ -55,8 +70,9 @@ public long isReady(long tid, T environment) throws Exception {
55
70
56
71
@ Override
57
72
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 );
59
74
try (Scope scope = span .makeCurrent ()) {
75
+ setAttributes (tid , span );
60
76
Repo <T > result = repo .call (tid , environment );
61
77
if (result == null ) {
62
78
return null ;
@@ -72,8 +88,9 @@ public Repo<T> call(long tid, T environment) throws Exception {
72
88
73
89
@ Override
74
90
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 );
76
92
try (Scope scope = span .makeCurrent ()) {
93
+ setAttributes (tid , span );
77
94
repo .undo (tid , environment );
78
95
} catch (Exception e ) {
79
96
TraceUtil .setException (span , e , true );
0 commit comments