public TelemetryPublisherFirestore(TelemetryPublisherOptions opts) : base(opts) { // Parse Options var options = ConnectionStringParser.Parse(opts.ConnectionString); if (!options.TryGetValue("ProjectId", out var firestoreProjectId)) { Logger?.LogCritical( $"Can't start {nameof(TelemetryPublisherFirestore)}! Malformed connection string! " + $"Missing ProjectId!"); throw new ArgumentException("Malformed connection string!"); } if (!options.TryGetValue("CollectionName", out var firestoreCollection)) { Logger?.LogCritical( $"Can't start {nameof(TelemetryPublisherFirestore)}! Malformed connection string! " + $"Missing CollectionName!"); throw new ArgumentException("Malformed connection string!"); } var timeout = int.Parse(options.GetValueOrDefault("Timeout", "10000") ?? "10000"); _webApiKey = options.GetValueOrDefault("WebApiKey", null); _webEmail = options.GetValueOrDefault("WebApiEmail", null); _webPassword = options.GetValueOrDefault("WebApiPassword", null); // Setup HttpClient var requestUrl = $"https://firestore.googleapis.com/v1/projects/{firestoreProjectId}/" + $"databases/(default)/documents/{firestoreCollection}/"; HttpClient = new MinimalHttpClient(requestUrl) { Timeout = timeout, Logger = Logger }; Logger?.LogInformation($"Initialized {nameof(TelemetryPublisherFirestore)}"); Logger?.LogInformation($"ProjectId: {firestoreProjectId}; CollectionName: {firestoreCollection}."); }
public void SetHttpClient(MinimalHttpClient client) { HttpClient = client; }