Sha256: 5bf9e05ead030b89f5b67c5a3aa61dd28af49134449080a196ae7684271b2b66

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 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.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

1 entries across 1 versions & 1 rubygems

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