/// <summary> /// Returns of a list of traces that match the specified filter conditions. /// </summary> /// <param name="request"> /// The request object containing all of the parameters for the API call. /// </param> /// <param name="callSettings"> /// If not null, applies overrides to this RPC call. /// </param> /// <returns> /// A pageable sequence of <see cref="Trace"/> resources. /// </returns> public override PagedEnumerable <ListTracesResponse, Trace> ListTraces( ListTracesRequest request, CallSettings callSettings = null) { Modify_ListTracesRequest(ref request, ref callSettings); return(new GrpcPagedEnumerable <ListTracesRequest, ListTracesResponse, Trace>(_callListTraces, request, callSettings)); }
/// <summary> /// Returns of a list of traces that match the specified filter conditions. /// </summary> /// <param name="request"> /// The request object containing all of the parameters for the API call. /// </param> /// <param name="callSettings"> /// If not null, applies overrides to this RPC call. /// </param> /// <returns> /// A pageable asynchronous sequence of <see cref="Trace"/> resources. /// </returns> public override gax::PagedAsyncEnumerable <ListTracesResponse, Trace> ListTracesAsync( ListTracesRequest request, gaxgrpc::CallSettings callSettings = null) { Modify_ListTracesRequest(ref request, ref callSettings); return(new gaxgrpc::GrpcPagedAsyncEnumerable <ListTracesRequest, ListTracesResponse, Trace>(_callListTraces, request, callSettings)); }
/// <summary> /// Gets a trace that contains a span with the given name. /// </summary> /// <param name="expectTrace">True if the trace is expected to exist. This is used /// to minimize RPC calls.</param> private async Task <TraceProto> GetTrace(string spanName, bool expectTrace = true) { TimeSpan totalSleepTime = TimeSpan.Zero; while (totalSleepTime <= _timeout) { TimeSpan sleepTime = expectTrace ? _sleepInterval : _timeout; totalSleepTime += sleepTime; Thread.Sleep(sleepTime); ListTracesRequest request = new ListTracesRequest { ProjectId = _projectId, StartTime = _startTime, View = ListTracesRequest.Types.ViewType.Complete }; var traces = _client.ListTracesAsync(request); TraceProto trace = await traces.FirstOrDefault(t => t.Spans.Any(s => s.Name.Equals(spanName))); if (trace != null) { return(trace); } } return(null); }
/// <summary>Snippet for ListTracesAsync</summary> public async Task ListTracesRequestObjectAsync() { // Snippet: ListTracesAsync(ListTracesRequest, CallSettings) // Create client TraceServiceClient traceServiceClient = await TraceServiceClient.CreateAsync(); // Initialize request argument(s) ListTracesRequest request = new ListTracesRequest { ProjectId = "", View = ListTracesRequest.Types.ViewType.Unspecified, StartTime = new Timestamp(), EndTime = new Timestamp(), Filter = "", OrderBy = "", }; // Make the request PagedAsyncEnumerable <ListTracesResponse, Trace> response = traceServiceClient.ListTracesAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((Trace item) => { // Do something with each item Console.WriteLine(item); }); // Or iterate over pages (of server-defined size), performing one RPC per page await response.AsRawResponses().ForEachAsync((ListTracesResponse page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Trace item in page) { // Do something with each item Console.WriteLine(item); } }); // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <Trace> singlePage = await response.ReadPageAsync(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (Trace item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
/// <summary> /// Returns of a list of traces that match the specified filter conditions. /// </summary> /// <param name="projectId"> /// ID of the Cloud project where the trace data is stored. /// </param> /// <param name="pageToken"> /// The token returned from the previous request. /// A value of <c>null</c> or an empty string retrieves the first page. /// </param> /// <param name="pageSize"> /// The size of page to request. The response will not be larger than this, but may be smaller. /// A value of <c>null</c> or 0 uses a server-defined page size. /// </param> /// <param name="callSettings"> /// If not null, applies overrides to this RPC call. /// </param> /// <returns> /// A pageable sequence of <see cref="Trace"/> resources. /// </returns> public override IPagedEnumerable <ListTracesResponse, Trace> ListTraces( string projectId, string pageToken = null, int?pageSize = null, CallSettings callSettings = null) { ListTracesRequest request = new ListTracesRequest { ProjectId = projectId, PageToken = pageToken ?? "", PageSize = pageSize ?? 0, }; Modify_ListTracesRequest(ref request, ref callSettings); return(new PagedEnumerable <ListTracesRequest, ListTracesResponse, Trace>(_callListTraces, request, callSettings)); }
public void ListTraces_RequestObject() { // Snippet: ListTraces(ListTracesRequest,CallSettings) // Create client TraceServiceClient traceServiceClient = TraceServiceClient.Create(); // Initialize request argument(s) ListTracesRequest request = new ListTracesRequest { ProjectId = "", }; // Make the request PagedEnumerable <ListTracesResponse, Trace> response = traceServiceClient.ListTraces(request); // Iterate over all response items, lazily performing RPCs as required foreach (Trace item in response) { // Do something with each item Console.WriteLine(item); } // Or iterate over pages (of server-defined size), performing one RPC per page foreach (ListTracesResponse page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Trace item in page) { Console.WriteLine(item); } } // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <Trace> singlePage = response.ReadPage(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (Trace item in singlePage) { Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
/// <summary> /// Gets traces containing the giving <paramref name="spanName"/>. /// </summary> /// <param name="spanName"> The name for the traces to get.</param> /// <param name="startTime"> The start time of traces to get.</param> /// <param name="minEntries"> Optional. The minimum number of entries to expect. /// Default value is 1.</param> /// <param name="pageSize"> Optional. The page size to use when making RPC calls. /// Default value is 250.</param> /// <returns></returns> public IEnumerable <TraceProto> GetTraces(string spanName, Timestamp startTime, int minEntries = 1, int pageSize = 250) { var traceList = GetEntries(minEntries, () => { ListTracesRequest request = new ListTracesRequest { ProjectId = _projectId, StartTime = startTime, View = ListTracesRequest.Types.ViewType.Complete, Filter = $"span:\"{spanName}\"", PageSize = pageSize }; return(_client.ListTraces(request)); }); return(traceList); }
/// <summary> /// Gets a trace that contains a span with the given name. /// </summary> /// <param name="expectTrace">True if the trace is expected to exist. This is used /// to minimize RPC calls.</param> public TraceProto GetTrace(string spanName, Timestamp startTime, bool expectTrace = true) { var minEntries = expectTrace ? 1 : 0; var traceList = GetEntries(minEntries, () => { ListTracesRequest request = new ListTracesRequest { ProjectId = _projectId, StartTime = startTime, View = ListTracesRequest.Types.ViewType.Complete }; var traces = _client.ListTraces(request); return(traces.Where(t => t.Spans.Any(s => s.Name == spanName))); }); return(traceList.FirstOrDefault()); }
/// <summary> /// Gets a trace that contains a span with the given name. /// </summary> /// <param name="expectTrace">True if the trace is expected to exist. This is used /// to minimize RPC calls.</param> public TraceProto GetTrace(string spanName, Timestamp startTime, bool expectTrace = true) { var minEntries = expectTrace ? 1 : 0; var traceList = GetEntries(minEntries, () => { ListTracesRequest request = new ListTracesRequest { ProjectId = _projectId, StartTime = startTime, View = ListTracesRequest.Types.ViewType.Complete, Filter = $"span:\"{spanName}\"", PageSize = 250 }; return(_client.ListTraces(request)); }); return(traceList.FirstOrDefault()); }
/// <summary> /// Gets traces containing the giving <paramref name="spanName"/>. /// </summary> /// <param name="spanName"> The name for the traces to get.</param> /// <param name="startTime"> The start time of traces to get.</param> /// <param name="minEntries"> Optional. The minimum number of entries to expect. /// Default value is 1.</param> /// <param name="pageSize"> Optional. The page size to use when making RPC calls. /// Default value is 250.</param> /// <returns></returns> public IEnumerable <TraceProto> GetTraces(string spanName, DateTimeOffset startTime, int minEntries = 1, int pageSize = 250) { var traceList = GetEntries(minEntries, () => { ListTracesRequest request = new ListTracesRequest { ProjectId = _projectId, // We substract 5 minutes because on ocasion we were polling too fast after startTime // and the backend clock was a little behind, we were getting InvalidArgument. StartTime = Timestamp.FromDateTimeOffset(startTime - TimeSpan.FromMinutes(5)), View = ListTracesRequest.Types.ViewType.Complete, Filter = $"span:\"{spanName}\"", PageSize = pageSize }; return(_client.ListTraces(request)); }); return(traceList); }
partial void Modify_ListTracesRequest(ref ListTracesRequest request, ref gaxgrpc::CallSettings settings);
/// <summary> /// Returns of a list of traces that match the specified filter conditions. /// </summary> /// <param name="request"> /// The request object containing all of the parameters for the API call. /// </param> /// <param name="callSettings"> /// If not null, applies overrides to this RPC call. /// </param> /// <returns> /// A pageable sequence of <see cref="Trace"/> resources. /// </returns> public virtual gax::PagedEnumerable <ListTracesResponse, Trace> ListTraces( ListTracesRequest request, gaxgrpc::CallSettings callSettings = null) { throw new sys::NotImplementedException(); }
/// <summary> /// Returns of a list of traces that match the specified filter conditions. /// </summary> /// <param name="request"> /// The request object containing all of the parameters for the API call. /// </param> /// <param name="callSettings"> /// If not null, applies overrides to this RPC call. /// </param> /// <returns> /// A pageable sequence of <see cref="Trace"/> resources. /// </returns> public virtual PagedEnumerable <ListTracesResponse, Trace> ListTraces( ListTracesRequest request, CallSettings callSettings = null) { throw new NotImplementedException(); }