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)


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

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)


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

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}) getMetricsSnapshot(measured) - (Hash{String => Object}) getMetricsSnapshot(baseName)

Will return the metrics that begins with the baseName, 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.

Overloads:

  • - (Hash{String => Object}) getMetricsSnapshot(measured)

    Parameters:

    • measured (::Vertx::Measured)
  • - (Hash{String => Object}) getMetricsSnapshot(baseName)

    Parameters:

    • baseName (String)

Returns:

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

Raises:

  • (ArgumentError)


53
54
55
56
57
58
59
60
# File '/Users/julien/java/vertx-aggregator/modules/vertx-dropwizard-metrics/src/main/resources/vertx-dropwizard/metrics_service.rb', line 53

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

- (Set<String>) metrics_names

@return the known metrics names by this service

Returns:

  • (Set<String>)

Raises:

  • (ArgumentError)


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

def metrics_names
  if !block_given?
    return ::Vertx::Util::Utils.to_set(@j_del.java_method(:metricsNames, []).call()).map! { |elt| elt }
  end
  raise ArgumentError, "Invalid arguments when calling metrics_names()"
end