public AsyncQueueWorker(DatadogClient client, int bufferingCount = 10, int bufferingTimeMilliseconds = 5000, Action <Exception> logException = null) { this.processingTask = Task.Factory.StartNew(ConsumeQueue, TaskCreationOptions.LongRunning).Unwrap(); this.client = client; this.logException = logException ?? ((Exception ex) => { }); this.bufferingCount = bufferingCount; this.bufferingTime = TimeSpan.FromMilliseconds(bufferingTimeMilliseconds); }
public TracingManager(DatadogClient client, int bufferingCount = 10, int bufferingTimeMilliseconds = 5000, Action <Exception> logException = null) { worker = new AsyncQueueWorker(client, bufferingCount, bufferingTimeMilliseconds, logException); }
static void Main(string[] args) { var client = new DatadogSharp.Tracing.DatadogClient(); var rand = new Random(); var traces = new List <Span>(); //client.Services(new Service //{ // App = "myapp", // AppType = "web", // ServiceName = "high.throughput" //}).Wait(); var tid = Span.BuildRandomId(); Console.WriteLine(tid); var root = new DatadogSharp.Tracing.Span { TraceId = tid, SpanId = Span.BuildRandomId(), Name = "my_root", Resource = "/home", Service = "testservice", Start = Span.ToNanoseconds(DateTime.UtcNow), Type = "web", Duration = Span.ToNanoseconds(TimeSpan.FromMilliseconds(3500)), //Error = 1, //Meta = new Dictionary<string, string> { { "Message", new Exception().ToString() } } }; traces.Add(root); for (int i = 0; i < 4000; i++) { var test = new DatadogSharp.Tracing.Span { TraceId = tid, SpanId = Span.BuildRandomId(), Name = "my_test_span" + i, Resource = "/home", Service = "testservice", Start = Span.ToNanoseconds(DateTime.UtcNow.AddMilliseconds(rand.Next(0, 3000))), Type = "web", Duration = Span.ToNanoseconds(TimeSpan.FromMilliseconds(rand.Next(100, 300))), ParentId = root.SpanId }; traces.Add(test); } var bytes = MessagePackSerializer.Serialize(traces, DatadogSharpResolver.Instance); Console.WriteLine(MessagePackSerializer.ToJson(bytes)); var v = client.Traces(new[] { traces.ToArray() }).Result; Console.WriteLine(v); }