Skip to content

Commit 4809232

Browse files
committed
[#9584] Add LocalTraceRoot for DisableTrace
1 parent bb2f9de commit 4809232

File tree

13 files changed

+95
-108
lines changed

13 files changed

+95
-108
lines changed

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultBaseTraceFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle;
2626
import com.navercorp.pinpoint.profiler.context.active.ActiveTraceRepository;
2727
import com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState;
28+
import com.navercorp.pinpoint.profiler.context.id.LocalTraceRoot;
2829
import com.navercorp.pinpoint.profiler.context.id.TraceRoot;
2930
import com.navercorp.pinpoint.profiler.context.id.TraceRootFactory;
3031
import com.navercorp.pinpoint.profiler.context.recorder.RecorderFactory;
@@ -244,7 +245,7 @@ public Trace disableSampling() {
244245
}
245246

246247
private Trace newLocalTrace(long nextDisabledId) {
247-
final TraceRoot traceRoot = traceRootFactory.newDisableTraceRoot(nextDisabledId);
248+
final LocalTraceRoot traceRoot = traceRootFactory.newDisableTraceRoot(nextDisabledId);
248249
final SpanRecorder spanRecorder = recorderFactory.newDisableSpanRecorder(traceRoot);
249250
final long traceStartTime = traceRoot.getTraceStartTime();
250251
final long threadId = Thread.currentThread().getId();

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DisableAsyncChildTrace.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.navercorp.pinpoint.bootstrap.context.Trace;
2222
import com.navercorp.pinpoint.bootstrap.context.TraceId;
2323
import com.navercorp.pinpoint.bootstrap.context.scope.TraceScope;
24-
import com.navercorp.pinpoint.profiler.context.id.TraceRoot;
24+
import com.navercorp.pinpoint.profiler.context.id.LocalTraceRoot;
2525
import com.navercorp.pinpoint.profiler.context.scope.DefaultTraceScopePool;
2626

2727
import java.util.Objects;
@@ -33,10 +33,10 @@ public class DisableAsyncChildTrace implements Trace {
3333

3434
private DefaultTraceScopePool scopePool;
3535

36-
private final TraceRoot traceRoot;
36+
private final LocalTraceRoot traceRoot;
3737
private final LocalAsyncId localAsyncId;
3838

39-
public DisableAsyncChildTrace(final TraceRoot traceRoot, final LocalAsyncId localAsyncId) {
39+
public DisableAsyncChildTrace(final LocalTraceRoot traceRoot, final LocalAsyncId localAsyncId) {
4040
this.traceRoot = Objects.requireNonNull(traceRoot, "traceRoot");
4141
this.localAsyncId = Objects.requireNonNull(localAsyncId, "localAsyncId");
4242
}
@@ -71,7 +71,7 @@ public int getCallStackFrameId() {
7171
return 0;
7272
}
7373

74-
private TraceRoot getTraceRoot() {
74+
private LocalTraceRoot getTraceRoot() {
7575
return this.traceRoot;
7676
}
7777

@@ -87,7 +87,7 @@ public long getStartTime() {
8787

8888
@Override
8989
public TraceId getTraceId() {
90-
return getTraceRoot().getTraceId();
90+
return null;
9191
}
9292

9393
@Override

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DisableTrace.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import com.navercorp.pinpoint.bootstrap.context.TraceId;
2323
import com.navercorp.pinpoint.bootstrap.context.scope.TraceScope;
2424
import com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle;
25+
import com.navercorp.pinpoint.profiler.context.id.LocalTraceRoot;
2526
import com.navercorp.pinpoint.profiler.context.id.Shared;
26-
import com.navercorp.pinpoint.profiler.context.id.TraceRoot;
2727
import com.navercorp.pinpoint.profiler.context.scope.DefaultTraceScopePool;
2828
import com.navercorp.pinpoint.profiler.context.storage.UriStatStorage;
2929

@@ -39,15 +39,15 @@ public class DisableTrace implements Trace {
3939
public static final String UNSUPPORTED_OPERATION = "disable trace";
4040
public static final long DISABLE_TRACE_OBJECT_ID = -1;
4141

42-
private final TraceRoot traceRoot;
42+
private final LocalTraceRoot traceRoot;
4343
private final SpanRecorder spanRecorder;
4444
private DefaultTraceScopePool scopePool;
4545
private final ActiveTraceHandle handle;
4646
private final UriStatStorage uriStatStorage;
4747

4848
private boolean closed = false;
4949

50-
public DisableTrace(TraceRoot traceRoot, SpanRecorder spanRecorder, ActiveTraceHandle handle, UriStatStorage uriStatStorage) {
50+
public DisableTrace(LocalTraceRoot traceRoot, SpanRecorder spanRecorder, ActiveTraceHandle handle, UriStatStorage uriStatStorage) {
5151
this.traceRoot = Objects.requireNonNull(traceRoot, "traceRoot");
5252
this.spanRecorder = Objects.requireNonNull(spanRecorder, "spanRecorder");
5353

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/id/DefaultTraceRootFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public TraceRoot newTraceRoot(long transactionId) {
4545

4646

4747
@Override
48-
public TraceRoot newDisableTraceRoot(long transactionId) {
48+
public LocalTraceRoot newDisableTraceRoot(long transactionId) {
4949
final long startTime = traceStartTime();
5050
return TraceRoot.local(agentId, startTime, transactionId);
5151
}
Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,13 @@
11
package com.navercorp.pinpoint.profiler.context.id;
22

3-
import com.navercorp.pinpoint.bootstrap.context.TraceId;
4-
5-
import java.util.Objects;
6-
73
/**
84
* @author Woonduk Kang(emeroad)
95
*/
10-
public class LocalTraceRoot implements TraceRoot {
11-
12-
private final String agentId;
13-
private final long localTransactionId;
14-
15-
private final long traceStartTime;
16-
17-
private final Shared shared = new DefaultShared();
18-
19-
20-
public LocalTraceRoot(String agentId, long traceStartTime, long localTransactionId) {
21-
this.agentId = Objects.requireNonNull(agentId, "agentId");
22-
this.traceStartTime = traceStartTime;
23-
this.localTransactionId = localTransactionId;
24-
}
25-
26-
@Override
27-
public TraceId getTraceId() {
28-
return null;
29-
}
30-
31-
@Override
32-
public long getLocalTransactionId() {
33-
return localTransactionId;
34-
}
35-
36-
37-
@Override
38-
public long getTraceStartTime() {
39-
return traceStartTime;
40-
}
41-
6+
public interface LocalTraceRoot {
427

43-
@Override
44-
public Shared getShared() {
45-
return shared;
46-
}
8+
long getLocalTransactionId();
479

10+
long getTraceStartTime();
4811

49-
@Override
50-
public String toString() {
51-
return "DisableTraceRoot{" +
52-
", agentId='" + agentId + '\'' +
53-
", traceStartTime=" + traceStartTime +
54-
'}';
55-
}
12+
Shared getShared();
5613
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.navercorp.pinpoint.profiler.context.id;
2+
3+
import java.util.Objects;
4+
5+
/**
6+
* @author Woonduk Kang(emeroad)
7+
*/
8+
public class LocalTraceRootImpl implements LocalTraceRoot {
9+
10+
protected final String agentId;
11+
protected final long localTransactionId;
12+
13+
protected final long traceStartTime;
14+
15+
protected final Shared shared = new DefaultShared();
16+
17+
18+
LocalTraceRootImpl(String agentId, long traceStartTime, long localTransactionId) {
19+
this.agentId = Objects.requireNonNull(agentId, "agentId");
20+
this.traceStartTime = traceStartTime;
21+
this.localTransactionId = localTransactionId;
22+
}
23+
24+
public String getAgentId() {
25+
return agentId;
26+
}
27+
28+
@Override
29+
public long getLocalTransactionId() {
30+
return localTransactionId;
31+
}
32+
33+
@Override
34+
public long getTraceStartTime() {
35+
return traceStartTime;
36+
}
37+
38+
39+
@Override
40+
public Shared getShared() {
41+
return shared;
42+
}
43+
44+
45+
@Override
46+
public String toString() {
47+
return "DefaultLocalTraceRoot{" +
48+
", agentId='" + agentId + '\'' +
49+
", traceStartTime=" + traceStartTime +
50+
'}';
51+
}
52+
}

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/id/RemoteTraceRoot.java renamed to profiler/src/main/java/com/navercorp/pinpoint/profiler/context/id/RemoteTraceRootImpl.java

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,56 +23,27 @@
2323
/**
2424
* @author Woonduk Kang(emeroad)
2525
*/
26-
public class RemoteTraceRoot implements TraceRoot {
26+
public class RemoteTraceRootImpl extends LocalTraceRootImpl implements TraceRoot {
2727

2828
private final TraceId traceId;
29-
private final String agentId;
30-
private final long localTransactionId;
3129

32-
private final long traceStartTime;
33-
34-
private final Shared shared = new DefaultShared();
35-
36-
RemoteTraceRoot(TraceId traceId, String agentId, long traceStartTime, long localTransactionId) {
30+
RemoteTraceRootImpl(TraceId traceId, String agentId, long traceStartTime, long localTransactionId) {
31+
super(agentId, traceStartTime, localTransactionId);
3732
this.traceId = Objects.requireNonNull(traceId, "traceId");
38-
this.agentId = Objects.requireNonNull(agentId, "agentId");
39-
this.traceStartTime = traceStartTime;
40-
this.localTransactionId = localTransactionId;
4133
}
4234

4335
@Override
4436
public TraceId getTraceId() {
4537
return traceId;
4638
}
4739

48-
@Override
49-
public long getLocalTransactionId() {
50-
return localTransactionId;
51-
}
52-
53-
54-
@Override
55-
public long getTraceStartTime() {
56-
return traceStartTime;
57-
}
58-
59-
60-
61-
62-
@Override
63-
public Shared getShared() {
64-
return shared;
65-
}
66-
67-
68-
69-
7040
@Override
7141
public String toString() {
72-
return "DefaultTraceRoot{" +
42+
return "DefaultRemoteTraceRoot{" +
7343
"traceId=" + traceId +
7444
", agentId='" + agentId + '\'' +
7545
", traceStartTime=" + traceStartTime +
7646
'}';
7747
}
48+
7849
}

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/id/TraceRoot.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,25 @@
2323
/**
2424
* @author Woonduk Kang(emeroad)
2525
*/
26-
public interface TraceRoot {
26+
public interface TraceRoot extends LocalTraceRoot {
2727

2828
TraceId getTraceId();
2929

30+
@Override
3031
long getLocalTransactionId();
3132

33+
@Override
3234
long getTraceStartTime();
3335

36+
@Override
3437
Shared getShared();
3538

3639
static TraceRoot remote(TraceId traceId, String agentId, long traceStartTime, long localTransactionId) {
37-
return new RemoteTraceRoot(traceId, agentId, traceStartTime, localTransactionId);
40+
return new RemoteTraceRootImpl(traceId, agentId, traceStartTime, localTransactionId);
3841
}
3942

40-
static TraceRoot local(String agentId, long traceStartTime, long localTransactionId) {
43+
static LocalTraceRoot local(String agentId, long traceStartTime, long localTransactionId) {
4144
Objects.requireNonNull(agentId, "agentId");
42-
return new LocalTraceRoot(agentId, traceStartTime, localTransactionId);
45+
return new LocalTraceRootImpl(agentId, traceStartTime, localTransactionId);
4346
}
4447
}

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/id/TraceRootFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface TraceRootFactory {
2525

2626
TraceRoot newTraceRoot(long transactionId);
2727

28-
TraceRoot newDisableTraceRoot(long transactionId);
28+
LocalTraceRoot newDisableTraceRoot(long transactionId);
2929

3030
TraceRoot continueTraceRoot(TraceId traceId, long transactionId);
3131
}

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DefaultRecorderFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.navercorp.pinpoint.profiler.context.AsyncContextFactory;
2424
import com.navercorp.pinpoint.profiler.context.Span;
2525
import com.navercorp.pinpoint.profiler.context.errorhandler.IgnoreErrorHandler;
26+
import com.navercorp.pinpoint.profiler.context.id.LocalTraceRoot;
2627
import com.navercorp.pinpoint.profiler.context.id.TraceRoot;
2728
import com.navercorp.pinpoint.profiler.metadata.SqlMetaDataService;
2829
import com.navercorp.pinpoint.profiler.metadata.StringMetaDataService;
@@ -59,7 +60,7 @@ public SpanRecorder newTraceRootSpanRecorder(TraceRoot traceRoot, boolean sampli
5960
}
6061

6162
@Override
62-
public SpanRecorder newDisableSpanRecorder(TraceRoot traceRoot) {
63+
public SpanRecorder newDisableSpanRecorder(LocalTraceRoot traceRoot) {
6364
return new DisableSpanRecorder(traceRoot, errorHandler);
6465
}
6566

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/DisableSpanRecorder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@
2323
import com.navercorp.pinpoint.common.trace.ServiceType;
2424
import com.navercorp.pinpoint.common.util.DataType;
2525
import com.navercorp.pinpoint.profiler.context.errorhandler.IgnoreErrorHandler;
26+
import com.navercorp.pinpoint.profiler.context.id.LocalTraceRoot;
2627
import com.navercorp.pinpoint.profiler.context.id.Shared;
27-
import com.navercorp.pinpoint.profiler.context.id.TraceRoot;
2828

2929
import java.util.Objects;
3030

3131
/**
3232
* @author Woonduk Kang(emeroad)
3333
*/
3434
public class DisableSpanRecorder implements SpanRecorder {
35-
private final TraceRoot traceRoot;
35+
private final LocalTraceRoot traceRoot;
3636
private final IgnoreErrorHandler ignoreErrorHandler;
3737

38-
public DisableSpanRecorder(TraceRoot traceRoot, IgnoreErrorHandler ignoreErrorHandler) {
38+
public DisableSpanRecorder(LocalTraceRoot traceRoot, IgnoreErrorHandler ignoreErrorHandler) {
3939
this.traceRoot = Objects.requireNonNull(traceRoot, "traceRoot");
4040
this.ignoreErrorHandler = Objects.requireNonNull(ignoreErrorHandler, "ignoreErrorHandler");
4141
}

profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/RecorderFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.navercorp.pinpoint.bootstrap.context.AsyncState;
2020
import com.navercorp.pinpoint.bootstrap.context.SpanRecorder;
2121
import com.navercorp.pinpoint.profiler.context.Span;
22+
import com.navercorp.pinpoint.profiler.context.id.LocalTraceRoot;
2223
import com.navercorp.pinpoint.profiler.context.id.TraceRoot;
2324

2425
/**
@@ -30,7 +31,7 @@ public interface RecorderFactory {
3031

3132
SpanRecorder newTraceRootSpanRecorder(TraceRoot traceRoot, boolean sampling);
3233

33-
SpanRecorder newDisableSpanRecorder(TraceRoot traceRoot);
34+
SpanRecorder newDisableSpanRecorder(LocalTraceRoot traceRoot);
3435

3536
WrappedSpanEventRecorder newWrappedSpanEventRecorder(TraceRoot traceRoot);
3637

0 commit comments

Comments
 (0)