Class: VertxMicrometerMetrics::MetricsService

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-micrometer-metrics/metrics_service.rb

Overview

The metrics service mainly allows to return a snapshot of measured objects.
This service is derived and adapted from MetricsService in the vertx-dropwizard-metrics module.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


19
20
21
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-micrometer-metrics/metrics_service.rb', line 19

def @@j_api_type.accept?(obj)
  obj.class == MetricsService
end

+ (::VertxMicrometerMetrics::MetricsService) create(measured = nil)

Creates a metric service for a given object.

Parameters:

Returns:

Raises:

  • (ArgumentError)


37
38
39
40
41
42
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-micrometer-metrics/metrics_service.rb', line 37

def self.create(measured=nil)
  if measured.class.method_defined?(:j_del) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxMicrometer::MetricsService.java_method(:create, [Java::IoVertxCoreMetrics::Measured.java_class]).call(measured.j_del),::VertxMicrometerMetrics::MetricsService)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{measured})"
end

+ (Object) j_api_type



28
29
30
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-micrometer-metrics/metrics_service.rb', line 28

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



31
32
33
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-micrometer-metrics/metrics_service.rb', line 31

def self.j_class
  Java::IoVertxMicrometer::MetricsService.java_class
end

+ (Object) unwrap(obj)



25
26
27
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-micrometer-metrics/metrics_service.rb', line 25

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



22
23
24
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-micrometer-metrics/metrics_service.rb', line 22

def @@j_api_type.wrap(obj)
  MetricsService.new(obj)
end

Instance Method Details

- (String) get_base_name

Returns the base name of the measured object

Returns:

  • (String)
    the base name of the measured object

Raises:

  • (ArgumentError)


44
45
46
47
48
49
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-micrometer-metrics/metrics_service.rb', line 44

def get_base_name
  if !block_given?
    return @j_del.java_method(:getBaseName, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling get_base_name()"
end

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

Will return the metrics that begins with the baseName, null if no metrics is available.

Parameters:

  • baseName (String) (defaults to: nil)

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)


60
61
62
63
64
65
66
67
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-micrometer-metrics/metrics_service.rb', line 60

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

- (Set<String>) metrics_names

Returns the known metrics names by this service

Returns:

  • (Set<String>)
    the known metrics names by this service

Raises:

  • (ArgumentError)


51
52
53
54
55
56
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-micrometer-metrics/metrics_service.rb', line 51

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