class OpConnect::Client
Public Class Methods
# File lib/op_connect/client.rb, line 15 def initialize(options = {}) OpConnect::Configurable.keys.each do |key| value = options.key?(key) ? options[key] : OpConnect.instance_variable_get(:"@#{key}") instance_variable_set(:"@#{key}", value) end end
Public Instance Methods
Retrieve a list of API requests that have been made.
@param params [Hash] Optional parameters. @option params [Integer] :limit How many API Events should be returned
in a single request.
@option params [Integer] :offset How far into the collection of API
Events should the response start.
@return [Array<APIRequest>]
# File lib/op_connect/client.rb, line 42 def activity(**params) get("activity", params: params).body.map { |a| APIRequest.new(a) } end
Query the state of the server and its service dependencies.
@return [ServerHealth] Returns a ‘ServerHealth` object.
# File lib/op_connect/client.rb, line 61 def health ServerHealth.new get("/health").body end
Simple “ping” endpoint to check whether the server is active.
@return [Boolean] Returns true if the server is active, false otherwise.
# File lib/op_connect/client.rb, line 50 def heartbeat return true if get("/heartbeat").status == 200 false rescue OpConnect::Error false end
Text representation of the client, masking tokens.
@return [String]
# File lib/op_connect/client.rb, line 26 def inspect inspected = super inspected.gsub!(@access_token, ("*" * 24).to_s) if @access_token inspected end
Returns Prometheus metrics collected by the server.
@return [String] Returns a plain text list of Prometheus metrics.
@see prometheus.io/docs/instrumenting/exposition_formats/#text-based-format
Prometheus documentation
# File lib/op_connect/client.rb, line 72 def metrics get("/metrics").body end