Skip to content

Commit 2d7d1ae

Browse files
author
Jade Wang
committed
change trace method
1 parent e45211a commit 2d7d1ae

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

csharp/src/Reader/CloudFetch/BaseResultFetcher.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
using System.Diagnostics;
2828
using System.Threading;
2929
using System.Threading.Tasks;
30+
using Apache.Arrow.Adbc.Tracing;
3031

3132
namespace Apache.Arrow.Adbc.Drivers.Databricks.Reader.CloudFetch
3233
{
@@ -120,7 +121,9 @@ public async Task StopAsync()
120121
}
121122
catch (Exception ex)
122123
{
123-
Trace.WriteLine($"Error stopping fetcher: {ex.Message}");
124+
Activity.Current?.AddEvent("cloudfetch.fetcher_stop_error", [
125+
new("error_message", ex.Message)
126+
]);
124127
}
125128
finally
126129
{
@@ -210,7 +213,10 @@ private async Task FetchResultsWrapperAsync(CancellationToken cancellationToken)
210213
}
211214
catch (Exception ex)
212215
{
213-
Trace.WriteLine($"Unhandled error in fetcher: {ex}");
216+
Activity.Current?.AddEvent("cloudfetch.fetcher_unhandled_error", [
217+
new("error_message", ex.Message),
218+
new("error_type", ex.GetType().Name)
219+
]);
214220
_error = ex;
215221
_hasMoreResults = false;
216222
_isCompleted = true;

csharp/src/Reader/CloudFetch/CloudFetchDownloader.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ public async Task StopAsync()
147147
}
148148
catch (Exception ex)
149149
{
150-
Trace.WriteLine($"Error stopping downloader: {ex}");
150+
Activity.Current?.AddEvent("cloudfetch.downloader_stop_error", [
151+
new("error_message", ex.Message),
152+
new("error_type", ex.GetType().Name)
153+
]);
151154
}
152155
finally
153156
{

csharp/src/Reader/CloudFetch/CloudFetchReader.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,21 @@ public CloudFetchReader(
157157
}
158158
catch (Exception ex)
159159
{
160-
Trace.WriteLine($"Error creating Arrow reader: {ex}");
160+
Activity.Current?.AddEvent("cloudfetch.arrow_reader_creation_error", [
161+
new("error_message", ex.Message),
162+
new("error_type", ex.GetType().Name)
163+
]);
161164
this.currentDownloadResult.Dispose();
162165
this.currentDownloadResult = null;
163166
throw;
164167
}
165168
}
166169
catch (Exception ex)
167170
{
168-
Trace.WriteLine($"Error getting next downloaded file: {ex}");
171+
Activity.Current?.AddEvent("cloudfetch.get_next_file_error", [
172+
new("error_message", ex.Message),
173+
new("error_type", ex.GetType().Name)
174+
]);
169175
throw;
170176
}
171177
}

csharp/src/Reader/CloudFetch/CloudFetchResultFetcher.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ protected override async Task FetchAllResultsAsync(CancellationToken cancellatio
192192
}
193193
catch (Exception ex)
194194
{
195-
Trace.WriteLine($"Error fetching results: {ex}");
195+
Activity.Current?.AddEvent("cloudfetch.fetch_results_error", [
196+
new("error_message", ex.Message),
197+
new("error_type", ex.GetType().Name)
198+
]);
196199
_error = ex;
197200
_hasMoreResults = false;
198201
throw;
@@ -230,7 +233,10 @@ private async Task FetchNextResultBatchAsync(long? offset, CancellationToken can
230233
}
231234
catch (Exception ex)
232235
{
233-
Trace.WriteLine($"Error fetching results from server: {ex}");
236+
Activity.Current?.AddEvent("cloudfetch.fetch_from_server_error", [
237+
new("error_message", ex.Message),
238+
new("error_type", ex.GetType().Name)
239+
]);
234240
_hasMoreResults = false;
235241
throw;
236242
}

0 commit comments

Comments
 (0)