Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
974e96bd
R
runtime
项目概览
dotNET Platform
/
runtime
12 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
974e96bd
编写于
1月 27, 2021
作者:
T
Tarek Mahmoud Sayed
提交者:
GitHub
1月 27, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Activity Status support (#47506)
* Activity Status support * Apply the agreed on behavior
上级
f638a75f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
105 addition
and
0 deletion
+105
-0
src/libraries/System.Diagnostics.DiagnosticSource/ref/System.Diagnostics.DiagnosticSourceActivity.cs
...Source/ref/System.Diagnostics.DiagnosticSourceActivity.cs
+9
-0
src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj
...sticSource/src/System.Diagnostics.DiagnosticSource.csproj
+1
-0
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs
...stics.DiagnosticSource/src/System/Diagnostics/Activity.cs
+29
-0
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/ActivityStatusCode.cs
...nosticSource/src/System/Diagnostics/ActivityStatusCode.cs
+26
-0
src/libraries/System.Diagnostics.DiagnosticSource/tests/ActivityTests.cs
...ystem.Diagnostics.DiagnosticSource/tests/ActivityTests.cs
+40
-0
未找到文件。
src/libraries/System.Diagnostics.DiagnosticSource/ref/System.Diagnostics.DiagnosticSourceActivity.cs
浏览文件 @
974e96bd
...
...
@@ -46,6 +46,8 @@ public partial class Activity : IDisposable
public
string
?
RootId
{
get
{
throw
null
;
}
}
public
System
.
Diagnostics
.
ActivitySpanId
SpanId
{
get
{
throw
null
;
}
}
public
System
.
DateTime
StartTimeUtc
{
get
{
throw
null
;
}
}
public
System
.
Diagnostics
.
ActivityStatusCode
Status
{
get
{
throw
null
;
}
}
public
string
?
StatusDescription
{
get
{
throw
null
;
}
}
public
System
.
Collections
.
Generic
.
IEnumerable
<
System
.
Collections
.
Generic
.
KeyValuePair
<
string
,
string
?>>
Tags
{
get
{
throw
null
;
}
}
public
System
.
Collections
.
Generic
.
IEnumerable
<
System
.
Collections
.
Generic
.
KeyValuePair
<
string
,
object
?>>
TagObjects
{
get
{
throw
null
;
}
}
public
System
.
Collections
.
Generic
.
IEnumerable
<
System
.
Diagnostics
.
ActivityEvent
>
Events
{
get
{
throw
null
;
}
}
...
...
@@ -65,6 +67,7 @@ public partial class Activity : IDisposable
public
System
.
Diagnostics
.
Activity
SetParentId
(
System
.
Diagnostics
.
ActivityTraceId
traceId
,
System
.
Diagnostics
.
ActivitySpanId
spanId
,
System
.
Diagnostics
.
ActivityTraceFlags
activityTraceFlags
=
System
.
Diagnostics
.
ActivityTraceFlags
.
None
)
{
throw
null
;
}
public
System
.
Diagnostics
.
Activity
SetParentId
(
string
parentId
)
{
throw
null
;
}
public
System
.
Diagnostics
.
Activity
SetStartTime
(
System
.
DateTime
startTimeUtc
)
{
throw
null
;
}
public
System
.
Diagnostics
.
Activity
SetStatus
(
System
.
Diagnostics
.
ActivityStatusCode
code
,
string
?
description
=
null
)
{
throw
null
;
}
public
System
.
Diagnostics
.
Activity
Start
()
{
throw
null
;
}
public
void
Stop
()
{
throw
null
;
}
public
void
Dispose
()
{
throw
null
;
}
...
...
@@ -104,6 +107,12 @@ public struct Enumerator : System.Collections.Generic.IEnumerator<System.Collect
void
System
.
Collections
.
IEnumerator
.
Reset
()
{
throw
null
;
}
}
}
public
enum
ActivityStatusCode
{
Unset
=
0
,
Ok
=
1
,
Error
=
2
}
public
enum
ActivityIdFormat
{
Unknown
=
0
,
...
...
src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj
浏览文件 @
974e96bd
...
...
@@ -34,6 +34,7 @@
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard1.1'">
<Compile Include="$(CommonPath)System\HexConverter.cs" Link="Common\System\HexConverter.cs" />
<Compile Include="System\Diagnostics\Activity.cs" />
<Compile Include="System\Diagnostics\ActivityStatusCode.cs" />
<Compile Include="System\Diagnostics\ActivityTagsCollection.cs" />
<Compile Include="System\Diagnostics\ActivityContext.cs" />
<Compile Include="System\Diagnostics\ActivityCreationOptions.cs" />
...
...
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs
浏览文件 @
974e96bd
...
...
@@ -82,6 +82,35 @@ public partial class Activity : IDisposable
private
LinkedList
<
ActivityEvent
>?
_events
;
private
Dictionary
<
string
,
object
>?
_customProperties
;
private
string
?
_displayName
;
private
ActivityStatusCode
_statusCode
;
private
string
?
_statusDescription
;
/// <summary>
/// Gets status code of the current activity object.
/// </summary>
public
ActivityStatusCode
Status
=>
_statusCode
;
/// <summary>
/// Gets the status descrition of the current activity object.
/// </summary>
public
string
?
StatusDescription
=>
_statusDescription
;
/// <summary>
/// Sets the status code and description on the current activity object.
/// </summary>
/// <param name="code">The status code</param>
/// <param name="description">The error status descrition</param>
/// <returns>'this' for convenient chaining</returns>
/// <remarks>
/// When passing code value different than ActivityStatusCode.Error, the Activity.StatusDescription will reset to null value.
/// The description paramater will be respected only when passing ActivityStatusCode.Error value.
/// </remarks>
public
Activity
SetStatus
(
ActivityStatusCode
code
,
string
?
description
=
null
)
{
_statusCode
=
code
;
_statusDescription
=
code
==
ActivityStatusCode
.
Error
?
description
:
null
;
return
this
;
}
/// <summary>
/// Gets the relationship between the Activity, its parents, and its children in a Trace.
...
...
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/ActivityStatusCode.cs
0 → 100644
浏览文件 @
974e96bd
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace
System.Diagnostics
{
/// <summary>
/// Define the status code of the Activity which indicate the status of the instrumented operation.
/// </summary>
public
enum
ActivityStatusCode
{
/// <summary>
/// Unset status code is the default value indicating the status code is not initialized.
/// </summary>
Unset
=
0
,
/// <summary>
/// Status code indicating the operation has been validated and completed successfully.
/// </summary>
Ok
=
1
,
/// <summary>
/// Status code indicating an error is encountered during the operation.
/// </summary>
Error
=
2
}
}
\ No newline at end of file
src/libraries/System.Diagnostics.DiagnosticSource/tests/ActivityTests.cs
浏览文件 @
974e96bd
...
...
@@ -1694,6 +1694,46 @@ public void StructEnumerator_TagsLinkedList()
Assert
.
True
(
method
.
ReturnType
.
IsValueType
);
}
[
Fact
]
public
void
TestStatus
()
{
Activity
a
=
new
Activity
(
"Status"
);
Assert
.
Equal
(
ActivityStatusCode
.
Unset
,
a
.
Status
);
Assert
.
Null
(
a
.
StatusDescription
);
a
.
SetStatus
(
ActivityStatusCode
.
Ok
);
// Default description null parameter
Assert
.
Equal
(
ActivityStatusCode
.
Ok
,
a
.
Status
);
Assert
.
Null
(
a
.
StatusDescription
);
a
.
SetStatus
(
ActivityStatusCode
.
Ok
,
null
);
// explicit description null parameter
Assert
.
Equal
(
ActivityStatusCode
.
Ok
,
a
.
Status
);
Assert
.
Null
(
a
.
StatusDescription
);
a
.
SetStatus
(
ActivityStatusCode
.
Ok
,
"Ignored Description"
);
// explicit non null description
Assert
.
Equal
(
ActivityStatusCode
.
Ok
,
a
.
Status
);
Assert
.
Null
(
a
.
StatusDescription
);
a
.
SetStatus
(
ActivityStatusCode
.
Error
);
// Default description null parameter
Assert
.
Equal
(
ActivityStatusCode
.
Error
,
a
.
Status
);
Assert
.
Null
(
a
.
StatusDescription
);
a
.
SetStatus
(
ActivityStatusCode
.
Error
,
"Error Code"
);
// Default description null parameter
Assert
.
Equal
(
ActivityStatusCode
.
Error
,
a
.
Status
);
Assert
.
Equal
(
"Error Code"
,
a
.
StatusDescription
);
a
.
SetStatus
(
ActivityStatusCode
.
Ok
,
"Description will reset to null"
);
Assert
.
Equal
(
ActivityStatusCode
.
Ok
,
a
.
Status
);
Assert
.
Null
(
a
.
StatusDescription
);
a
.
SetStatus
(
ActivityStatusCode
.
Error
,
"Another Error Code Description"
);
Assert
.
Equal
(
ActivityStatusCode
.
Error
,
a
.
Status
);
Assert
.
Equal
(
"Another Error Code Description"
,
a
.
StatusDescription
);
a
.
SetStatus
((
ActivityStatusCode
)
100
,
"Another Error Code Description"
);
Assert
.
Equal
((
ActivityStatusCode
)
100
,
a
.
Status
);
Assert
.
Null
(
a
.
StatusDescription
);
}
[
Fact
]
public
void
StructEnumerator_GenericLinkedList
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录