Sha256: 5530435c5a9a6ea21a94ba6b0b7107a556431edf39b3b0b16c58068c940cd18c

Contents?: true

Size: 1.07 KB

Versions: 20

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module ElasticAPM
  # @api private
  class ServiceInfo
    def initialize(config)
      @config = config
    end

    # rubocop:disable Metrics/MethodLength
    def build
      base = {
        name: @config.service_name,
        environment: @config.environment,
        agent: {
          name: 'ruby',
          version: VERSION
        },
        framework: nil,
        language: {
          name: 'ruby',
          version: RUBY_VERSION
        },
        runtime: runtime,
        version: @config.service_version || Util.git_sha
      }

      if @config.framework_name
        base[:framework] = {
          name: @config.framework_name,
          version: @config.framework_version
        }
      end

      base
    end
    # rubocop:enable Metrics/MethodLength

    def self.build(config)
      new(config).build
    end

    private

    def runtime
      case RUBY_ENGINE
      when 'ruby'
        { name: RUBY_ENGINE, version: RUBY_VERSION }
      when 'jruby'
        { name: RUBY_ENGINE, version: ENV['JRUBY_VERSION'] }
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
elastic-apm-1.0.1 lib/elastic_apm/service_info.rb
elastic-apm-1.0.0 lib/elastic_apm/service_info.rb
elastic-apm-1.0.0.beta2 lib/elastic_apm/service_info.rb
elastic-apm-1.0.0.beta1 lib/elastic_apm/service_info.rb
elastic-apm-0.8.0 lib/elastic_apm/service_info.rb
elastic-apm-0.7.4 lib/elastic_apm/service_info.rb
elastic-apm-0.7.3 lib/elastic_apm/service_info.rb
elastic-apm-0.7.2 lib/elastic_apm/service_info.rb
elastic-apm-0.7.1 lib/elastic_apm/service_info.rb
elastic-apm-0.7.0 lib/elastic_apm/service_info.rb
elastic-apm-0.6.2 lib/elastic_apm/service_info.rb
elastic-apm-0.6.1 lib/elastic_apm/service_info.rb
elastic-apm-0.5.1 lib/elastic_apm/service_info.rb
elastic-apm-0.5.0 lib/elastic_apm/service_info.rb
elastic-apm-0.4.5 lib/elastic_apm/service_info.rb
elastic-apm-0.4.4 lib/elastic_apm/service_info.rb
elastic-apm-0.4.3 lib/elastic_apm/service_info.rb
elastic-apm-0.4.2 lib/elastic_apm/service_info.rb
elastic-apm-0.4.1 lib/elastic_apm/service_info.rb
elastic-apm-0.4.0 lib/elastic_apm/service_info.rb