Class: ScoutApmMcp::Client

Inherits:
Object
  • Object
show all
Includes:
Api::AnomalyEvents, Api::Apps, Api::Endpoints, Api::ErrorGroups, Api::Insights, Api::Jobs, Api::Metrics, Api::OpenApi, Api::Traces, HttpTransport, QueryParams, Validation
Defined in:
lib/scout_apm_mcp/client.rb,
lib/scout_apm_mcp/client/api.rb,
lib/scout_apm_mcp/client/validation.rb,
lib/scout_apm_mcp/client/query_params.rb,
lib/scout_apm_mcp/client/http_transport.rb,
sig/scout_apm_mcp.rbs

Overview

ScoutAPM API client for making authenticated requests to the ScoutAPM API

Examples:

api_key = ScoutApmMcp::Helpers.get_api_key
client = ScoutApmMcp::Client.new(api_key: api_key)
apps = client.list_apps
trace = client.fetch_trace(123, 456)

Defined Under Namespace

Modules: Api, HttpTransport, QueryParams, Validation

Constant Summary collapse

API_BASE =
"https://scoutapm.com/api/v0"
VALID_METRICS =
%w[apdex response_time response_time_95th errors throughput queue_time].freeze
VALID_INSIGHTS =
%w[n_plus_one memory_bloat slow_query].freeze
VALID_JOB_METRICS =
%w[throughput execution_time latency errors allocations].freeze
VALID_ENDPOINT_SORT_BY =
%w[time_consumed response_time throughput error_rate].freeze
VALID_ANOMALY_STATES =
%w[open closed all].freeze
MAX_REQUEST_ATTEMPTS =
3
RETRY_BASE_DELAY_SECONDS =
0.5
RETRYABLE_HTTP_STATUS_CODES =
(500..599)

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, api_base: API_BASE) ⇒ Client

Returns a new instance of Client.

