Sha256: b88258dd02fe0fb82c7978855b935df18b3131814458174e6de3fb8c2494ba06

Contents?: true

Size: 1.14 KB

Versions: 29

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require "rake"

Rake::TaskManager.record_task_metadata = true

module Honeycomb
  module Rake
    ##
    # Automatically capture rake tasks and create a trace
    #
    module Task
      def execute(args = nil)
        return super(args) if honeycomb_client.nil?

        honeycomb_client.start_span(name: "rake.#{name}") do |span|
          span.add_field("meta.package", "rake")
          span.add_field("meta.package_version", ::Rake::VERSION)
          full_comment && span.add_field("rake.description", full_comment)
          arg_description && span.add_field("rake.arguments", arg_description)
          super(args)
        end
      end

      def honeycomb_client
        application.honeycomb_client
      end
    end

    ##
    # Provide access to the honeycomb_client for the rake tasks, can be
    # provided or uses the default global honeycomb client
    #
    module Application
      attr_writer :honeycomb_client

      def honeycomb_client
        @honeycomb_client || Honeycomb.client
      end
    end
  end
end

Rake::Application.include(Honeycomb::Rake::Application)
Rake::Task.prepend(Honeycomb::Rake::Task)

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
honeycomb-beeline-2.10.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.9.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.8.2 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.8.1 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.8.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.7.1 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.7.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.6.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.5.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.4.2 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.4.1 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.4.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.3.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.2.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.1.2 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.1.1 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.1.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-2.0.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-1.3.0 lib/honeycomb/integrations/rake.rb
honeycomb-beeline-1.2.0 lib/honeycomb/integrations/rake.rb