private void OnTimedEvent(object _Source, ElapsedEventArgs _E) { var TimeSpans = new List <Span>(); // Keep the lock has tight has possible, grab the values we need then clear out the existing ones. lock (Spans) { TimeSpans.AddRange(Spans); Spans.Clear(); } // Just in case things back up, ensure we write each one without clobbering via threads lock (TraceClient) { if (!TimeSpans.Any()) { return; } try { TraceClient.BatchWriteSpans(ProjectName, TimeSpans); } catch (Exception ex) { ErrorMessageAction?.Invoke("BTracingServiceGC->OnTimedEvent: " + ex.Message + ", Trace: " + ex.StackTrace); } } }
public static int Main(string[] args) { // Read projectId from args if (args.Length != 1) { Console.WriteLine("Usage: Project ID must be passed as first argument."); Console.WriteLine(); return(1); } string projectId = args[0]; // Create client TraceServiceClient client = TraceServiceClient.Create(); // Initialize request argument(s) ProjectName name = new ProjectName(projectId); IEnumerable <Span> spans = new List <Span>(); // Call API method client.BatchWriteSpans(name, spans); // Success Console.WriteLine("Smoke test passed OK"); return(0); }
/// <summary>Snippet for BatchWriteSpans</summary> public void BatchWriteSpansResourceNames() { // Snippet: BatchWriteSpans(ProjectName, IEnumerable<Span>, CallSettings) // Create client TraceServiceClient traceServiceClient = TraceServiceClient.Create(); // Initialize request argument(s) ProjectName name = ProjectName.FromProject("[PROJECT]"); IEnumerable <Span> spans = new Span[] { new Span(), }; // Make the request traceServiceClient.BatchWriteSpans(name, spans); // End snippet }
/// <summary>Snippet for BatchWriteSpans</summary> public void BatchWriteSpans() { // Snippet: BatchWriteSpans(string, IEnumerable<Span>, CallSettings) // Create client TraceServiceClient traceServiceClient = TraceServiceClient.Create(); // Initialize request argument(s) string name = "projects/[PROJECT]"; IEnumerable <Span> spans = new Span[] { new Span(), }; // Make the request traceServiceClient.BatchWriteSpans(name, spans); // End snippet }
/// <summary>Snippet for BatchWriteSpans</summary> public void BatchWriteSpans() { // Snippet: BatchWriteSpans(ProjectName,IEnumerable<apis::Span>,CallSettings) // Create client TraceServiceClient traceServiceClient = TraceServiceClient.Create(); // Initialize request argument(s) ProjectName name = new ProjectName("[PROJECT]"); IEnumerable <apis::Span> spans = new List <apis::Span>(); // Make the request traceServiceClient.BatchWriteSpans(name, spans); // End snippet }
/// <summary>Snippet for BatchWriteSpans</summary> public void BatchWriteSpansRequestObject() { // Snippet: BatchWriteSpans(BatchWriteSpansRequest, CallSettings) // Create client TraceServiceClient traceServiceClient = TraceServiceClient.Create(); // Initialize request argument(s) BatchWriteSpansRequest request = new BatchWriteSpansRequest { ProjectName = ProjectName.FromProject("[PROJECT]"), Spans = { new Span(), }, }; // Make the request traceServiceClient.BatchWriteSpans(request); // End snippet }