Class: Wavefront::Spy

Inherits:
CoreApi show all
Defined in:
lib/wavefront-sdk/spy.rb

Overview

Spy on data going into Wavefront

Instance Attribute Summary

Attributes inherited from CoreApi

#api, #creds, #logger, #opts, #update_keys

Instance Method Summary collapse

Methods inherited from CoreApi

#api_base, #hash_for_update, #initialize, #setup_api, #time_to_ms

Methods included from Mixins

#log, #parse_relative_time, #parse_time, #relative_time, #time_multiplier, #valid_relative_time?

Methods included from Validators

#uuid?, #wf_account_id?, #wf_alert_id?, #wf_alert_severity?, #wf_apitoken_id?, #wf_aws_external_id?, #wf_cloudintegration_id?, #wf_dashboard_id?, #wf_derivedmetric_id?, #wf_distribution?, #wf_distribution_count?, #wf_distribution_interval?, #wf_distribution_values?, #wf_epoch?, #wf_event_id?, #wf_granularity?, #wf_ingestionpolicy_id?, #wf_integration_id?, #wf_link_id?, #wf_link_template?, #wf_maintenance_window_id?, #wf_message_id?, #wf_metric_name?, #wf_metricspolicy_id?, #wf_monitoredapplication_id?, #wf_monitoredcluster_id?, #wf_ms_ts?, #wf_name?, #wf_notificant_id?, #wf_permission?, #wf_point?, #wf_point_tag?, #wf_point_tags?, #wf_proxy_id?, #wf_role_id?, #wf_sampling_value?, #wf_savedsearch_entity?, #wf_savedsearch_id?, #wf_serviceaccount_id?, #wf_source_id?, #wf_spansamplingpolicy_id?, #wf_string?, #wf_tag?, #wf_trace?, #wf_ts?, #wf_user_id?, #wf_usergroup_id?, #wf_value?, #wf_version?, #wf_webhook_id?

Constructor Details

This class inherits a constructor from Wavefront::CoreApi

Instance Method Details

#_response_shim(resp, status) ⇒ Object

We have to try to make the response we get from the API look like the one we get from the public API. To begin with, it’s nothing like it.

This method must be public because a #respond_to? looks for it.



105
106
107
108
109
110
# File 'lib/wavefront-sdk/spy.rb', line 105

def _response_shim(resp, status)
  { response: parse_response(resp),
    status: { result: status == 200 ? 'OK' : 'ERROR',
              message: extract_api_message(status, resp),
              code: status } }.to_json
end

#api_pathObject



94
95
96
# File 'lib/wavefront-sdk/spy.rb', line 94

def api_path
  '/api/spy'
end

#deltas(sampling = 0.01, filters = {}, options = {}) ⇒ Nil

GET /api/spy/deltas Gets new deltas that are added to existing time series.

Parameters:

  • sampling (Float) (defaults to: 0.01)

    see #points

  • filter (Hash)

    see #points

  • options (Hash) (defaults to: {})

    see #points

Returns:

  • (Nil)

Raises:

  • Wavefront::Exception::InvalidSamplingValue



43
44
45
46
47
48
# File 'lib/wavefront-sdk/spy.rb', line 43

def deltas(sampling = 0.01, filters = {}, options = {})
  wf_sampling_value?(sampling)
  api.get_stream('deltas',
                 deltas_filter(sampling, filters),
                 options)
end

#histograms(sampling = 0.01, filters = {}, options = {}) ⇒ Nil

GET /api/spy/histograms Gets new histograms that are added to existing time series.

Parameters:

  • sampling (Float) (defaults to: 0.01)

    see #points

  • filter (Hash)

    see #points

  • options (Hash) (defaults to: {})

    see #points

Returns:

  • (Nil)

Raises:

  • Wavefront::Exception::InvalidSamplingValue



58
59
60
61
62
63
# File 'lib/wavefront-sdk/spy.rb', line 58

def histograms(sampling = 0.01, filters = {}, options = {})
  wf_sampling_value?(sampling)
  api.get_stream('histograms',
                 histograms_filter(sampling, filters),
                 options)
end

#ids(sampling = 0.01, filters = {}, options = {}) ⇒ Object

GET /api/spy/ids Gets newly allocated IDs that correspond to new metric names, source names, point tags, or span tags. A new ID generally indicates that a new time series has been introduced.

Parameters:

  • sampling (Float) (defaults to: 0.01)

    see #points

  • filter (Hash)

    with keys: :prefix [String] only list assignments whose metric name begins with

    this case-sensitive string
    

    :type [String] one of METRIC, SPAN, HOST or STRING

  • options (Hash) (defaults to: {})

    see #points



89
90
91
92
# File 'lib/wavefront-sdk/spy.rb', line 89

def ids(sampling = 0.01, filters = {}, options = {})
  wf_sampling_value?(sampling)
  api.get_stream('ids', ids_filter(sampling, filters), options)
end

#points(sampling = 0.01, filters = {}, options = {}) ⇒ Nil

GET /api/spy/points Gets new metric data points that are added to existing time series.

Parameters:

  • sampling (Float) (defaults to: 0.01)

    the amount of points to sample, from 0 (none) to 1 (all)

  • filter (Hash)

    with the following keys: :prefix [String] only list points whose metric name begins with this

    case-sensitive string
    

    :host [Array] only list points if source name begins with this

    case-sensitive string
    

    :tag_key [String,Array] only list points with one or more of

    the given points tags
    
  • options (Hash) (defaults to: {})

    with the following keys :timestamp [Boolean] prefix each block of streamed data with a

    timestamp
    

    :timeout [Integer] how many seconds to run the spy. After this time

    the method returns
    

Returns:

  • (Nil)

Raises:

  • Wavefront::Exception::InvalidSamplingValue



30
31
32
33
# File 'lib/wavefront-sdk/spy.rb', line 30

def points(sampling = 0.01, filters = {}, options = {})
  wf_sampling_value?(sampling)
  api.get_stream('points', points_filter(sampling, filters), options)
end

#spans(sampling = 0.01, filters = {}, options = {}) ⇒ Nil

GET /api/spy/spans Gets new spans with existing source names and span tags.

Parameters:

  • sampling (Float) (defaults to: 0.01)

    see #points

  • filter (Hash)

    see #points

  • options (Hash) (defaults to: {})

    see #points

Returns:

  • (Nil)

Raises:

  • Wavefront::Exception::InvalidSamplingValue



73
74
75
76
# File 'lib/wavefront-sdk/spy.rb', line 73

def spans(sampling = 0.01, filters = {}, options = {})
  wf_sampling_value?(sampling)
  api.get_stream('spans', spans_filter(sampling, filters), options)
end