Parameters:

  • api_key (String)

    ScoutAPM API key

  • api_base (String) (defaults to: API_BASE)

    API base URL (default: https://scoutapm.com/api/v0)

  • api_key: (String)
  • api_base: (String) (defaults to: API_BASE)

Raises:

  • (ArgumentError)

    if api_key is nil or empty



52
53
54
55
56
57
58
59
# File 'lib/scout_apm_mcp/client.rb', line 52

def initialize(api_key:, api_base: API_BASE)
  if api_key.nil? || api_key.to_s.strip.empty?
    raise ArgumentError, "API key is required and cannot be nil or empty"
  end
  @api_key = api_key.to_s
  @api_base = api_base
  @user_agent = "scout-apm-mcp-rb/#{VERSION}"
end

Instance Method Details

#build_http_clientNet::HTTP

Parameters:

  • uri (URI)

Returns:

  • (Net::HTTP)


13
# File 'sig/scout_apm_mcp.rbs', line 13

def build_http_client: (URI uri) -> Net::HTTP

#fetch_openapi_schemaHash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


36
# File 'sig/scout_apm_mcp.rbs', line 36

def fetch_openapi_schema: () -> Hash[Symbol, untyped]

#fetch_traceHash[String, untyped]

Parameters:

  • app_id (Integer)
  • trace_id (Integer)

Returns:

  • (Hash[String, untyped])


26
# File 'sig/scout_apm_mcp.rbs', line 26

def fetch_trace: (Integer app_id, Integer trace_id) -> Hash[String, untyped]

#get_all_insightsHash[String, untyped]

Parameters:

  • app_id (Integer)
  • limit: (Integer, nil)

Returns:

  • (Hash[String, untyped])


32
# File 'sig/scout_apm_mcp.rbs', line 32

def get_all_insights: (Integer app_id, ?limit: Integer?) -> Hash[String, untyped]

#get_anomaly_eventHash[String, untyped]

Parameters:

  • app_id (Integer)
  • anomaly_event_id (Integer)

Returns:

  • (Hash[String, untyped])


31
# File 'sig/scout_apm_mcp.rbs', line 31

def get_anomaly_event: (Integer app_id, Integer anomaly_event_id) -> Hash[String, untyped]

#get_appHash[String, untyped]

Parameters:

  • app_id (Integer)

Returns:

  • (Hash[String, untyped])


16
# File 'sig/scout_apm_mcp.rbs', line 16

def get_app: (Integer app_id) -> Hash[String, untyped]

#get_endpoint_metricsHash[String, untyped]

Parameters:

  • app_id (Integer)
  • endpoint_id (String)
  • metric_type (String)
  • from: (String, nil)
  • to: (String, nil)

Returns:

  • (Hash[String, untyped])


20
# File 'sig/scout_apm_mcp.rbs', line 20

def get_endpoint_metrics: (Integer app_id, String endpoint_id, String metric_type, ?from: String?, ?to: String?) -> Hash[String, untyped]

#get_error_groupHash[String, untyped]

Parameters:

  • app_id (Integer)
  • error_id (Integer)

Returns:

  • (Hash[String, untyped])


28
# File 'sig/scout_apm_mcp.rbs', line 28

def get_error_group: (Integer app_id, Integer error_id) -> Hash[String, untyped]

#get_error_group_errorsHash[String, untyped]

Parameters:

  • app_id (Integer)
  • error_id (Integer)

Returns:

  • (Hash[String, untyped])


29
# File 'sig/scout_apm_mcp.rbs', line 29

def get_error_group_errors: (Integer app_id, Integer error_id) -> Hash[String, untyped]

#get_insight_by_typeHash[String, untyped]

Parameters:

  • app_id (Integer)
  • insight_type (String)
  • limit: (Integer, nil)

Returns:

  • (Hash[String, untyped])


33
# File 'sig/scout_apm_mcp.rbs', line 33

def get_insight_by_type: (Integer app_id, String insight_type, ?limit: Integer?) -> Hash[String, untyped]

#get_insights_historyHash[String, untyped]

Parameters:

  • app_id (Integer)
  • from: (String, nil)
  • to: (String, nil)
  • limit: (Integer, nil)
  • pagination_cursor: (Integer, nil)
  • pagination_direction: (String, nil)
  • pagination_page: (Integer, nil)

Returns:

  • (Hash[String, untyped])


34
# File 'sig/scout_apm_mcp.rbs', line 34

def get_insights_history: (Integer app_id, ?from: String?, ?to: String?, ?limit: Integer?, ?pagination_cursor: Integer?, ?pagination_direction: String?, ?pagination_page: Integer?) -> Hash[String, untyped]

#get_insights_history_by_typeHash[String, untyped]

Parameters:

  • app_id (Integer)
  • insight_type (String)
  • from: (String, nil)
  • to: (String, nil)
  • limit: (Integer, nil)
  • pagination_cursor: (Integer, nil)
  • pagination_direction: (String, nil)
  • pagination_page: (Integer, nil)

Returns:

  • (Hash[String, untyped])


35
# File 'sig/scout_apm_mcp.rbs', line 35

def get_insights_history_by_type: (Integer app_id, String insight_type, ?from: String?, ?to: String?, ?limit: Integer?, ?pagination_cursor: Integer?, ?pagination_direction: String?, ?pagination_page: Integer?) -> Hash[String, untyped]

#get_job_metricsObject

Parameters:

  • app_id (Integer)
  • job_id (String)
  • metric_type (String)
  • from: (String, nil)
  • to: (String, nil)
  • range: (String, nil)

Returns:

  • (Object)


24
# File 'sig/scout_apm_mcp.rbs', line 24

def get_job_metrics: (Integer app_id, String job_id, String metric_type, ?from: String?, ?to: String?, ?range: String?) -> untyped

#get_metricHash[String, untyped]

Parameters:

  • app_id (Integer)
  • metric_type (String)
  • from: (String, nil)
  • to: (String, nil)

Returns:

  • (Hash[String, untyped])


18
# File 'sig/scout_apm_mcp.rbs', line 18

def get_metric: (Integer app_id, String metric_type, ?from: String?, ?to: String?) -> Hash[String, untyped]

#list_anomaly_eventsArray[untyped]

Parameters:

  • app_id (Integer)
  • from: (String, nil)
  • to: (String, nil)
  • range: (String, nil)
  • state: (String, nil)
  • metric: (String, nil)
  • endpoint: (String, nil)

Returns:

  • (Array[untyped])


30
# File 'sig/scout_apm_mcp.rbs', line 30

def list_anomaly_events: (Integer app_id, ?from: String?, ?to: String?, ?range: String?, ?state: String?, ?metric: String?, ?endpoint: String?) -> Array[untyped]

#list_appsArray[untyped]

Parameters:

  • active_since: (String, nil)

Returns:

  • (Array[untyped])


15
# File 'sig/scout_apm_mcp.rbs', line 15

def list_apps: (?active_since: String?) -> Array[untyped]

#list_endpoint_tracesArray[untyped]

Parameters:

  • app_id (Integer)
  • endpoint_id (String)
  • from: (String, nil)
  • to: (String, nil)
  • range: (String, nil)

Returns:

  • (Array[untyped])


21
# File 'sig/scout_apm_mcp.rbs', line 21

def list_endpoint_traces: (Integer app_id, String endpoint_id, ?from: String?, ?to: String?, ?range: String?) -> Array[untyped]

#list_endpointsArray[untyped], Hash[String, untyped]

Parameters:

  • app_id (Integer)
  • from: (String, nil)
  • to: (String, nil)
  • range: (String, nil)
  • sort_by: (String, nil)
  • limit: (Integer, nil)
  • offset: (Integer, nil)

Returns:

  • (Array[untyped], Hash[String, untyped])


19
# File 'sig/scout_apm_mcp.rbs', line 19

def list_endpoints: (Integer app_id, ?from: String?, ?to: String?, ?range: String?, ?sort_by: String?, ?limit: Integer?, ?offset: Integer?) -> (Array[untyped] | Hash[String, untyped])

#list_error_groupsHash[String, untyped]

Parameters:

  • app_id (Integer)
  • from: (String, nil)
  • to: (String, nil)
  • endpoint: (String, nil)

Returns:

  • (Hash[String, untyped])


27
# File 'sig/scout_apm_mcp.rbs', line 27

def list_error_groups: (Integer app_id, ?from: String?, ?to: String?, ?endpoint: String?) -> Hash[String, untyped]

#list_job_metricsObject

Parameters:

  • app_id (Integer)
  • job_id (String)

Returns:

  • (Object)


23
# File 'sig/scout_apm_mcp.rbs', line 23

def list_job_metrics: (Integer app_id, String job_id) -> untyped

#list_job_tracesObject

Parameters:

  • app_id (Integer)
  • job_id (String)
  • from: (String, nil)
  • to: (String, nil)
  • range: (String, nil)

Returns:

  • (Object)


25
# File 'sig/scout_apm_mcp.rbs', line 25

def list_job_traces: (Integer app_id, String job_id, ?from: String?, ?to: String?, ?range: String?) -> untyped

#list_jobsObject

Parameters:

  • app_id (Integer)
  • from: (String, nil)
  • to: (String, nil)
  • range: (String, nil)

Returns:

  • (Object)


22
# File 'sig/scout_apm_mcp.rbs', line 22

def list_jobs: (Integer app_id, ?from: String?, ?to: String?, ?range: String?) -> untyped

#list_metricsHash[String, untyped]

Parameters:

  • app_id (Integer)

Returns:

  • (Hash[String, untyped])


17
# File 'sig/scout_apm_mcp.rbs', line 17

def list_metrics: (Integer app_id) -> Hash[String, untyped]