Module: Google::Cloud

Defined in:
lib/google-cloud-trace.rb,
lib/google/cloud/trace.rb,
lib/google/cloud/trace/v2.rb,
lib/google/cloud/trace/span.rb,
lib/google/cloud/trace/rails.rb,
lib/google/cloud/trace/utils.rb,
lib/google/cloud/trace/project.rb,
lib/google/cloud/trace/service.rb,
lib/google/cloud/trace/version.rb,
lib/google/cloud/trace/label_key.rb,
lib/google/cloud/trace/span_kind.rb,
lib/google/cloud/trace/middleware.rb,
lib/google/cloud/trace/result_set.rb,
lib/google/cloud/trace/credentials.rb,
lib/google/cloud/trace/time_sampler.rb,
lib/google/cloud/trace/trace_record.rb,
lib/google/cloud/trace/notifications.rb,
lib/google/cloud/trace/async_reporter.rb,
lib/google/cloud/trace/v1/doc/overview.rb,
lib/google/cloud/trace/v2/doc/overview.rb,
lib/google/cloud/trace/faraday_middleware.rb,
lib/google/cloud/trace/v1/trace_service_client.rb,
lib/google/cloud/trace/v2/trace_service_client.rb

Defined Under Namespace

Modules: Trace

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.trace(project_id = nil, credentials = nil, scope: nil, timeout: nil, client_config: nil) ⇒ Google::Cloud::Trace::Project

Creates a new object for connecting to the Stackdriver Trace service. Each call creates a new connection.

For more information on connecting to Google Cloud see the Authentication Guide.

Examples:

require "google/cloud"

trace_client = Google::Cloud.trace

traces = trace_client.list_traces Time.now - 3600, Time.now
traces.each do |trace|
  puts "Retrieved trace ID: #{trace.trace_id}"
end

Parameters:

  • project_id (String) (defaults to: nil)

    Project identifier for the Stackdriver Trace service you are connecting to. If not present, the default project for the credentials is used.

  • credentials (String, Hash, Google::Auth::Credentials) (defaults to: nil)

    The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Google::Cloud::Trace::Credentials)

  • scope (String, Array<String>) (defaults to: nil)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/cloud-platform
  • timeout (Integer) (defaults to: nil)

    Default timeout to use in requests. Optional.

Returns:



101
102
103
104
105
106
107
# File 'lib/google-cloud-trace.rb', line 101

def self.trace project_id = nil, credentials = nil, scope: nil,
               timeout: nil, client_config: nil
  require "google/cloud/trace"
  Google::Cloud::Trace.new project_id: project_id, credentials: credentials,
                           scope: scope, timeout: timeout,
                           client_config: client_config
end

Instance Method Details

#trace(scope: nil, timeout: nil, client_config: nil) ⇒ Google::Cloud::Trace::Project

Creates a new object for connecting to the Stackdriver Trace service. Each call creates a new connection.

For more information on connecting to Google Cloud see the Authentication Guide.

Examples:

require "google/cloud"

gcloud = Google::Cloud.new
trace_client = gcloud.trace

traces = trace_client.list_traces Time.now - 3600, Time.now
traces.each do |trace|
  puts "Retrieved trace ID: #{trace.trace_id}"
end

Parameters:

  • scope (String, Array<String>) (defaults to: nil)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/cloud-platform
  • timeout (Integer) (defaults to: nil)

    Default timeout to use in requests. Optional.

Returns:



59
60
61
62
63
# File 'lib/google-cloud-trace.rb', line 59

def trace scope: nil, timeout: nil, client_config: nil
  Google::Cloud.trace @project, @keyfile, scope: scope,
                                          timeout: (timeout || @timeout),
                                          client_config: client_config
end