提交 96554c82 编写于 作者: 彭伟 提交者: Lemon

Feature (#189)

* Add xml comment

* fix: LocalSegment relationship error when use Task.WhenAll
上级 f67a8682
<Project>
<Project>
<Import Project="sign.props" />
<Import Project="version.props" />
<PropertyGroup>
......@@ -15,6 +15,8 @@
<GenerateAssemblyCompanyAttribute>True</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>True</GenerateAssemblyProductAttribute>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
</Project>
\ No newline at end of file
</Project>
/*
/*
* Licensed to the SkyAPM under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
......@@ -42,8 +42,8 @@ namespace SkyApm.Tracing.Segments
public SpanLayer SpanLayer { get; set; }
/// <summary>Limiting values. Please see <see cref="Components" /> or see <seealso href="https://github.com/apache/incubator-skywalking/blob/master/oap-server/server-starter/src/main/resources/component-libraries.yml"/></summary>
public StringOrIntValue Component { get; set; }
public bool IsError { get; set; }
public TagCollection Tags { get; } = new TagCollection();
......@@ -187,4 +187,4 @@ namespace SkyApm.Tracing.Segments
return new LogEvent("stack", value);
}
}
}
\ No newline at end of file
}
/*
/*
* Licensed to the SkyAPM under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
......@@ -16,55 +16,34 @@
*
*/
using System.Collections.Concurrent;
using System.Threading;
using SkyApm.Tracing.Segments;
using System.Runtime.CompilerServices;
using System.Threading;
namespace SkyApm.Tracing
{
public class LocalSegmentContextAccessor : ILocalSegmentContextAccessor
{
private readonly AsyncLocal<ConcurrentStack<SegmentContext>> _segmentContextStack =
new AsyncLocal<ConcurrentStack<SegmentContext>>();
private readonly ConditionalWeakTable<SegmentContext, SegmentContext> _parent = new ConditionalWeakTable<SegmentContext, SegmentContext>();
private readonly AsyncLocal<SegmentContext> _segmentContext = new AsyncLocal<SegmentContext>();
public SegmentContext Context
{
get
{
var stack = _segmentContextStack.Value;
if (stack == null)
{
return null;
}
stack.TryPeek(out var context);
return context;
}
get => _segmentContext.Value;
set
{
var stack = _segmentContextStack.Value;
if (stack == null)
var current = _segmentContext.Value;
if (value == null)
{
if (value == null) return;
stack = new ConcurrentStack<SegmentContext>();
stack.Push(value);
_segmentContextStack.Value = stack;
if (_parent.TryGetValue(current, out var parent))
_segmentContext.Value = parent;
}
else
{
if (value == null)
{
stack.TryPop(out _);
if (stack.IsEmpty)
{
_segmentContextStack.Value = null;
}
}
else
{
stack.Push(value);
}
_parent.Add(value, current);
_segmentContext.Value = value;
}
}
}
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册