class Google::Cloud::Trace::Service
Represents the connection to Trace
, and exposes the API calls.
@private
Attributes
credentials[RW]
host[RW]
mocked_lowlevel_client[RW]
project[RW]
timeout[RW]
Public Class Methods
new(project, credentials, timeout: nil, host: nil)
click to toggle source
Creates a new Service
instance.
# File lib/google/cloud/trace/service.rb, line 37 def initialize project, credentials, timeout: nil, host: nil @project = project @credentials = credentials @timeout = timeout @host = host end
Public Instance Methods
get_trace(trace_id)
click to toggle source
Returns a trace given its ID
# File lib/google/cloud/trace/service.rb, line 82 def get_trace trace_id trace_proto = lowlevel_client.get_trace project_id: @project, trace_id: trace_id Google::Cloud::Trace::TraceRecord.from_grpc trace_proto end
inspect()
click to toggle source
@private
# File lib/google/cloud/trace/service.rb, line 123 def inspect "#{self.class}(#{@project})" end
list_traces(project_id, start_time, end_time, filter: nil, order_by: nil, view: nil, page_size: nil, page_token: nil)
click to toggle source
Searches for traces matching the given criteria.
# File lib/google/cloud/trace/service.rb, line 90 def list_traces project_id, start_time, end_time, filter: nil, order_by: nil, view: nil, page_size: nil, page_token: nil start_proto = Google::Cloud::Trace::Utils.time_to_grpc start_time end_proto = Google::Cloud::Trace::Utils.time_to_grpc end_time paged_enum = lowlevel_client.list_traces project_id: project_id, view: view, page_size: page_size, start_time: start_proto, end_time: end_proto, filter: filter, order_by: order_by, page_token: page_token Google::Cloud::Trace::ResultSet.from_gapic_page \ self, project_id, paged_enum.page, start_time, end_time, filter: filter, order_by: order_by, view: view, page_size: page_size, page_token: page_token end
lowlevel_client()
click to toggle source
# File lib/google/cloud/trace/service.rb, line 47 def lowlevel_client return mocked_lowlevel_client if mocked_lowlevel_client @lowlevel_client ||= \ begin require "grpc" require "google/cloud/trace/patches/active_call_with_trace" require "google/cloud/trace/patches/call_with_trace" V1::TraceService::Client.new do |config| config.credentials = credentials if credentials config.timeout = timeout if timeout config.endpoint = host if host config.lib_name = "gccl" config.lib_version = Google::Cloud::Trace::VERSION end end end
patch_traces(traces)
click to toggle source
Sends new traces to Stackdriver Trace
or updates existing traces.
# File lib/google/cloud/trace/service.rb, line 69 def patch_traces traces traces = Array(traces) traces_proto = Google::Cloud::Trace::V1::Traces.new traces.each do |trace| traces_proto.traces.push trace.to_grpc end lowlevel_client.patch_traces project_id: @project, traces: traces_proto traces end