Sha256: 7adb80d8227b5769b30299100cce6e2f159b254baaf6f2828a3ad59065431219

Contents?: true

Size: 711 Bytes

Versions: 2

Compression:

Stored size: 711 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.to_s.blank?
        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.3 lib/influxdb/rails/tags.rb
influxdb-rails-1.0.2 lib/influxdb/rails/tags.rb