Commit 54b7c0b9 authored by Liuhaoyang's avatar Liuhaoyang

Refactor ContextSnapshot

parent 83c1f584
......@@ -28,12 +28,12 @@ namespace SkyWalking.Context
/// <summary>
/// Trace Segment Id of the parent trace segment
/// </summary>
private ID _traceSegmentId;
private readonly ID _traceSegmentId;
/// <summary>
/// span id of the parent span , in parent trace segment
/// </summary>
private int _spanId = -1;
private readonly int _spanId = -1;
private string _entryOperationName;
private string _parentOperationName;
......@@ -51,63 +51,45 @@ namespace SkyWalking.Context
public string EntryOperationName
{
get { return _entryOperationName; }
set { _entryOperationName = "#" + value; }
get => _entryOperationName;
set => _entryOperationName = "#" + value;
}
public string ParentOperationName
{
get { return _parentOperationName; }
set { _parentOperationName = "#" + value; }
get => _parentOperationName;
set => _parentOperationName = "#" + value;
}
public DistributedTraceId DistributedTraceId
{
get { return _primaryDistributedTraceId; }
}
public DistributedTraceId DistributedTraceId => _primaryDistributedTraceId;
public int EntryApplicationInstanceId
{
get { return _entryApplicationInstanceId; }
set { _entryApplicationInstanceId = value; }
get => _entryApplicationInstanceId;
set => _entryApplicationInstanceId = value;
}
public int SpanId
{
get { return _spanId; }
}
public int SpanId => _spanId;
public bool IsFromCurrent
{
get { return _traceSegmentId.Equals(ContextManager.Capture().TraceSegmentId); }
}
public bool IsFromCurrent => _traceSegmentId.Equals(ContextManager.Capture.TraceSegmentId);
public bool IsValid
{
get
{
return _traceSegmentId != null
&& _spanId > -1
&& _entryApplicationInstanceId != DictionaryUtil.NullValue
&& _primaryDistributedTraceId != null
&& string.IsNullOrEmpty(_entryOperationName)
&& string.IsNullOrEmpty(_parentOperationName);
}
}
public bool IsValid => _traceSegmentId != null
&& _spanId > -1
&& _entryApplicationInstanceId != DictionaryUtil.NullValue
&& _primaryDistributedTraceId != null
&& string.IsNullOrEmpty(_entryOperationName)
&& string.IsNullOrEmpty(_parentOperationName);
public ID TraceSegmentId
{
get { return _traceSegmentId; }
}
public ID TraceSegmentId => _traceSegmentId;
public int EntryOperationId
{
set { _entryOperationName = value + ""; }
set => _entryOperationName = value + "";
}
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