|
@@
-1,211
+1,238
|
|
1
|
using System;
|
|
1
|
using System;
|
|
2
|
using System.Collections.Generic;
|
|
2
|
using System.Collections.Generic;
|
|
3
|
using System.Linq;
|
|
3
|
using System.Linq;
|
|
4
|
using System.Text;
|
|
4
|
using System.Text;
|
|
5
|
using System.Threading;
|
|
5
|
using System.Threading;
|
|
6
|
using System.Threading.Tasks;
|
|
6
|
using System.Threading.Tasks;
|
|
7
|
|
|
7
|
|
|
8
|
namespace Implab.Diagnostics {
|
|
8
|
namespace Implab.Diagnostics {
|
|
9
|
/// <summary>
|
|
9
|
/// <summary>
|
|
10
|
/// ΠΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ, ΠΏΡΠΈΠ²ΡΠ·ΡΠ²Π°Π΅ΡΡΡ ΠΊ ΠΏΠΎΡΠΎΠΊΡ ΠΈ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ Π² ΡΠ΅Π±Π΅ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎ ΡΡΠ΅ΠΊΠ΅ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΈΡ
ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΉ.
|
|
10
|
/// ΠΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ, ΠΏΡΠΈΠ²ΡΠ·ΡΠ²Π°Π΅ΡΡΡ ΠΊ ΠΏΠΎΡΠΎΠΊΡ ΠΈ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ Π² ΡΠ΅Π±Π΅ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎ ΡΡΠ΅ΠΊΠ΅ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΈΡ
ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΉ.
|
|
11
|
/// </summary>
|
|
11
|
/// </summary>
|
|
12
|
/// <remarks>
|
|
12
|
/// <remarks>
|
|
13
|
/// ΠΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΏΠ΅ΡΠ΅Π΄Π°Π΅ΡΡΡ ΡΠ»ΡΡΠ°ΡΠ΅Π»ΡΠΌ ΡΠΎΠ±ΡΡΠΈΠΉ Π΄Π»Ρ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½ΠΈΡ ΠΌΠ΅ΡΡΠ°, Π³Π΄Π΅ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΎ ΡΠΎΠ±ΡΡΠΈΠ΅.
|
|
13
|
/// ΠΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΏΠ΅ΡΠ΅Π΄Π°Π΅ΡΡΡ ΡΠ»ΡΡΠ°ΡΠ΅Π»ΡΠΌ ΡΠΎΠ±ΡΡΠΈΠΉ Π΄Π»Ρ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½ΠΈΡ ΠΌΠ΅ΡΡΠ°, Π³Π΄Π΅ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΎ ΡΠΎΠ±ΡΡΠΈΠ΅.
|
|
14
|
/// </remarks>
|
|
14
|
/// </remarks>
|
|
15
|
public class TraceContext {
|
|
15
|
public class TraceContext {
|
|
16
|
LogicalOperation m_currentOperation;
|
|
16
|
LogicalOperation m_currentOperation;
|
|
17
|
readonly LogicalOperation m_bound;
|
|
17
|
readonly LogicalOperation m_bound;
|
|
18
|
readonly int m_threadId;
|
|
18
|
readonly int m_threadId;
|
|
19
|
|
|
19
|
|
|
20
|
[ThreadStatic]
|
|
20
|
[ThreadStatic]
|
|
21
|
static TraceContext _current;
|
|
21
|
static TraceContext _current;
|
|
22
|
|
|
22
|
|
|
23
|
/// <summary>
|
|
23
|
/// <summary>
|
|
24
|
/// Π’Π΅ΠΊΡΡΠΈΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ Π΄Π»Ρ ΠΏΠΎΡΠΎΠΊΠ°, ΡΠΎΠ·Π΄Π°Π΅ΡΡΡ Π°ΡΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ ΠΏΡΠΈ ΠΏΠ΅ΡΠ²ΠΎΠΌ ΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΠΈ.
|
|
24
|
/// Π’Π΅ΠΊΡΡΠΈΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ Π΄Π»Ρ ΠΏΠΎΡΠΎΠΊΠ°, ΡΠΎΠ·Π΄Π°Π΅ΡΡΡ Π°ΡΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ ΠΏΡΠΈ ΠΏΠ΅ΡΠ²ΠΎΠΌ ΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΠΈ.
|
|
25
|
/// </summary>
|
|
25
|
/// </summary>
|
|
26
|
public static TraceContext Current {
|
|
26
|
public static TraceContext Current {
|
|
27
|
get {
|
|
27
|
get {
|
|
28
|
if (_current == null) {
|
|
28
|
if (_current == null) {
|
|
29
|
_current = new TraceContext();
|
|
29
|
_current = new TraceContext();
|
|
30
|
_current.LogEvent(TraceEventType.Created,"[{0}]", _current.ThreadId);
|
|
30
|
_current.LogEvent(TraceEventType.Created,"[{0}]", _current.ThreadId);
|
|
31
|
}
|
|
31
|
}
|
|
32
|
return _current;
|
|
32
|
return _current;
|
|
33
|
}
|
|
33
|
}
|
|
34
|
}
|
|
34
|
}
|
|
35
|
|
|
35
|
|
|
36
|
TraceContext(TraceContext context)
|
|
36
|
TraceContext(TraceContext context)
|
|
37
|
: this(context, false) {
|
|
37
|
: this(context, false) {
|
|
38
|
}
|
|
38
|
}
|
|
39
|
|
|
39
|
|
|
40
|
TraceContext(TraceContext context, bool attach) {
|
|
40
|
TraceContext(TraceContext context, bool attach) {
|
|
41
|
if (context == null)
|
|
41
|
if (context == null)
|
|
42
|
throw new ArgumentNullException("context");
|
|
42
|
throw new ArgumentNullException("context");
|
|
43
|
|
|
43
|
|
|
44
|
m_currentOperation = context.CurrentOperation;
|
|
44
|
m_currentOperation = context.CurrentOperation;
|
|
45
|
m_bound = attach ? context.BoundOperation : context.CurrentOperation;
|
|
45
|
m_bound = attach ? context.BoundOperation : context.CurrentOperation;
|
|
46
|
m_threadId = Thread.CurrentThread.ManagedThreadId;
|
|
46
|
m_threadId = Thread.CurrentThread.ManagedThreadId;
|
|
47
|
}
|
|
47
|
}
|
|
48
|
|
|
48
|
|
|
49
|
TraceContext() {
|
|
49
|
TraceContext() {
|
|
50
|
m_currentOperation = new LogicalOperation();
|
|
50
|
m_currentOperation = new LogicalOperation();
|
|
51
|
m_bound = m_currentOperation;
|
|
51
|
m_bound = m_currentOperation;
|
|
52
|
m_threadId = Thread.CurrentThread.ManagedThreadId;
|
|
52
|
m_threadId = Thread.CurrentThread.ManagedThreadId;
|
|
53
|
}
|
|
53
|
}
|
|
54
|
|
|
54
|
|
|
55
|
/// <summary>
|
|
55
|
/// <summary>
|
|
56
|
/// ΠΡΠΈ Π½Π΅ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌΠΎΡΡΠΈ ΠΊΠΎΠΏΠΈΡΡΠ΅Ρ ΡΠΎΡΡΠΎΡΠ½ΠΈΠ΅ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΡΡΠ°ΡΡΠΈΠ²ΡΠΎΠ²ΠΊΠΈ Π² ΡΠ΅ΠΊΡΡΠΈΠΉ ΠΏΠΎΡΠΎΠΊ.
|
|
56
|
/// ΠΡΠΈ Π½Π΅ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌΠΎΡΡΠΈ ΠΊΠΎΠΏΠΈΡΡΠ΅Ρ ΡΠΎΡΡΠΎΡΠ½ΠΈΠ΅ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΡΡΠ°ΡΡΠΈΠ²ΡΠΎΠ²ΠΊΠΈ Π² ΡΠ΅ΠΊΡΡΠΈΠΉ ΠΏΠΎΡΠΎΠΊ.
|
|
57
|
/// </summary>
|
|
57
|
/// </summary>
|
|
58
|
/// <param name="from">ΠΡΡ
ΠΎΠ΄Π½ΡΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΠ΅ΡΠ΅Π΄Π°Π΅ΡΡΡ.</param>
|
|
58
|
/// <param name="from">ΠΡΡ
ΠΎΠ΄Π½ΡΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΠ΅ΡΠ΅Π΄Π°Π΅ΡΡΡ.</param>
|
|
59
|
/// <remarks>
|
|
59
|
/// <remarks>
|
|
60
|
/// <para>
|
|
60
|
/// <para>
|
|
61
|
/// ΠΠΎΠΏΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΏΡΠΎΠΈΡΡ
ΠΎΠ΄ΠΈΡ Π·Π° ΡΡΠ΅Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ Π½ΠΎΠ²ΠΎΠ³ΠΎ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΈ Π·Π°ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ΠΌ Π΅Π³ΠΎ
|
|
61
|
/// ΠΠΎΠΏΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΏΡΠΎΠΈΡΡ
ΠΎΠ΄ΠΈΡ Π·Π° ΡΡΠ΅Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ Π½ΠΎΠ²ΠΎΠ³ΠΎ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΈ Π·Π°ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ΠΌ Π΅Π³ΠΎ
|
|
62
|
/// ΡΠΎΡΡΠΎΡΠ½ΠΈΡ ΠΈΠ· ΠΏΠ΅ΡΠ΅Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ°. ΠΡΠΈ ΡΡΠΎΠΌ ΠΊΠΎΠΏΠΈΡΡΠ΅ΡΡΡ ΡΡΠ΅ΠΊ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΉ, ΠΎΠ΄Π½Π°ΠΊΠΎ Π² Π½ΠΎΠ²ΠΎΠΌ
|
|
62
|
/// ΡΠΎΡΡΠΎΡΠ½ΠΈΡ ΠΈΠ· ΠΏΠ΅ΡΠ΅Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ°. ΠΡΠΈ ΡΡΠΎΠΌ ΠΊΠΎΠΏΠΈΡΡΠ΅ΡΡΡ ΡΡΠ΅ΠΊ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΉ, ΠΎΠ΄Π½Π°ΠΊΠΎ Π² Π½ΠΎΠ²ΠΎΠΌ
|
|
63
|
/// ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅ ΡΠ°Π½Π΅Π΅ Π½Π°ΡΠ°ΡΡΠ΅ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΈΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ Π½Π΅ ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ Π·Π°Π²Π΅ΡΡΠ΅Π½Ρ.
|
|
63
|
/// ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅ ΡΠ°Π½Π΅Π΅ Π½Π°ΡΠ°ΡΡΠ΅ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΈΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ Π½Π΅ ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ Π·Π°Π²Π΅ΡΡΠ΅Π½Ρ.
|
|
64
|
/// </para>
|
|
64
|
/// </para>
|
|
65
|
/// <para>
|
|
65
|
/// <para>
|
|
66
|
/// ΠΡΠ»ΠΈ ΠΏΠ΅ΡΠ΅Π΄Π°ΡΠ° ΡΠΎΡΡΠΎΡΠ½ΠΈΡ ΡΠΎΡΡΠΎΡΠ»Π°ΡΡ, ΡΠΎ Π²ΡΠ·ΡΠ²Π°Π΅ΡΡΡ ΡΠΎΠ±ΡΡΠΈΠ΅ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ <see cref="TraceEventType.Fork"/>.
|
|
66
|
/// ΠΡΠ»ΠΈ ΠΏΠ΅ΡΠ΅Π΄Π°ΡΠ° ΡΠΎΡΡΠΎΡΠ½ΠΈΡ ΡΠΎΡΡΠΎΡΠ»Π°ΡΡ, ΡΠΎ Π²ΡΠ·ΡΠ²Π°Π΅ΡΡΡ ΡΠΎΠ±ΡΡΠΈΠ΅ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ <see cref="TraceEventType.Fork"/>.
|
|
67
|
/// </para>
|
|
67
|
/// </para>
|
|
68
|
/// </remarks>
|
|
68
|
/// </remarks>
|
|
69
|
public static void Fork(TraceContext from) {
|
|
69
|
public static void Fork(TraceContext from) {
|
|
70
|
if (_current == from)
|
|
70
|
if (_current == from)
|
|
71
|
return;
|
|
71
|
return;
|
|
72
|
if (from != null) {
|
|
72
|
if (from != null) {
|
|
73
|
var context = new TraceContext(from);
|
|
73
|
var context = new TraceContext(from);
|
|
74
|
context.LogEvent(TraceEventType.Fork, "[{0}]-->[{1}]",from.ThreadId, context.ThreadId);
|
|
74
|
context.LogEvent(TraceEventType.Fork, "[{0}]-->[{1}]",from.ThreadId, context.ThreadId);
|
|
75
|
_current = context;
|
|
75
|
_current = context;
|
|
76
|
} else {
|
|
76
|
} else {
|
|
77
|
_current = new TraceContext();
|
|
77
|
_current = new TraceContext();
|
|
78
|
}
|
|
78
|
}
|
|
79
|
}
|
|
79
|
}
|
|
80
|
|
|
80
|
|
|
81
|
/// <summary>
|
|
81
|
/// <summary>
|
|
82
|
/// ΠΠ°Π΄Π°Π΅Ρ ΡΠ΅ΠΊΡΡΠ΅ΠΌΡ ΠΏΠΎΡΠΎΠΊΡ ΡΠΊΠ°Π·Π°Π½Π½ΡΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ, ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΠΏΠΎΡΠΎΠΊ ΠΌΠΎΠΆΠ΅Ρ Π·Π°ΠΊΠ°Π½ΡΠΈΠ²Π°ΡΡ ΡΠ°Π½Π΅Π΅ Π½Π°ΡΠ°ΡΡΠ΅
|
|
82
|
/// ΠΠ°Π΄Π°Π΅Ρ ΡΠ΅ΠΊΡΡΠ΅ΠΌΡ ΠΏΠΎΡΠΎΠΊΡ ΡΠΊΠ°Π·Π°Π½Π½ΡΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ, ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΠΏΠΎΡΠΎΠΊ ΠΌΠΎΠΆΠ΅Ρ Π·Π°ΠΊΠ°Π½ΡΠΈΠ²Π°ΡΡ ΡΠ°Π½Π΅Π΅ Π½Π°ΡΠ°ΡΡΠ΅
|
|
83
|
/// Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΈΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ Π² ΡΠΊΠ°Π·Π°Π½Π½ΠΎΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅.
|
|
83
|
/// Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΈΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ Π² ΡΠΊΠ°Π·Π°Π½Π½ΠΎΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅.
|
|
84
|
/// </summary>
|
|
84
|
/// </summary>
|
|
85
|
/// <param name="source"></param>
|
|
85
|
/// <param name="source"></param>
|
|
86
|
public static void Attach(TraceContext source) {
|
|
86
|
public static void Attach(TraceContext source) {
|
|
87
|
if (_current == source)
|
|
87
|
if (_current == source)
|
|
88
|
return;
|
|
88
|
return;
|
|
89
|
if (source != null) {
|
|
89
|
if (source != null) {
|
|
90
|
var context = new TraceContext(source, true);
|
|
90
|
var context = new TraceContext(source, true);
|
|
91
|
context.LogEvent(TraceEventType.Attach, "[{0}]-->[{1}]", source.ThreadId, context.ThreadId);
|
|
91
|
context.LogEvent(TraceEventType.Attach, "[{0}]-->[{1}]", source.ThreadId, context.ThreadId);
|
|
92
|
_current = context;
|
|
92
|
_current = context;
|
|
93
|
} else {
|
|
93
|
} else {
|
|
94
|
_current = new TraceContext();
|
|
94
|
_current = new TraceContext();
|
|
95
|
}
|
|
95
|
}
|
|
96
|
}
|
|
96
|
}
|
|
97
|
|
|
97
|
|
|
98
|
/// <summary>
|
|
98
|
/// <summary>
|
|
99
|
/// ΠΡΡΠΎΠ΅Π΄ΠΈΠ½ΡΠ΅Ρ ΡΠ΅ΠΊΡΡΠΈΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΎΡ ΠΏΠΎΡΠΎΠΊΠ°, Π΄Π»Ρ Π΄Π°Π»ΡΠ½Π΅ΠΉΡΠ΅ΠΉ Π΅Π³ΠΎ ΠΏΠ΅ΡΠ΅Π΄Π°ΡΠΈ Π΄ΡΡΠ³ΠΎΠΌΡ ΠΏΠΎΡΠΎΠΊΡ
|
|
99
|
/// ΠΡΡΠΎΠ΅Π΄ΠΈΠ½ΡΠ΅Ρ ΡΠ΅ΠΊΡΡΠΈΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΎΡ ΠΏΠΎΡΠΎΠΊΠ°, Π΄Π»Ρ Π΄Π°Π»ΡΠ½Π΅ΠΉΡΠ΅ΠΉ Π΅Π³ΠΎ ΠΏΠ΅ΡΠ΅Π΄Π°ΡΠΈ Π΄ΡΡΠ³ΠΎΠΌΡ ΠΏΠΎΡΠΎΠΊΡ
|
|
100
|
/// <see cref="Attach(TraceContext)"/>.
|
|
100
|
/// <see cref="Attach(TraceContext)"/>.
|
|
101
|
/// </summary>
|
|
101
|
/// </summary>
|
|
102
|
/// <returns>ΠΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΏΠΎΡΠΎΠΊΠ°</returns>
|
|
102
|
/// <returns>ΠΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΏΠΎΡΠΎΠΊΠ°</returns>
|
|
103
|
/// <remarks>
|
|
103
|
/// <remarks>
|
|
104
|
/// ΠΠΎΡΠ»Π΅ ΠΎΡΡΠΎΠ΅Π΄ΠΈΠ½Π΅Π½ΠΈΡ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΎΡ ΠΏΠΎΡΠΎΠΊΠ°, ΠΏΡΠΈ ΠΏΠ΅ΡΠ²ΠΎΠΌ ΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΠΈ ΠΊ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠ΅ Π² ΡΡΠΎΠΌ
|
|
104
|
/// ΠΠΎΡΠ»Π΅ ΠΎΡΡΠΎΠ΅Π΄ΠΈΠ½Π΅Π½ΠΈΡ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΎΡ ΠΏΠΎΡΠΎΠΊΠ°, ΠΏΡΠΈ ΠΏΠ΅ΡΠ²ΠΎΠΌ ΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΠΈ ΠΊ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠ΅ Π² ΡΡΠΎΠΌ
|
|
105
|
/// ΠΏΠΎΡΠΎΠΊΠ΅ Π±ΡΠ΄Π΅Ρ ΡΠΎΠ·Π΄Π°Π½ Π½ΠΎΠ²ΡΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ.
|
|
105
|
/// ΠΏΠΎΡΠΎΠΊΠ΅ Π±ΡΠ΄Π΅Ρ ΡΠΎΠ·Π΄Π°Π½ Π½ΠΎΠ²ΡΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ.
|
|
106
|
/// </remarks>
|
|
106
|
/// </remarks>
|
|
107
|
public static TraceContext Detach() {
|
|
107
|
public static TraceContext Detach() {
|
|
108
|
var context = Current;
|
|
108
|
var context = Current;
|
|
109
|
context.LogEvent(TraceEventType.Detach, null);
|
|
109
|
context.LogEvent(TraceEventType.Detach, null);
|
|
110
|
_current = null;
|
|
110
|
_current = null;
|
|
111
|
return context;
|
|
111
|
return context;
|
|
112
|
}
|
|
112
|
}
|
|
113
|
|
|
113
|
|
|
114
|
/// <summary>
|
|
114
|
/// <summary>
|
|
115
|
/// Π‘ΠΎΠ·Π΄Π°Π΅Ρ ΠΏΠΎΡΡΠΎΡΠ½Π½ΡΡ ΠΊΠΎΠΏΠΈΡ ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ°, Π΄Π°Π½Π½ΡΡ ΠΊΠΎΠΏΠΈΡ ΠΌΠΎΠΆΠ½ΠΎ Ρ
ΡΠ°Π½ΠΈΡΡ ΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π΄Π»Ρ ΠΏΠ΅ΡΠ΅Π΄Π°ΡΠΈ ΡΠ΅ΡΠ΅Π· <see cref="Fork(TraceContext)"/>
|
|
115
|
/// Π‘ΠΎΠ·Π΄Π°Π΅Ρ ΠΏΠΎΡΡΠΎΡΠ½Π½ΡΡ ΠΊΠΎΠΏΠΈΡ ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ°, Π΄Π°Π½Π½ΡΡ ΠΊΠΎΠΏΠΈΡ ΠΌΠΎΠΆΠ½ΠΎ Ρ
ΡΠ°Π½ΠΈΡΡ ΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π΄Π»Ρ ΠΏΠ΅ΡΠ΅Π΄Π°ΡΠΈ ΡΠ΅ΡΠ΅Π· <see cref="Fork(TraceContext)"/>
|
|
116
|
/// </summary>
|
|
116
|
/// </summary>
|
|
117
|
/// <returns>ΠΠΎΠΏΠΈΡ ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ.</returns>
|
|
117
|
/// <returns>ΠΠΎΠΏΠΈΡ ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ.</returns>
|
|
118
|
public static TraceContext Snapshot() {
|
|
118
|
public static TraceContext Snapshot() {
|
|
119
|
return _current == null ? new TraceContext() : new TraceContext(_current);
|
|
119
|
return _current == null ? new TraceContext() : new TraceContext(_current,false);
|
|
120
|
}
|
|
120
|
}
|
|
121
|
|
|
121
|
|
|
122
|
/// <summary>
|
|
122
|
/// <summary>
|
|
123
|
/// ΠΡΠΏΠΎΠ»Π½ΡΠ΅Ρ ΠΏΠ΅ΡΠ΅Π΄Π°Π½Π½ΠΎΠ΅ Π΄Π΅ΠΉΡΡΠ²ΠΈΠ΅ Π² ΡΠΊΠ°Π·Π°Π½Π½ΠΎΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ, ΠΏΠΎ ΠΎΠΊΠΎΠ½ΡΠ°Π½ΠΈΠΈ Π²ΠΎΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅Ρ ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠΈΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΏΠΎΡΠΎΠΊΠ°.
|
|
123
|
/// ΠΡΠΏΠΎΠ»Π½ΡΠ΅Ρ ΠΏΠ΅ΡΠ΅Π΄Π°Π½Π½ΠΎΠ΅ Π΄Π΅ΠΉΡΡΠ²ΠΈΠ΅ Π² ΡΠΊΠ°Π·Π°Π½Π½ΠΎΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ, ΠΏΠΎ ΠΎΠΊΠΎΠ½ΡΠ°Π½ΠΈΠΈ Π²ΠΎΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅Ρ ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠΈΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΏΠΎΡΠΎΠΊΠ°.
|
|
124
|
/// </summary>
|
|
124
|
/// </summary>
|
|
125
|
/// <param name="action"></param>
|
|
125
|
/// <param name="action"></param>
|
|
126
|
public void Invoke(Action action) {
|
|
126
|
public void Invoke(Action action) {
|
|
127
|
if (action == null)
|
|
127
|
if (action == null)
|
|
128
|
throw new ArgumentNullException("action");
|
|
128
|
throw new ArgumentNullException("action");
|
|
129
|
var old = _current;
|
|
129
|
var old = _current;
|
|
130
|
Fork(this);
|
|
130
|
Fork(this);
|
|
131
|
try {
|
|
131
|
try {
|
|
132
|
action();
|
|
132
|
action();
|
|
133
|
} finally {
|
|
133
|
} finally {
|
|
|
|
|
134
|
if(_current != null)
|
|
134
|
_current.EndAllOperations();
|
|
135
|
_current.EndAllOperations();
|
|
135
|
_current = old;
|
|
136
|
_current = old;
|
|
136
|
}
|
|
137
|
}
|
|
137
|
}
|
|
138
|
}
|
|
138
|
|
|
139
|
|
|
139
|
/// <summary>
|
|
140
|
/// <summary>
|
|
140
|
/// Π’Π΅ΠΊΡΡΠ°Ρ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠ°Ρ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ.
|
|
141
|
/// Π’Π΅ΠΊΡΡΠ°Ρ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠ°Ρ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ.
|
|
141
|
/// </summary>
|
|
142
|
/// </summary>
|
|
142
|
public LogicalOperation CurrentOperation {
|
|
143
|
public LogicalOperation CurrentOperation {
|
|
143
|
get {
|
|
144
|
get {
|
|
144
|
return m_currentOperation;
|
|
145
|
return m_currentOperation;
|
|
145
|
}
|
|
146
|
}
|
|
146
|
}
|
|
147
|
}
|
|
147
|
|
|
148
|
|
|
148
|
/// <summary>
|
|
149
|
/// <summary>
|
|
149
|
/// ΠΠΏΠ΅ΡΠ°ΡΠΈΡ Π½ΠΈΠΆΠ΅ ΠΊΠΎΡΠΎΡΠΎΠΉ Π½Π΅Π»ΡΠ·Ρ ΠΎΠΏΡΡΠΊΠ°ΡΡΡΡ Π² ΡΡΠ΅ΠΊΠ΅ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΈΡ
ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΉ, Ρ.Π΅. ΠΎΠ½Π° Π½Π΅ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ Π·Π°Π²Π΅ΡΡΠ΅Π½Π° Π² ΡΠ΅ΠΊΡΡΠ΅ΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅.
|
|
150
|
/// ΠΠΏΠ΅ΡΠ°ΡΠΈΡ Π½ΠΈΠΆΠ΅ ΠΊΠΎΡΠΎΡΠΎΠΉ Π½Π΅Π»ΡΠ·Ρ ΠΎΠΏΡΡΠΊΠ°ΡΡΡΡ Π² ΡΡΠ΅ΠΊΠ΅ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΈΡ
ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΉ, Ρ.Π΅. ΠΎΠ½Π° Π½Π΅ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ Π·Π°Π²Π΅ΡΡΠ΅Π½Π° Π² ΡΠ΅ΠΊΡΡΠ΅ΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅.
|
|
150
|
/// </summary>
|
|
151
|
/// </summary>
|
|
151
|
public LogicalOperation BoundOperation {
|
|
152
|
public LogicalOperation BoundOperation {
|
|
152
|
get {
|
|
153
|
get {
|
|
153
|
return m_bound;
|
|
154
|
return m_bound;
|
|
154
|
}
|
|
155
|
}
|
|
155
|
}
|
|
156
|
}
|
|
156
|
|
|
157
|
|
|
157
|
/// <summary>
|
|
158
|
/// <summary>
|
|
158
|
/// ΠΠΎΡΠΎΠΊ, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ ΡΠΎΠ·Π΄Π°Π½ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ.
|
|
159
|
/// ΠΠΎΡΠΎΠΊ, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ ΡΠΎΠ·Π΄Π°Π½ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ.
|
|
159
|
/// </summary>
|
|
160
|
/// </summary>
|
|
160
|
public int ThreadId {
|
|
161
|
public int ThreadId {
|
|
161
|
get {
|
|
162
|
get {
|
|
162
|
return m_threadId;
|
|
163
|
return m_threadId;
|
|
163
|
}
|
|
164
|
}
|
|
164
|
}
|
|
165
|
}
|
|
165
|
|
|
166
|
|
|
166
|
/// <summary>
|
|
167
|
/// <summary>
|
|
167
|
/// ΠΠ°ΡΠΈΠ½Π°Π΅Ρ Π±Π΅Π·ΡΠΌΡΠ½Π½ΡΡ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ.
|
|
168
|
/// ΠΠ°ΡΠΈΠ½Π°Π΅Ρ Π±Π΅Π·ΡΠΌΡΠ½Π½ΡΡ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ.
|
|
168
|
/// </summary>
|
|
169
|
/// </summary>
|
|
169
|
public void StartLogicalOperation() {
|
|
170
|
public void StartLogicalOperation() {
|
|
170
|
StartLogicalOperation(null);
|
|
171
|
StartLogicalOperation(null);
|
|
171
|
}
|
|
172
|
}
|
|
172
|
|
|
173
|
|
|
173
|
/// <summary>
|
|
174
|
/// <summary>
|
|
174
|
/// ΠΠ°ΡΠΈΠ½Π°Π΅Ρ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ Ρ ΡΠΊΠ°Π·Π°Π½Π½ΡΠΌ ΠΈΠΌΠ΅Π½Π΅ΠΌ. Π‘ΠΎΠ·Π΄Π°Π½Π½Π°Ρ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ Π±ΡΠ΄Π΅Ρ Π΄ΠΎΠ±Π²Π°Π»Π΅Π½Π° Π² ΡΡΠ΅ΠΊ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΈΡ
ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ°, Π·Π°ΡΠ΅ΠΌ Π±ΡΠ΄Π΅Ρ ΡΠΎΠ·Π΄Π°Π½ΠΎ ΡΠΎΠΎΡΠ²Π΅ΡΡΠ²ΡΡΡΠ΅Π΅ ΡΠΎΠ±ΡΡΠΈΠ΅.
|
|
175
|
/// ΠΠ°ΡΠΈΠ½Π°Π΅Ρ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ Ρ ΡΠΊΠ°Π·Π°Π½Π½ΡΠΌ ΠΈΠΌΠ΅Π½Π΅ΠΌ. Π‘ΠΎΠ·Π΄Π°Π½Π½Π°Ρ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ Π±ΡΠ΄Π΅Ρ Π΄ΠΎΠ±Π²Π°Π»Π΅Π½Π° Π² ΡΡΠ΅ΠΊ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΈΡ
ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΉ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ°, Π·Π°ΡΠ΅ΠΌ Π±ΡΠ΄Π΅Ρ ΡΠΎΠ·Π΄Π°Π½ΠΎ ΡΠΎΠΎΡΠ²Π΅ΡΡΠ²ΡΡΡΠ΅Π΅ ΡΠΎΠ±ΡΡΠΈΠ΅.
|
|
175
|
/// </summary>
|
|
176
|
/// </summary>
|
|
176
|
/// <param name="name">ΠΠΌΡ Π½Π°ΡΠΈΠ½Π°Π΅ΠΌΠΎΠΉ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ.</param>
|
|
177
|
/// <param name="name">ΠΠΌΡ Π½Π°ΡΠΈΠ½Π°Π΅ΠΌΠΎΠΉ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ.</param>
|
|
177
|
public void StartLogicalOperation(string name) {
|
|
178
|
public void StartLogicalOperation(string name) {
|
|
178
|
m_currentOperation = new LogicalOperation(name, m_currentOperation);
|
|
179
|
m_currentOperation = new LogicalOperation(name, m_currentOperation);
|
|
179
|
LogEvent(TraceEventType.OperationStarted, name);
|
|
180
|
LogEvent(TraceEventType.OperationStarted, name);
|
|
180
|
}
|
|
181
|
}
|
|
181
|
|
|
182
|
|
|
182
|
/// <summary>
|
|
183
|
/// <summary>
|
|
183
|
/// ΠΠ°ΠΊΠ°Π½ΡΠΈΠ²Π°Π΅Ρ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ Π½Π°ΡΠ°ΡΡΡ Π² ΡΠ΅ΠΊΡΡΠ΅ΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅. ΠΠΏΠ΅ΡΠ°ΡΠΈΠΈ, Π½Π°ΡΠ°ΡΡΠ΅ Π² Π΄ΡΡΠ³ΠΈΡ
ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ°Ρ
Π½Π΅ ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ Π·Π°ΠΊΠΎΠ½ΡΠ΅Π½Ρ Π² ΡΠ΅ΠΊΡΡΠ΅ΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅.
|
|
184
|
/// ΠΠ°ΠΊΠ°Π½ΡΠΈΠ²Π°Π΅Ρ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ Π½Π°ΡΠ°ΡΡΡ Π² ΡΠ΅ΠΊΡΡΠ΅ΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅. ΠΠΏΠ΅ΡΠ°ΡΠΈΠΈ, Π½Π°ΡΠ°ΡΡΠ΅ Π² Π΄ΡΡΠ³ΠΈΡ
ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ°Ρ
Π½Π΅ ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ Π·Π°ΠΊΠΎΠ½ΡΠ΅Π½Ρ Π² ΡΠ΅ΠΊΡΡΠ΅ΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅.
|
|
184
|
/// </summary>
|
|
185
|
/// </summary>
|
|
185
|
/// <remarks>
|
|
186
|
/// <remarks>
|
|
186
|
/// ΠΡΠΈ Π²ΡΠ·ΠΎΠ²Π΅ Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΠΌΠ΅ΡΠΎΠ΄Π° ΡΠΎΠ·Π΄Π°Π΅ΡΡΡ ΡΠΎΠ±ΡΡΠΈΠ΅ ΠΆΡΡΠ½Π°Π»Π° ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ, Π»ΠΈΠ±ΠΎ ΠΎ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΠΈ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ, Π»ΠΈΠ±ΠΎ ΠΎΠ± ΠΎΡΠΈΠ±ΠΊΠΈ, ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ Π΄Π°Π½Π½Π°Ρ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ
|
|
187
|
/// ΠΡΠΈ Π²ΡΠ·ΠΎΠ²Π΅ Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΠΌΠ΅ΡΠΎΠ΄Π° ΡΠΎΠ·Π΄Π°Π΅ΡΡΡ ΡΠΎΠ±ΡΡΠΈΠ΅ ΠΆΡΡΠ½Π°Π»Π° ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ, Π»ΠΈΠ±ΠΎ ΠΎ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΠΈ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ, Π»ΠΈΠ±ΠΎ ΠΎΠ± ΠΎΡΠΈΠ±ΠΊΠΈ, ΠΏΠΎΡΠΊΠΎΠ»ΡΠΊΡ Π΄Π°Π½Π½Π°Ρ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ
|
|
187
|
/// Π½Π°ΡΠ°ΡΠ° Π² Π΄ΡΡΠ³ΠΎΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅.
|
|
188
|
/// Π½Π°ΡΠ°ΡΠ° Π² Π΄ΡΡΠ³ΠΎΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅.
|
|
188
|
/// </remarks>
|
|
189
|
/// </remarks>
|
|
189
|
public void EndLogicalOperation() {
|
|
190
|
public void EndLogicalOperation() {
|
|
190
|
if (m_bound == m_currentOperation) {
|
|
191
|
if (m_bound == m_currentOperation) {
|
|
191
|
LogEvent(TraceEventType.Error, "Trying to end the operation which isn't belongs to current trace");
|
|
192
|
LogEvent(TraceEventType.Error, "Trying to end the operation which isn't belongs to current trace");
|
|
192
|
} else {
|
|
193
|
} else {
|
|
193
|
var op = m_currentOperation;
|
|
194
|
var op = m_currentOperation;
|
|
194
|
LogEvent(TraceEventType.OperationCompleted, "{0} {1} ms", op.Name, op.Duration);
|
|
195
|
LogEvent(TraceEventType.OperationCompleted, "{0} {1} ms", op.Name, op.Duration);
|
|
195
|
m_currentOperation = m_currentOperation.Parent;
|
|
196
|
m_currentOperation = m_currentOperation.Parent;
|
|
196
|
}
|
|
197
|
}
|
|
197
|
}
|
|
198
|
}
|
|
198
|
|
|
199
|
|
|
199
|
/// <summary>
|
|
200
|
/// <summary>
|
|
|
|
|
201
|
/// Π‘ΠΎΠ·Π΄Π°Π΅Ρ ΠΊΠΎΠΏΠΈΡ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΠΈ Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅ΡΡΡ Π½Π° ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ Π² ΡΠ΅ΠΊΡΡΠ΅ΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅, ΡΡΠΎ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π½Π°ΡΠ°ΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ Π² ΠΎΠ΄Π½ΠΎΠΌ ΠΏΠΎΡΠΎΠΊΠ΅, Π° Π·Π°Π²Π΅ΡΡΠΈΡΡ - Π² Π΄ΡΡΠ³ΠΎΠΌ.
|
|
|
|
|
202
|
/// </summary>
|
|
|
|
|
203
|
/// <returns>ΠΠΎΠ½ΡΠ΅ΠΊΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠΈ, ΠΊΠΎΡΠΎΡΡΠΉ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΡΠΈΡΠΎΠ΅Π΄ΠΈΠ½ΠΈΡΡ ΠΊ Π΄ΡΡΠ³ΠΎΠΌΡ ΠΏΠΎΡΠΎΠΊΡ.</returns>
|
|
|
|
|
204
|
public TraceContext DetachLogicalOperation() {
|
|
|
|
|
205
|
if (m_bound == m_currentOperation) {
|
|
|
|
|
206
|
return new TraceContext();
|
|
|
|
|
207
|
} else {
|
|
|
|
|
208
|
var detached = new TraceContext(this, true);
|
|
|
|
|
209
|
m_currentOperation = m_currentOperation.Parent;
|
|
|
|
|
210
|
return detached;
|
|
|
|
|
211
|
}
|
|
|
|
|
212
|
}
|
|
|
|
|
213
|
|
|
|
|
|
214
|
public void BindLogicalOperationToPromise(IPromiseBase promise) {
|
|
|
|
|
215
|
Safe.ArgumentNotNull(promise, "promise");
|
|
|
|
|
216
|
|
|
|
|
|
217
|
var ctx = DetachLogicalOperation();
|
|
|
|
|
218
|
promise.Finally(() => {
|
|
|
|
|
219
|
var old = _current;
|
|
|
|
|
220
|
TraceContext.Attach(ctx);
|
|
|
|
|
221
|
TraceContext.Current.EndLogicalOperation();
|
|
|
|
|
222
|
_current = old;
|
|
|
|
|
223
|
});
|
|
|
|
|
224
|
}
|
|
|
|
|
225
|
|
|
|
|
|
226
|
/// <summary>
|
|
200
|
/// ΠΠ°Π²ΡΠ΅ΡΠ°Π΅Ρ Π²ΡΠ΅ Π½Π°ΡΠ°ΡΡΠ΅ Π² ΡΡΠΎΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ
|
|
227
|
/// ΠΠ°Π²ΡΠ΅ΡΠ°Π΅Ρ Π²ΡΠ΅ Π½Π°ΡΠ°ΡΡΠ΅ Π² ΡΡΠΎΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ
|
|
201
|
/// </summary>
|
|
228
|
/// </summary>
|
|
202
|
public void EndAllOperations() {
|
|
229
|
public void EndAllOperations() {
|
|
203
|
while (m_bound != m_currentOperation)
|
|
230
|
while (m_bound != m_currentOperation)
|
|
204
|
EndLogicalOperation();
|
|
231
|
EndLogicalOperation();
|
|
205
|
}
|
|
232
|
}
|
|
206
|
|
|
233
|
|
|
207
|
void LogEvent(TraceEventType type, string format, params object[] args) {
|
|
234
|
void LogEvent(TraceEventType type, string format, params object[] args) {
|
|
208
|
LogChannel<TraceEvent>.Default.LogEvent(this, TraceEvent.Create(type, format, args));
|
|
235
|
LogChannel<TraceEvent>.Default.LogEvent(this, TraceEvent.Create(type, format, args));
|
|
209
|
}
|
|
236
|
}
|
|
210
|
}
|
|
237
|
}
|
|
211
|
}
|
|
238
|
}
|