GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #480 from ieven/master · ysire/uavstack@1ed0a81

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/span
    • SpanFactory.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/span/SpanFactory.java‎

Copy file name to clipboardExpand all lines: com.creditease.uav.monitorframework.apm/src/main/java/com/creditease/uav/apm/invokechain/span/SpanFactory.java
+19-1Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ private static class TraceIDGen {
4949
private volatile AtomicLong count = new AtomicLong(0);
5050

5151
public TraceIDGen() {
52+
5253
ip = NetworkHelper.getLocalIP();
5354
}
5455

@@ -103,6 +104,8 @@ protected Map<String, Span> initialValue() {
103104
}
104105
};
105106

107+
public static final TransmittableThreadLocal<Span> mainThreadLocalTracker = new TransmittableThreadLocal<Span>();
108+
106109
/**
107110
* 通过一个父span来,创建一个span
108111
*
@@ -215,6 +218,10 @@ public Map<String, Span> getSpansFromContext() {
215218
*/
216219
public Span getSpanFromContext(String key) {
217220

221+
if (key.equals("main")) {
222+
return mainThreadLocalTracker.get();
223+
}
224+
218225
Map<String, Span> spanMap = threadLocalTracker.get();
219226

220227
return spanMap.get(key);
@@ -228,6 +235,12 @@ public Span getSpanFromContext(String key) {
228235
*/
229236
public Span getRemoveSpanFromContext(String key) {
230237

238+
if (key.equals("main")) {
239+
Span span = mainThreadLocalTracker.get();
240+
mainThreadLocalTracker.remove();
241+
return span;
242+
}
243+
231244
Map<String, Span> spanMap = threadLocalTracker.get();
232245

233246
return spanMap.remove(key);
@@ -240,6 +253,10 @@ public Span getRemoveSpanFromContext(String key) {
240253
*/
241254
public void setSpanToContext(String key, Span span) {
242255

256+
if (key.equals("main")) {
257+
mainThreadLocalTracker.set(span);
258+
return;
259+
}
243260
Map<String, Span> spanMap = threadLocalTracker.get();
244261

245262
spanMap.put(key, span);
@@ -250,7 +267,8 @@ public void setSpanToContext(String key, Span span) {
250267
*/
251268
public void removeCurrentThreadValue() {
252269

270+
mainThreadLocalTracker.removeCurrent();
253271
threadLocalTracker.removeCurrent();
254272
}
255273

256-
}
274+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.