wu-sheng commented on a change in pull request #6213:
URL: https://github.com/apache/skywalking/pull/6213#discussion_r558283357
##########
File path:
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
##########
@@ -72,11 +74,23 @@ private static AbstractTracerContext get() {
*/
public static String getGlobalTraceId() {
AbstractTracerContext segment = CONTEXT.get();
- if (segment == null) {
- return "N/A";
- } else {
- return segment.getReadablePrimaryTraceId();
- }
+ return Objects.nonNull(segment) ? segment.getReadablePrimaryTraceId()
: EMPTY_TRACE_CONTEXT_ID;
+ }
+
+ /**
+ * @return the current segment id if needEnhance. Otherwise, "N/A".
+ */
+ public static String getSegmentId() {
+ AbstractTracerContext segment = CONTEXT.get();
Review comment:
Please rename variable to `context`, seems the previous version is wrong.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]