Sha256: 02d96ad873b6a8d68b06657b1b722048fa8aadd58ffd687bb8dde55afa2e8601

Contents?: true

Size: 719 Bytes

Versions: 1

Compression:

Stored size: 719 Bytes

Contents

module InfluxDB
  module Rails
    class Tags
      def initialize(config:, tags: {}, 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

1 entries across 1 versions & 1 rubygems

Version Path
influxdb-rails-1.0.1.beta3 lib/influxdb/rails/tags.rb