Sha256: ccbbed1d08569d2e416c4cdbb2a941552000f0a4e5cb33ca9347785b28a04992

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require "pyroscope/version"
require "pyroscope_c"

module Pyroscope
  Config = Struct.new(:app_name, :server_address, :auth_token, :sample_rate, :with_subprocesses, :log_level, :tags)

  class << self
    def configure
      @configuration = Config.new
      yield @configuration
      _start(
        @configuration.app_name,
        @configuration.server_address,
        @configuration.auth_token || "",
        @configuration.sample_rate || 100,
        @configuration.with_subprocesses || 0,
        @configuration.log_level || "error",
      )
      tag(@configuration.tags) if @configuration.tags
    end

    def stop
      _stop
    end

    def change_name(new_name)
      _change_name(new_name)
    end

    def tag_wrapper(tags)
      tag(tags)

      begin
        yield
      ensure
        remove_tags(*tags.keys)
      end
    end

    def tag(tags)
      tags.each_pair do |key, val|
        _set_tag(key.to_s, val.to_s)
      end
    end

    def remove_tags(*keys)
      keys.each do |key|
        _set_tag(key.to_s, "")
      end
    end

    def test_logger
      _test_logger
    end

    def build_summary
      _build_summary
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pyroscope-0.2.0 lib/pyroscope.rb
pyroscope-0.1.1 lib/pyroscope.rb