Sha256: e85469c354a3d41dcf4f6446a66e2ccb422d7771c2179942ff2adbe6d6076fe5

Contents?: true

Size: 719 Bytes

Versions: 2

Compression:

Stored size: 719 Bytes

Contents

module InfluxDB
  module Rails
    class Tags
      def initialize(tags: {}, config:, additional_tags: InfluxDB::Rails.current.tags)
        @tags = tags
        @config = config
        @additional_tags = additional_tags
      end

      def to_h
        expanded_tags.reject do |_, value|
          value.nil? || value == ""
        end
      end

      private

      attr_reader :additional_tags, :tags, :config

      def expanded_tags
        config.tags_middleware.call(tags.merge(default_tags))
      end

      def default_tags
        {
          server:   Socket.gethostname,
          app_name: config.application_name,
          location: :raw,
        }.merge(additional_tags)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
influxdb-rails-1.0.1.beta2 lib/influxdb/rails/tags.rb
influxdb-rails-1.0.1.beta1 lib/influxdb/rails/tags.rb