Class: Wavefront::Unstable::Spy

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

Overview

THIS IS AN UNSTABLE CLASS. PLEASE REFER TO README.md.

Everything about this API is different from the public one. To make it appear similar we must change various things we normally take for granted.

This class is built according to the documentation at docs.wavefront.com/wavefront_monitoring_spy.html

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_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_monitoredcluster_id?, #wf_ms_ts?, #wf_name?, #wf_notificant_id?, #wf_permission?, #wf_point?, #wf_point_tag?, #wf_point_tags?, #wf_proxy_id?, #wf_sampling_value?, #wf_savedsearch_entity?, #wf_savedsearch_id?, #wf_serviceaccount_id?, #wf_source_id?, #wf_string?, #wf_tag?, #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.



97
98
99
100
101
102
# File 'lib/wavefront-sdk/unstable/spy.rb', line 97

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



86
87
88
# File 'lib/wavefront-sdk/unstable/spy.rb', line 86

def api_path
  '/api/spy'
end

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

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



50
51
52
53
54
55
# File 'lib/wavefront-sdk/unstable/spy.rb', line 50

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

https://<cluster>.wavefront.com/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



81
82
83
84
# File 'lib/wavefront-sdk/unstable/spy.rb', line 81

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

https://<cluster>.wavefront.com/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



38
39
40
41
# File 'lib/wavefront-sdk/unstable/spy.rb', line 38

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

https://<cluster>.wavefront.com/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



65
66
67
68
# File 'lib/wavefront-sdk/unstable/spy.rb', line 65

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