@@ -67,10 +67,18 @@ public async Task Auto_Instrument_With_StartupHook_Should_Capture_Transaction(st
67
67
apmServer . RunInBackground ( port ) ;
68
68
var waitHandle = new ManualResetEvent ( false ) ;
69
69
70
+ var error = string . Empty ;
71
+
70
72
apmServer . OnReceive += o =>
71
73
{
72
74
if ( o is TransactionDto )
73
75
waitHandle . Set ( ) ;
76
+
77
+ else if ( o is string s ) // may occur if there is an error
78
+ {
79
+ waitHandle . Set ( ) ;
80
+ error = s ;
81
+ }
74
82
} ;
75
83
76
84
using ( var sampleApp = new SampleApplication ( ) )
@@ -86,8 +94,9 @@ public async Task Auto_Instrument_With_StartupHook_Should_Capture_Transaction(st
86
94
var response = await client . GetAsync ( uri ) ;
87
95
88
96
response . IsSuccessStatusCode . Should ( ) . BeTrue ( ) ;
97
+ waitHandle . WaitOne ( TimeSpan . FromMinutes ( 1 ) ) ;
89
98
90
- waitHandle . WaitOne ( TimeSpan . FromMinutes ( 2 ) ) ;
99
+ error . Should ( ) . BeEmpty ( ) ;
91
100
apmServer . ReceivedData . Transactions . Should ( ) . HaveCount ( 1 ) ;
92
101
93
102
var transaction = apmServer . ReceivedData . Transactions . First ( ) ;
@@ -108,12 +117,22 @@ public async Task Auto_Instrument_With_StartupHook_Should_Capture_Error(string t
108
117
var transactionWaitHandle = new ManualResetEvent ( false ) ;
109
118
var errorWaitHandle = new ManualResetEvent ( false ) ;
110
119
120
+ var serverError = string . Empty ;
121
+
111
122
apmServer . OnReceive += o =>
112
123
{
113
124
if ( o is TransactionDto )
114
125
transactionWaitHandle . Set ( ) ;
115
- if ( o is ErrorDto )
126
+
127
+ else if ( o is ErrorDto )
116
128
errorWaitHandle . Set ( ) ;
129
+
130
+ else if ( o is string s ) // may occur if there is an error
131
+ {
132
+ transactionWaitHandle . Set ( ) ;
133
+ errorWaitHandle . Set ( ) ;
134
+ serverError = s ;
135
+ }
117
136
} ;
118
137
119
138
using ( var sampleApp = new SampleApplication ( ) )
@@ -131,13 +150,15 @@ public async Task Auto_Instrument_With_StartupHook_Should_Capture_Error(string t
131
150
132
151
response . IsSuccessStatusCode . Should ( ) . BeFalse ( ) ;
133
152
134
- transactionWaitHandle . WaitOne ( TimeSpan . FromMinutes ( 2 ) ) ;
153
+ transactionWaitHandle . WaitOne ( TimeSpan . FromMinutes ( 1 ) ) ;
154
+ serverError . Should ( ) . BeEmpty ( ) ;
135
155
apmServer . ReceivedData . Transactions . Should ( ) . HaveCount ( 1 ) ;
136
156
137
157
var transaction = apmServer . ReceivedData . Transactions . First ( ) ;
138
158
transaction . Name . Should ( ) . Be ( "GET Home/Exception" ) ;
139
159
140
- errorWaitHandle . WaitOne ( TimeSpan . FromMinutes ( 2 ) ) ;
160
+ errorWaitHandle . WaitOne ( TimeSpan . FromMinutes ( 1 ) ) ;
161
+ serverError . Should ( ) . BeEmpty ( ) ;
141
162
apmServer . ReceivedData . Errors . Should ( ) . HaveCount ( 1 ) ;
142
163
143
164
var error = apmServer . ReceivedData . Errors . First ( ) ;
@@ -159,11 +180,19 @@ public async Task Auto_Instrument_With_StartupHook_Should_Capture_Metadata(
159
180
var port = apmServer . FindAvailablePortToListen ( ) ;
160
181
apmServer . RunInBackground ( port ) ;
161
182
183
+ var error = string . Empty ;
162
184
var waitHandle = new ManualResetEvent ( false ) ;
185
+
163
186
apmServer . OnReceive += o =>
164
187
{
165
188
if ( o is MetadataDto )
166
189
waitHandle . Set ( ) ;
190
+
191
+ else if ( o is string s ) // may occur if there is an error
192
+ {
193
+ waitHandle . Set ( ) ;
194
+ error = s ;
195
+ }
167
196
} ;
168
197
169
198
using ( var sampleApp = new SampleApplication ( ) )
@@ -180,7 +209,9 @@ public async Task Auto_Instrument_With_StartupHook_Should_Capture_Metadata(
180
209
181
210
response . IsSuccessStatusCode . Should ( ) . BeTrue ( ) ;
182
211
183
- waitHandle . WaitOne ( TimeSpan . FromMinutes ( 2 ) ) ;
212
+ waitHandle . WaitOne ( TimeSpan . FromMinutes ( 1 ) ) ;
213
+
214
+ error . Should ( ) . BeEmpty ( ) ;
184
215
apmServer . ReceivedData . Metadata . Should ( ) . HaveCountGreaterOrEqualTo ( 1 ) ;
185
216
186
217
var metadata = apmServer . ReceivedData . Metadata . First ( ) ;
0 commit comments