Commit 54b7c0b9 authored by Liuhaoyang's avatar Liuhaoyang

Refactor ContextSnapshot

parent 83c1f584
...@@ -28,12 +28,12 @@ namespace SkyWalking.Context ...@@ -28,12 +28,12 @@ namespace SkyWalking.Context
/// <summary> /// <summary>
/// Trace Segment Id of the parent trace segment /// Trace Segment Id of the parent trace segment
/// </summary> /// </summary>
private ID _traceSegmentId; private readonly ID _traceSegmentId;
/// <summary> /// <summary>
/// span id of the parent span , in parent trace segment /// span id of the parent span , in parent trace segment
/// </summary> /// </summary>
private int _spanId = -1; private readonly int _spanId = -1;
private string _entryOperationName; private string _entryOperationName;
private string _parentOperationName; private string _parentOperationName;
...@@ -51,63 +51,45 @@ namespace SkyWalking.Context ...@@ -51,63 +51,45 @@ namespace SkyWalking.Context
public string EntryOperationName public string EntryOperationName
{ {
get { return _entryOperationName; } get => _entryOperationName;
set { _entryOperationName = "#" + value; } set => _entryOperationName = "#" + value;
} }
public string ParentOperationName public string ParentOperationName
{ {
get { return _parentOperationName; } get => _parentOperationName;
set { _parentOperationName = "#" + value; } set => _parentOperationName = "#" + value;
} }
public DistributedTraceId DistributedTraceId public DistributedTraceId DistributedTraceId => _primaryDistributedTraceId;
{
get { return _primaryDistributedTraceId; }
}
public int EntryApplicationInstanceId public int EntryApplicationInstanceId
{ {
get { return _entryApplicationInstanceId; } get => _entryApplicationInstanceId;
set { _entryApplicationInstanceId = value; } set => _entryApplicationInstanceId = value;
} }
public int SpanId public int SpanId => _spanId;
{
get { return _spanId; }
}
public bool IsFromCurrent public bool IsFromCurrent => _traceSegmentId.Equals(ContextManager.Capture.TraceSegmentId);
{
get { return _traceSegmentId.Equals(ContextManager.Capture().TraceSegmentId); }
}
public bool IsValid public bool IsValid => _traceSegmentId != null
{ && _spanId > -1
get && _entryApplicationInstanceId != DictionaryUtil.NullValue
{ && _primaryDistributedTraceId != null
return _traceSegmentId != null && string.IsNullOrEmpty(_entryOperationName)
&& _spanId > -1 && string.IsNullOrEmpty(_parentOperationName);
&& _entryApplicationInstanceId != DictionaryUtil.NullValue
&& _primaryDistributedTraceId != null
&& string.IsNullOrEmpty(_entryOperationName)
&& string.IsNullOrEmpty(_parentOperationName);
}
}
public ID TraceSegmentId public ID TraceSegmentId => _traceSegmentId;
{
get { return _traceSegmentId; }
}
public int EntryOperationId public int EntryOperationId
{ {
set { _entryOperationName = value + ""; } set => _entryOperationName = value + "";
} }
public int ParentOperationId public int ParentOperationId
{ {
set { _parentOperationName = value + ""; } set => _parentOperationName = value + "";
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment