static void Main() { string writeKey = "abcabc123123defdef456456"; string dataSet = "dynamic"; var honey = new LibHoney(writeKey, dataSet); var builder = new Builder(honey); // Attach fields to the Builder instance builder.AddField("start", DateTime.Now); builder.AddDynamicField("end", () => DateTime.Now); var tasks = new Task [8]; foreach (int i in Enumerable.Range(0, tasks.Length)) { var t = Task.Run(async() => { // Simulate some work. await Task.Delay(new Random().Next(100)); // builder comes with the "start" and "end" fields // already populated ("end" being a dynamic field) var ev = builder.NewEvent(); ev.AddField("id", i); ev.Send(); }); tasks [i] = t; } Task.WaitAll(tasks); honey.Close(); }
static void Main() { string writeKey = "abcabc123123defdef456456"; string dataSet = "responses"; var honey = new LibHoney(writeKey, dataSet); var responses = honey.Responses; Task.Run(() => ReadResponses(responses)); var tasks = new Task [8]; foreach (int i in Enumerable.Range(0, tasks.Length)) { var t = Task.Run(async() => { // Simulate work. var start = DateTime.Now; await Task.Delay(new Random().Next(100)); // Work is done, send the task id and its elapsed time. var ev = new Event(honey); ev.AddField("id", i); ev.AddField("elapsed", (DateTime.Now - start).TotalMilliseconds); ev.Send(); }); tasks [i] = t; } Task.WaitAll(tasks); honey.Close(); }
static void Main() { string writeKey = "abcabc123123defdef456456"; string dataSet = "factorial"; var honey = new LibHoney(writeKey, dataSet); Task.Run(() => ReadResponses(honey.Responses)); // Attach fields to the top-level instance. honey.AddField("version", "3.4.5"); honey.AddDynamicField("num_threads", () => Process.GetCurrentProcess().Threads.Count); // Sends an event with "version", "num_threads", and "status" fields. honey.SendNow("status", "starting run"); RunFact(1, 2, new Builder(honey, new Dictionary <string, object> () { ["range"] = "low" })); RunFact(31, 32, new Builder(honey, new Dictionary <string, object> () { ["range"] = "high" })); honey.SendNow("status", "sending now"); honey.Close(); }
static void Main() { string writeKey = "abcabc123123defdef456456"; string dataSet = "event_values"; var honey = new LibHoney(writeKey, dataSet); var rand = new Random(); // Send 3 events with a random number. for (int i = 0; i < 10; i++) { honey.SendNow(new Dictionary <string, object> () { ["counter"] = rand.Next(100), }); } // Send an event with the same writeKey but different // dataSet. var ev = new Event(honey); ev.DataSet = "master_values"; ev.AddField("latest_event", DateTime.Now.ToString("O")); ev.Send(); // Close the client. honey.Close(); }
public void Responses() { var libHoney = LibHoney = new LibHoney("key1", "HelloHoney", 1); Assert.Equal(true, libHoney.Responses != null); Assert.Equal(false, libHoney.Responses.IsAddingCompleted); Assert.Equal(false, libHoney.Responses.IsCompleted); }
public void AddNull() { var libHoney = LibHoney = new LibHoney("key1", "HelloHoney", 1); bool excThrown = false; try { libHoney.Add(null); } catch (ArgumentNullException) { excThrown = true; } Assert.True(excThrown); }
public void SendEmpty() { var libHoney = LibHoney = new LibHoney("key1", "HelloHoney", 1); bool excThrown = false; try { libHoney.SendNow(new Dictionary <string, object> ()); } catch (SendException) { excThrown = true; } Assert.True(excThrown); }
public HybridConnectionReverseProxy(string connectionString, Uri targetUri, string honeycombKey, string honeycombDataset) { _libHoney = new LibHoney(honeycombKey, honeycombDataset); listener = new HybridConnectionListener(connectionString); httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.ExpectContinue = false; hybridConnectionSubpath = listener.Address.AbsolutePath + "/"; _targetUri = targetUri; }
public void CloseMultiple() { var libHoney = new LibHoney("key1", "HelloHoney", 1); libHoney.Close(); // Again, a few times. libHoney.Close(); libHoney.Close(); }
public void InternalStateAfterClose() { var libHoney = LibHoney = new LibHoney("key1", "HelloHoney", 1); libHoney.Close(); Assert.Equal(true, libHoney.IsClosed); Assert.Null(libHoney.Transmission); Assert.NotNull(libHoney.Responses); }
public void Ctor2() { var libHoney = LibHoney = new LibHoney("key1", "HelloHoney", "http://myhost"); Assert.Equal("key1", libHoney.WriteKey); Assert.Equal("HelloHoney", libHoney.DataSet); Assert.Equal("http://myhost", libHoney.ApiHost); Assert.Equal(LibHoney.DefaultSampleRate, libHoney.SampleRate); Assert.Equal(false, libHoney.BlockOnSend); Assert.Equal(false, libHoney.BlockOnResponse); }
static GetStatus() { var builder = new ConfigurationBuilder(); var connString = Environment.GetEnvironmentVariable("APP_CONFIG_CONN_STRING", EnvironmentVariableTarget.Process); builder.AddAzureAppConfiguration(connString); Configuration = builder.Build(); HoneycombKey = Configuration["HoneycombKey"]; HoneycombDataset = Configuration["HoneycombDataset"]; _libHoney = new LibHoney(HoneycombKey, HoneycombDataset); }
public void Ctor4() { var libHoney = LibHoney = new LibHoney("key1", "HelloHoney", "http://myhost", 3, 6, true, true); Assert.Equal("key1", libHoney.WriteKey); Assert.Equal("HelloHoney", libHoney.DataSet); Assert.Equal("http://myhost", libHoney.ApiHost); Assert.Equal(3, libHoney.SampleRate); Assert.Equal(true, libHoney.BlockOnSend); Assert.Equal(true, libHoney.BlockOnResponse); }
public void AfterClose() { var libHoney = LibHoney = new LibHoney("key1", "HelloHoney", "http://myhost", 3, 6, true, true); libHoney.Close(); Assert.Equal(true, libHoney.Responses != null); Assert.Equal(0, libHoney.Responses.Count); Assert.Equal(true, libHoney.Responses.IsAddingCompleted); Assert.Equal(true, libHoney.Responses.IsCompleted); }
public void SendPreSampledDisposed() { // Create our own LibHoney so we can dispose it right away. var honey = new LibHoney("key1", "data1"); var ev = new Event(honey); honey.Close(); bool excThrown = false; try { ev.SendPreSampled(); } catch (SendException) { excThrown = true; } Assert.True(excThrown); }
public void SendNowClosed() { var libHoney = new LibHoney("key1", "HelloHoney", 1); libHoney.Close(); bool excThrown = false; try { libHoney.SendNow(new Dictionary <string, object> ()); } catch (SendException) { excThrown = true; } Assert.True(excThrown); excThrown = false; try { libHoney.SendNow("name", "value"); } catch (SendException) { excThrown = true; } Assert.True(excThrown); }
public void InternalStateAfterInit() { var libHoney = LibHoney = new LibHoney("key1", "HelloHoney", 3); libHoney.AddField("counter", 13); libHoney.AddField("value", DateTime.Now); libHoney.AddDynamicField("dynamic_value", () => DateTime.Now); Assert.Equal(false, libHoney.Fields.IsEmpty); Assert.Equal(2, libHoney.Fields.Fields.Count); Assert.Equal(1, libHoney.Fields.DynamicFields.Count); Assert.Equal(true, libHoney.Transmission != null); Assert.Equal(3, libHoney.Transmission.MaxConcurrentBatches); Assert.Equal(true, libHoney.Responses != null); Assert.Equal(libHoney.Transmission.Responses, libHoney.Responses); Assert.Equal(true, libHoney.Transmission.Responses.BoundedCapacity > 1); Assert.Equal(false, libHoney.Transmission.Responses.IsAddingCompleted); Assert.Equal(false, libHoney.Transmission.Responses.IsCompleted); }
static void Main() { string writeKey = "abcabc123123defdef456456"; string dataSet = "simple"; var honey = new LibHoney(writeKey, dataSet); var rand = new Random(); // Send 10 events with a random number. for (int i = 0; i < 10; i++) { honey.SendNow(new Dictionary <string, object> () { ["message"] = "Diagnostic #" + i, ["counter"] = rand.Next(100), }); Thread.Sleep(TimeSpan.FromMilliseconds(100)); } // Close the client. honey.Close(); }
public void Dispose() { LibHoney.Close(); }
public LibHoneyFixture() { LibHoney = new LibHoney("key1", "HelloTest", 1); }