public async Task InfluxLineFormatterWritesToBuffer() { var mockHttp = new MockHttpClient(); using (var client = new InfluxDBClientBuilder(mockHttp, "test").Build()) { DiagnosticSourceInfluxDB.Listen(client, s => s == "tests"); var source = new DiagnosticListener("tests"); if (source.IsEnabled("test")) { var obj = new { size = 100, duration = 1000, url = "test.com", id = "42" }; source.Write("test", obj); // Seems like we have to wait for DiagnosticSource to actually complete. await Task.Delay(32); } // Forces the client to complete outstanding requests ((InfluxDBClient)client).Flush(); } Assert.Equal("write?db=test&precision=ms", mockHttp.Path); Assert.NotNull(mockHttp.Bytes); Assert.StartsWith("tests_test", mockHttp.Text); Assert.Contains("size=100", mockHttp.Text); Assert.Contains("duration=1000", mockHttp.Text); Assert.Contains("url=test.com", mockHttp.Text); Assert.Contains("id=42", mockHttp.Text); }
public async Task WritesToInflux() { var random = new Random(42); using (var client = new InfluxDBClientBuilder("http://localhost:8086", "carbon-dev") .ForceFlushInterval(TimeSpan.FromSeconds(1)) .Build()) using (DiagnosticSourceInfluxDB.Listen(client, _ => true)) { for (int i = 0; i < 1024; i++) { Source.Write("test", new { value = random.Next(64), source = $"id{random.Next(8)}" }); } await Task.Delay(TimeSpan.FromSeconds(1)); } Assert.True(true); }