private async Task UploadAsync(string[] files) { using var tracer = Tracing.Trace("UploadToGarminViaNative") .WithTag(TagKey.Category, "nativeImplV1"); try { await _api.InitAuth(); } catch (Exception e) { throw new GarminUploadException("Failed to authenticate with Garmin.", -2, e); } foreach (var file in files) { try { var response = await _api.UploadActivity(file, _config.Format.Fit? ".fit" : ".tcx"); if (!string.IsNullOrEmpty(response.DetailedImportResult.UploadId)) { // TODO: update upload datetime in DBClient Log.Information("Uploaded workout {@workoutName}", file); } RateLimit(); } catch (Exception e) { throw new GarminUploadException($"NativeImplV1 failed to upload workout {file}", -1, e); } } }
private async Task UploadAsync(string[] files) { using var tracing = Tracing.Trace($"{nameof(GarminUploader)}.{nameof(UploadAsync)}.UploadToGarminViaNative")? .WithTag(TagKey.Category, "nativeImplV1") .AddTag("workouts.count", files.Count()); try { await _api.InitAuth(); } catch (Exception e) { tracing?.AddTag("exception.message", e.Message); tracing?.AddTag("exception.stacktrace", e.StackTrace); throw new GarminUploadException("Failed to authenticate with Garmin.", -2, e); } foreach (var file in files) { try { _logger.Information("Uploading to Garmin: {@file}", file); await _api.UploadActivity(file, _config.Format.Fit? ".fit" : ".tcx"); await RateLimit(); } catch (Exception e) { tracing?.AddTag("exception.message", e.Message); tracing?.AddTag("exception.stacktrace", e.StackTrace); throw new GarminUploadException($"NativeImplV1 failed to upload workout {file}", -1, e); } } }