<commit_before>require "benchmark"
require "etc"
require "md5"
require "socket"
require "time"
require "timeout"

require "dogapi"

# Monkeypatch capistrano to collect data about the tasks that it's running
module Capistrano
  class Configuration
    module Execution
      # Attempts to locate the task at the given fully-qualified path, and
      # execute it. If no such task exists, a Capistrano::NoSuchTaskError 
      # will be raised.
      # Also, capture the time the task took to execute, and the logs it 
      # outputted for submission to Datadog
      def find_and_execute_task(path, hooks={})
        task = find_task(path) or raise NoSuchTaskError, "the task `#{path}' does not exist"
        result = nil
        reporter = Capistrano::Datadog.reporter
        timing = Benchmark.measure(task.fully_qualified_name) do
          # Set the current task so that the logger knows which task to 
          # associate the logs with
          reporter.current_task = task.fully_qualified_name
          trigger(hooks[:before], task) if hooks[:before]<commit_msg>use proper require for md5 (fixes #11)<commit_after>require "benchmark"
require "etc"
require "digest/md5"
require "socket"
require "time"
require "timeout"

require "dogapi"

# Monkeypatch capistrano to collect data about the tasks that it's running
module Capistrano
  class Configuration
    module Execution
      # Attempts to locate the task at the given fully-qualified path, and
      # execute it. If no such task exists, a Capistrano::NoSuchTaskError 
      # will be raised.
      # Also, capture the time the task took to execute, and the logs it 
      # outputted for submission to Datadog
      def find_and_execute_task(path, hooks={})
        task = find_task(path) or raise NoSuchTaskError, "the task `#{path}' does not exist"
        result = nil
        reporter = Capistrano::Datadog.reporter
        timing = Benchmark.measure(task.fully_qualified_name) do
          # Set the current task so that the logger knows which task to 
          # associate the logs with
          reporter.current_task = task.fully_qualified_name
          trigger(hooks[:before], task) if hooks[:before]
{'fraction_non_alphanumeric': 0.06978879706152434, 'fraction_numerical': 0.002295684113865932, 'mean_word_length': 3.2228682170542635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2100611', 'n_tokens_mistral': 609, 'n_tokens_neox': 595, 'n_words': 235}