Class: VertxDropwizard::MetricsService

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-dropwizard-metrics/src/main/resources/vertx-dropwizard/metrics_service.rb

Overview

The metrics service mainly allows to return a snapshot of measured objects.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (::VertxDropwizard::MetricsService) create(vertx = nil)

Creates a metric service for a given Vertx::Vertx instance.

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the vertx instance

Returns:

Raises:

  • (ArgumentError)


20
21
22
23
24
25
# File '/Users/julien/java/vertx-aggregator/modules/vertx-dropwizard-metrics/src/main/resources/vertx-dropwizard/metrics_service.rb', line 20

def self.create(vertx=nil)
  if vertx.class.method_defined?(:j_del) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtDropwizard::MetricsService.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxDropwizard::MetricsService)
  end
  raise ArgumentError, "Invalid arguments when calling create(vertx)"
end

Instance Method Details

- (String) get_base_name(measured = nil)

@param measured the measure object

Parameters:

  • measured (::Vertx::Measured) (defaults to: nil)

Returns:

  • (String)
    the base name of the measured object

Raises:

  • (ArgumentError)


41
42
43
44
45
46
# File '/Users/julien/java/vertx-aggregator/modules/vertx-dropwizard-metrics/src/main/resources/vertx-dropwizard/metrics_service.rb', line 41

def get_base_name(measured=nil)
  if measured.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:getBaseName, [Java::IoVertxCoreMetrics::Measured.java_class]).call(measured.j_del)
  end
  raise ArgumentError, "Invalid arguments when calling get_base_name(measured)"
end

- (Hash{String => Object}) get_metrics_snapshot(o = nil)

Will return the metrics that correspond with this measured object, null if no metrics is available.

Note: in the case of scaled servers, the JsonObject returns an aggregation of the metrics as the dropwizard backend reports to a single server.

Parameters:

  • o (::Vertx::Measured) (defaults to: nil)

Returns:

  • (Hash{String => Object})
    the map of metrics where the key is the name of the metric (excluding the base name) and the value is the json data representing that metric

Raises:

  • (ArgumentError)


32
33
34
35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-dropwizard-metrics/src/main/resources/vertx-dropwizard/metrics_service.rb', line 32

def get_metrics_snapshot(o=nil)
  if o.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:getMetricsSnapshot, [Java::IoVertxCoreMetrics::Measured.java_class]).call(o.j_del) != nil ? JSON.parse(@j_del.java_method(:getMetricsSnapshot, [Java::IoVertxCoreMetrics::Measured.java_class]).call(o.j_del).encode) : nil
  end
  raise ArgumentError, "Invalid arguments when calling get_metrics_snapshot(o)"
end