_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
66
10.5k
language
stringclasses
1 value
meta_information
dict
q19600
Kms.PageFetcher.fetch_templatable_page!
train
def fetch_templatable_page! parent_page_path = File.dirname(@path) parent_page_path = Kms::Page::INDEX_FULLPATH if parent_page_path == "." parent_page = Kms::Page.published.find_by_fullpath!(parent_page_path) templatable_pages = parent_page.children.where(templatable: true) templatable_pages.detect do |templatable_page| templatable_page.fetch_item(File.basename(@path)) end end
ruby
{ "resource": "" }
q19601
Kms.Permalinkable.permalink
train
def permalink templatable_page = Kms::Page.where(templatable_type: self.class.name).first if templatable_page Pathname.new(templatable_page.parent.fullpath).join(slug.to_s).to_s end end
ruby
{ "resource": "" }
q19602
Yell.Level.set
train
def set( *severities ) @severities = Yell::Severities.map { true } severity = severities.length > 1 ? severities : severities.first case severity when Array then at(*severity) when Range then gte(severity.first).lte(severity.last) when String then interpret(severity) when Integer, Symbol then gte(severity) when Yell::Level then @severities = severity.severities end end
ruby
{ "resource": "" }
q19603
ShowFor.Helper.show_for
train
def show_for(object, html_options={}, &block) html_options = html_options.dup tag = html_options.delete(:show_for_tag) || ShowFor.show_for_tag html_options[:id] ||= dom_id(object) html_options[:class] = show_for_html_class(object, html_options) builder = html_options.delete(:builder) || ShowFor::Builder content = capture(builder.new(object, self), &block) content_tag(tag, content, html_options) end
ruby
{ "resource": "" }
q19604
ScormCloud.Base.execute_call_xml
train
def execute_call_xml(url) doc = REXML::Document.new(execute_call_plain(url)) raise create_error(doc) unless doc.elements["rsp"].attributes["stat"] == "ok" doc end
ruby
{ "resource": "" }
q19605
ScormCloud.Base.execute_call_plain
train
def execute_call_plain(url) res = Net::HTTP.get_response(URI.parse(url)) case res when Net::HTTPRedirection # Return the new URL res['location'] when Net::HTTPSuccess res.body else raise "HTTP Error connecting to scorm cloud: #{res.inspect}" end end
ruby
{ "resource": "" }
q19606
ScormCloud.Base.prepare_url
train
def prepare_url(method, params = {}) timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S') params[:method] = method params[:appid] = @appid params[:ts] = timestamp html_params = params.map { |k,v| "#{k.to_s}=#{v}" }.join("&") raw = @secret + params.keys. sort{ |a,b| a.to_s.downcase <=> b.to_s.downcase }. map{ |k| "#{k.to_s}#{params[k]}" }. join sig = Digest::MD5.hexdigest(raw) "http://cloud.scorm.com/api?#{html_params}&sig=#{sig}" end
ruby
{ "resource": "" }
q19607
ScormCloud.Base.create_error
train
def create_error(doc, url) err = doc.elements["rsp"].elements["err"] code = err.attributes["code"] msg = err.attributes["msg"] "Error In Scorm Cloud: Error=#{code} Message=#{msg} URL=#{url}" end
ruby
{ "resource": "" }
q19608
Twee2.StoryFormat.compile
train
def compile @source.gsub('{{STORY_NAME}}', Twee2::build_config.story_name).gsub('{{STORY_DATA}}', Twee2::build_config.story_file.xmldata).gsub('{{STORY_FORMAT}}', @name) end
ruby
{ "resource": "" }
q19609
Twee2.StoryFile.run_preprocessors
train
def run_preprocessors @passages.each_key do |k| # HAML if @passages[k][:tags].include? 'haml' @passages[k][:content] = Haml::Engine.new(@passages[k][:content], HAML_OPTIONS).render @passages[k][:tags].delete 'haml' end # Coffeescript if @passages[k][:tags].include? 'coffee' @passages[k][:content] = CoffeeScript.compile(@passages[k][:content], COFFEESCRIPT_OPTIONS) @passages[k][:tags].delete 'coffee' end # SASS / SCSS if @passages[k][:tags].include? 'sass' @passages[k][:content] = Sass::Engine.new(@passages[k][:content], :syntax => :sass).render end if @passages[k][:tags].include? 'scss' @passages[k][:content] = Sass::Engine.new(@passages[k][:content], :syntax => :scss).render end end end
ruby
{ "resource": "" }
q19610
HammerCLIKatello.IdNameOptionsValidator.validate_id_or_name
train
def validate_id_or_name(record_name = nil) child_options = IdNameOptionsValidator.build_child_options(record_name) validate_options do any(*child_options).required end end
ruby
{ "resource": "" }
q19611
Bowline.Watcher.call
train
def call(event, *args) return unless @listeners[event] @listeners[event].each do |callback| callback.call(*args) end end
ruby
{ "resource": "" }
q19612
Bowline.Watcher.remove
train
def remove(event, value=nil) return unless @listeners[event] if value @listeners[event].delete(value) if @listeners[event].empty? @listeners.delete(event) end else @listeners.delete(event) end end
ruby
{ "resource": "" }
q19613
Bowline.Initializer.set_autoload_paths
train
def set_autoload_paths # Rails 3 master support if ActiveSupport::Dependencies.respond_to?(:autoload_paths) ActiveSupport::Dependencies.autoload_paths = configuration.autoload_paths.uniq ActiveSupport::Dependencies.autoload_once_paths = configuration.autoload_once_paths.uniq else ActiveSupport::Dependencies.load_paths = configuration.autoload_paths.uniq ActiveSupport::Dependencies.load_once_paths = configuration.autoload_once_paths.uniq end end
ruby
{ "resource": "" }
q19614
Bowline.Configuration.set_root_path!
train
def set_root_path! raise 'APP_ROOT is not set' unless defined?(::APP_ROOT) raise 'APP_ROOT is not a directory' unless File.directory?(::APP_ROOT) @root_path = # Pathname is incompatible with Windows, but Windows doesn't have # real symlinks so File.expand_path is safe. if RUBY_PLATFORM =~ /(:?mswin|mingw)/ File.expand_path(::APP_ROOT) # Otherwise use Pathname#realpath which respects symlinks. else Pathname.new(::APP_ROOT).realpath.to_s end Object.const_set(:RELATIVE_APP_ROOT, ::APP_ROOT.dup) unless defined?(::RELATIVE_APP_ROOT) ::APP_ROOT.replace @root_path end
ruby
{ "resource": "" }
q19615
CocoaPodsStats.TargetMapper.pods_from_project
train
def pods_from_project(context, master_pods) context.umbrella_targets.flat_map do |target| root_specs = target.specs.map(&:root).uniq # As it's hard to look up the source of a pod, we # can check if the pod exists in the master specs repo though pods = root_specs. select { |spec| master_pods.include?(spec.name) }. map { |spec| { :name => spec.name, :version => spec.version.to_s } } # This will be an empty array for `integrate_targets: false` Podfiles user_targets(target).map do |user_target| # Send in a digested'd UUID anyway, a second layer # of misdirection can't hurt { :uuid => Digest::SHA256.hexdigest(user_target.uuid), :type => user_target.product_type, :pods => pods, :platform => user_target.platform_name, } end end end
ruby
{ "resource": "" }
q19616
JekyllAssetPipeline.Pipeline.collect
train
def collect @assets = YAML.safe_load(@manifest).map! do |path| full_path = File.join(@source, path) File.open(File.join(@source, path)) do |file| ::JekyllAssetPipeline::Asset.new(file.read, File.basename(path), File.dirname(full_path)) end end rescue StandardError => e puts 'Asset Pipeline: Failed to load assets from provided ' \ "manifest: #{e.message}" raise e end
ruby
{ "resource": "" }
q19617
JekyllAssetPipeline.Pipeline.convert_asset
train
def convert_asset(klass, asset) # Convert asset content converter = klass.new(asset) # Replace asset content and filename asset.content = converter.converted asset.filename = File.basename(asset.filename, '.*') # Add back the output extension if no extension left if File.extname(asset.filename) == '' asset.filename = "#{asset.filename}#{@type}" end rescue StandardError => e puts "Asset Pipeline: Failed to convert '#{asset.filename}' " \ "with '#{klass}': #{e.message}" raise e end
ruby
{ "resource": "" }
q19618
JekyllAssetPipeline.Pipeline.compress
train
def compress @assets.each do |asset| # Find a compressor to use klass = ::JekyllAssetPipeline::Compressor.subclasses.select do |c| c.filetype == @type end.last break unless klass begin asset.content = klass.new(asset.content).compressed rescue StandardError => e puts "Asset Pipeline: Failed to compress '#{asset.filename}' " \ "with '#{klass}': #{e.message}" raise e end end end
ruby
{ "resource": "" }
q19619
JekyllAssetPipeline.Pipeline.gzip
train
def gzip @assets.map! do |asset| gzip_content = Zlib::Deflate.deflate(asset.content) [ asset, ::JekyllAssetPipeline::Asset .new(gzip_content, "#{asset.filename}.gz", asset.dirname) ] end.flatten! end
ruby
{ "resource": "" }
q19620
JekyllAssetPipeline.Pipeline.save
train
def save output_path = @options['output_path'] staging_path = @options['staging_path'] @assets.each do |asset| directory = File.join(@source, staging_path, output_path) write_asset_file(directory, asset) # Store output path of saved file asset.output_path = output_path end end
ruby
{ "resource": "" }
q19621
StarlingServer.QueueCollection.put
train
def put(key, data) queue = queues(key) return nil unless queue @stats[:current_bytes] += data.size @stats[:total_items] += 1 queue.push(data) return true end
ruby
{ "resource": "" }
q19622
StarlingServer.QueueCollection.take
train
def take(key) queue = queues(key) if queue.nil? || queue.length == 0 @stats[:get_misses] += 1 return nil else @stats[:get_hits] += 1 end result = queue.pop @stats[:current_bytes] -= result.size result end
ruby
{ "resource": "" }
q19623
StarlingServer.QueueCollection.queues
train
def queues(key=nil) return nil if @shutdown_mutex.locked? return @queues if key.nil? # First try to return the queue named 'key' if it's available. return @queues[key] if @queues[key] # If the queue wasn't available, create or get the mutex that will # wrap creation of the Queue. @queue_init_mutexes[key] ||= Mutex.new # Otherwise, check to see if another process is already loading # the queue named 'key'. if @queue_init_mutexes[key].locked? # return an empty/false result if we're waiting for the queue # to be loaded and we're not the first process to request the queue return nil else begin @queue_init_mutexes[key].lock # we've locked the mutex, but only go ahead if the queue hasn't # been loaded. There's a race condition otherwise, and we could # end up loading the queue multiple times. if @queues[key].nil? @queues[key] = PersistentQueue.new(@path, key) @stats[:current_bytes] += @queues[key].initial_bytes end rescue Object => exc puts "ZOMG There was an exception reading back the queue. That totally sucks." puts "The exception was: #{exc}. Backtrace: #{exc.backtrace.join("\n")}" ensure @queue_init_mutexes[key].unlock end end return @queues[key] end
ruby
{ "resource": "" }
q19624
StarlingServer.PersistentQueue.pop
train
def pop(log_trx = true) raise NoTransactionLog if log_trx && !@trx begin rv = super(!log_trx) rescue ThreadError puts "WARNING: The queue was empty when trying to pop(). Technically this shouldn't ever happen. Probably a bug in the transactional underpinnings. Or maybe shutdown didn't happen cleanly at some point. Ignoring." rv = [now_usec, ''] end transaction "\001" if log_trx @current_age = (now_usec - rv[0]) / 1000 rv[1] end
ruby
{ "resource": "" }
q19625
StarlingServer.Base.run
train
def run @stats[:start_time] = Time.now if @opts[:syslog_channel] begin require 'syslog_logger' @@logger = SyslogLogger.new(@opts[:syslog_channel]) rescue LoadError # SyslogLogger isn't available, so we're just going to use Logger end end @@logger ||= case @opts[:logger] when IO, String; Logger.new(@opts[:logger]) when Logger; @opts[:logger] else; Logger.new(STDERR) end begin @opts[:queue] = QueueCollection.new(@opts[:path]) rescue InaccessibleQueuePath => e puts "Error: #{e.message}" exit 1 end @@logger.level = @opts[:log_level] || Logger::ERROR @@logger.info "Starling STARTUP on #{@opts[:host]}:#{@opts[:port]}" EventMachine.epoll EventMachine.set_descriptor_table_size(4096) EventMachine.run do EventMachine.start_server(@opts[:host], @opts[:port], Handler, @opts) end # code here will get executed on shutdown: @opts[:queue].close end
ruby
{ "resource": "" }
q19626
StarlingServer.Handler.post_init
train
def post_init @stash = [] @data = "" @data_buf = "" @server = @opts[:server] @logger = StarlingServer::Base.logger @expiry_stats = Hash.new(0) @expected_length = nil @server.stats[:total_connections] += 1 set_comm_inactivity_timeout @opts[:timeout] @queue_collection = @opts[:queue] @session_id = @@next_session_id @@next_session_id += 1 peer = Socket.unpack_sockaddr_in(get_peername) #@logger.debug "(#{@session_id}) New session from #{peer[1]}:#{peer[0]}" end
ruby
{ "resource": "" }
q19627
Attach.Attachment.child
train
def child(role) @cached_children ||= {} @cached_children[role.to_sym] ||= self.children.where(:role => role).first || :nil @cached_children[role.to_sym] == :nil ? nil : @cached_children[role.to_sym] end
ruby
{ "resource": "" }
q19628
Attach.Attachment.add_child
train
def add_child(role, &block) attachment = self.children.build attachment.role = role attachment.owner = self.owner attachment.file_name = self.file_name attachment.file_type = self.file_type attachment.disposition = self.disposition attachment.cache_type = self.cache_type attachment.cache_max_age = self.cache_max_age attachment.type = self.type block.call(attachment) attachment.save! end
ruby
{ "resource": "" }
q19629
LinuxAdmin.NetworkInterface.netmask6
train
def netmask6(scope = :global) if [:global, :link].include?(scope) @network_conf["mask6_#{scope}".to_sym] ||= IPAddr.new('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff').mask(prefix6(scope)).to_s if prefix6(scope) else raise ArgumentError, "Unrecognized address scope #{scope}" end end
ruby
{ "resource": "" }
q19630
LinuxAdmin.NetworkInterfaceRH.apply_static
train
def apply_static(ip, mask, gw, dns, search = nil) self.address = ip self.netmask = mask self.gateway = gw self.dns = dns self.search_order = search if search save end
ruby
{ "resource": "" }
q19631
LinuxAdmin.NetworkInterfaceRH.apply_static6
train
def apply_static6(ip, prefix, gw, dns, search = nil) self.address6 = "#{ip}/#{prefix}" self.gateway6 = gw self.dns = dns self.search_order = search if search save end
ruby
{ "resource": "" }
q19632
CustomFields.Source.klass_with_custom_fields
train
def klass_with_custom_fields(name) # Rails.logger.debug "[CustomFields] klass_with_custom_fields #{self.send(name).metadata.klass} / #{self.send(name).metadata[:old_klass]}" if defined?(Rails) # DEBUG recipe = self.custom_fields_recipe_for(name) _metadata = self.send(name).relation_metadata target = _metadata[:original_klass] || _metadata.klass # avoid to use an already enhanced klass target.klass_with_custom_fields(recipe) end
ruby
{ "resource": "" }
q19633
CustomFields.Source.collect_custom_fields_diff
train
def collect_custom_fields_diff(name, fields) # puts "==> collect_custom_fields_diff for #{name}, #{fields.size}" # DEBUG memo = self.initialize_custom_fields_diff(name) fields.map do |field| field.collect_diff(memo) end # collect fields with a modified localized field fields.each do |field| if field.localized_changed? && field.persisted? self._custom_field_localize_diff[name] << { field: field.name, localized: field.localized? } end end end
ruby
{ "resource": "" }
q19634
CustomFields.Source.apply_custom_fields_diff
train
def apply_custom_fields_diff(name) # puts "==> apply_custom_fields_recipes for #{name}, #{self._custom_fields_diff[name].inspect}" # DEBUG operations = self._custom_fields_diff[name] operations['$set'].merge!({ 'custom_fields_recipe.version' => self.custom_fields_version(name) }) collection, selector = self.send(name).collection, self.send(name).criteria.selector # http://docs.mongodb.org/manual/reference/method/db.collection.update/#update-parameter # The <update> document must contain only update operator expressions. %w(set unset rename).each do |operation_name| _fields = operations.delete("$#{operation_name}") next if _fields.empty? _operation = { "$#{operation_name}" => _fields } collection.find(selector).update_many _operation end end
ruby
{ "resource": "" }
q19635
CustomFields.Source.apply_custom_fields_localize_diff
train
def apply_custom_fields_localize_diff(name) return if self._custom_field_localize_diff[name].empty? self.send(name).all.each do |record| updates = {} # puts "[apply_custom_fields_localize_diff] processing: record #{record._id} / #{self._custom_field_localize_diff[name].inspect}" # DEBUG self._custom_field_localize_diff[name].each do |changes| if changes[:localized] value = record.read_attribute(changes[:field].to_sym) updates[changes[:field]] = { Mongoid::Fields::I18n.locale.to_s => value } else # the other way around value = record.read_attribute(changes[:field].to_sym) next if value.nil? updates[changes[:field]] = value[Mongoid::Fields::I18n.locale.to_s] end end next if updates.empty? collection = self.send(name).collection collection.find(record.atomic_selector).update_one({ '$set' => updates }) end end
ruby
{ "resource": "" }
q19636
CustomFields.TargetHelpers.custom_fields_methods
train
def custom_fields_methods(&filter) self.custom_fields_recipe['rules'].map do |rule| method = self.custom_fields_getters_for rule['name'], rule['type'] if block_given? filter.call(rule) ? method : nil else method end end.compact.flatten end
ruby
{ "resource": "" }
q19637
CustomFields.TargetHelpers.custom_fields_safe_setters
train
def custom_fields_safe_setters self.custom_fields_recipe['rules'].map do |rule| case rule['type'].to_sym when :date, :date_time, :money then "formatted_#{rule['name']}" when :file then [rule['name'], "remove_#{rule['name']}", "remote_#{rule['name']}_url"] when :select, :belongs_to then ["#{rule['name']}_id", "position_in_#{rule['name']}"] when :has_many, :many_to_many then nil else rule['name'] end end.compact.flatten end
ruby
{ "resource": "" }
q19638
CustomFields.TargetHelpers.custom_fields_basic_attributes
train
def custom_fields_basic_attributes {}.tap do |hash| self.non_relationship_custom_fields.each do |rule| name, type = rule['name'], rule['type'].to_sym # method of the custom getter method_name = "#{type}_attribute_get" hash.merge!(self.class.send(method_name, self, name)) end end end
ruby
{ "resource": "" }
q19639
CustomFields.TargetHelpers.is_a_custom_field_many_relationship?
train
def is_a_custom_field_many_relationship?(name) rule = self.custom_fields_recipe['rules'].detect do |rule| rule['name'] == name && _custom_field_many_relationship?(rule['type']) end end
ruby
{ "resource": "" }
q19640
Instrumental.Agent.gauge
train
def gauge(metric, value, time = Time.now, count = 1) if valid?(metric, value, time, count) && send_command("gauge", metric, value, time.to_i, count.to_i) value else nil end rescue Exception => e report_exception(e) nil end
ruby
{ "resource": "" }
q19641
Instrumental.Agent.time
train
def time(metric, multiplier = 1) start = Time.now begin result = yield ensure finish = Time.now duration = finish - start gauge(metric, duration * multiplier, start) end result end
ruby
{ "resource": "" }
q19642
Instrumental.Agent.cleanup
train
def cleanup if running? logger.info "Cleaning up agent, queue size: #{@queue.size}, thread running: #{@thread.alive?}" @allow_reconnect = false if @queue.size > 0 queue_message('exit') begin with_timeout(EXIT_FLUSH_TIMEOUT) { @thread.join } rescue Timeout::Error if @queue.size > 0 logger.error "Timed out working agent thread on exit, dropping #{@queue.size} metrics" else logger.error "Timed out Instrumental Agent, exiting" end end end end end
ruby
{ "resource": "" }
q19643
Secp256k1.ECDSA.ecdsa_signature_normalize
train
def ecdsa_signature_normalize(raw_sig, check_only: false) sigout = check_only ? nil : C::ECDSASignature.new.pointer res = C.secp256k1_ecdsa_signature_normalize(@ctx, sigout, raw_sig) [res == 1, sigout] end
ruby
{ "resource": "" }
q19644
Secp256k1.PublicKey.combine
train
def combine(pubkeys) raise ArgumentError, 'must give at least 1 pubkey' if pubkeys.empty? outpub = FFI::Pubkey.new.pointer #pubkeys.each {|item| } res = C.secp256k1_ec_pubkey_combine(@ctx, outpub, pubkeys, pubkeys.size) raise AssertError, 'failed to combine public keys' unless res == 1 @public_key = outpub outpub end
ruby
{ "resource": "" }
q19645
HipChat.Room.get_room
train
def get_room response = self.class.get(@api.get_room_config[:url], :query => {:auth_token => @token }.merge(@api.get_room_config[:query_params]), :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :room, room_id, response response.parsed_response end
ruby
{ "resource": "" }
q19646
HipChat.Room.update_room
train
def update_room(options = {}) merged_options = { :privacy => 'public', :is_archived => false, :is_guest_accessible => false }.merge symbolize(options) response = self.class.send(@api.topic_config[:method], @api.update_room_config[:url], :query => { :auth_token => @token }, :body => { :name => merged_options[:name], :topic => merged_options[:topic], :privacy => merged_options[:privacy], :is_archived => @api.bool_val(merged_options[:is_archived]), :is_guest_accessible => @api.bool_val(merged_options[:is_guest_accessible]), :owner => merged_options[:owner] }.to_json, :headers => @api.headers) ErrorHandler.response_code_to_exception_for :room, room_id, response true end
ruby
{ "resource": "" }
q19647
HipChat.Room.delete_room
train
def delete_room response = self.class.send(@api.delete_room_config[:method], @api.delete_room_config[:url], :query => {:auth_token => @token }.merge(@api.get_room_config[:query_params]), :headers => @api.headers) ErrorHandler.response_code_to_exception_for :room, room_id, response true end
ruby
{ "resource": "" }
q19648
HipChat.Room.invite
train
def invite(user, reason='') response = self.class.post(@api.invite_config[:url]+"/#{user}", :query => { :auth_token => @token }, :body => { :reason => reason }.to_json, :headers => @api.headers) ErrorHandler.response_code_to_exception_for :room, room_id, response true end
ruby
{ "resource": "" }
q19649
HipChat.Room.add_member
train
def add_member(user, room_roles=['room_member']) response = self.class.put(@api.member_config[:url]+"/#{user}", :query => { :auth_token => @token }, :body => { :room_roles => room_roles }.to_json, :headers => @api.headers) ErrorHandler.response_code_to_exception_for :room, room_id, response true end
ruby
{ "resource": "" }
q19650
HipChat.Room.members
train
def members(options = {}) response = self.class.get(@api.member_config[:url], :query => { :auth_token => @token }.merge(options), :headers => @api.headers) ErrorHandler.response_code_to_exception_for :room, room_id, response wrap_users(response) end
ruby
{ "resource": "" }
q19651
HipChat.Room.participants
train
def participants(options = {}) response = self.class.get(@api.participant_config[:url], :query => { :auth_token => @token }.merge(options), :headers => @api.headers) ErrorHandler.response_code_to_exception_for :room, room_id, response wrap_users(response) end
ruby
{ "resource": "" }
q19652
HipChat.Room.send_message
train
def send_message(message) response = self.class.post(@api.send_message_config[:url], :query => { :auth_token => @token }, :body => { :room_id => room_id, :message => message, }.send(@api.send_config[:body_format]), :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :room, room_id, response true end
ruby
{ "resource": "" }
q19653
HipChat.Room.send
train
def send(from, message, options_or_notify = {}) if from.length > 20 raise UsernameTooLong, "Username #{from} is `#{from.length} characters long. Limit is 20'" end if options_or_notify == true or options_or_notify == false warn 'DEPRECATED: Specify notify flag as an option (e.g., :notify => true)' options = { :notify => options_or_notify } else options = options_or_notify end merged_options = { :color => 'yellow', :notify => false, :message_format => 'html' }.merge options body = { :room_id => room_id, :from => from, :message => message, :message_format => merged_options[:message_format], :color => merged_options[:color], :card => merged_options[:card], :notify => @api.bool_val(merged_options[:notify]) }.delete_if { |_k, v| v.nil? } response = self.class.post(@api.send_config[:url], :query => { :auth_token => @token }, :body => body.send(@api.send_config[:body_format]), :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :room, room_id, response true end
ruby
{ "resource": "" }
q19654
HipChat.Room.send_file
train
def send_file(from, message, file) if from.length > 20 raise UsernameTooLong, "Username #{from} is `#{from.length} characters long. Limit is 20'" end response = self.class.post(@api.send_file_config[:url], :query => { :auth_token => @token }, :body => file_body( { :room_id => room_id, :from => from, :message => message, }.send(@api.send_config[:body_format]), file ), :headers => file_body_headers(@api.headers) ) ErrorHandler.response_code_to_exception_for :room, room_id, response true end
ruby
{ "resource": "" }
q19655
HipChat.Room.topic
train
def topic(new_topic, options = {}) merged_options = { :from => 'API' }.merge options response = self.class.send(@api.topic_config[:method], @api.topic_config[:url], :query => { :auth_token => @token }, :body => { :room_id => room_id, :from => merged_options[:from], :topic => new_topic }.send(@api.topic_config[:body_format]), :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :room, room_id, response true end
ruby
{ "resource": "" }
q19656
HipChat.Room.history
train
def history(options = {}) merged_options = { :date => 'recent', :timezone => 'UTC', :format => 'JSON', :'max-results' => 100, :'start-index' => 0, :'end-date' => nil }.merge options response = self.class.get(@api.history_config[:url], :query => { :room_id => room_id, :date => merged_options[:date], :timezone => merged_options[:timezone], :format => merged_options[:format], :'max-results' => merged_options[:'max-results'], :'start-index' => merged_options[:'start-index'], :'end-date' => merged_options[:'end-date'], :auth_token => @token }.reject!{|k,v| v.nil?}, :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :room, room_id, response response.body end
ruby
{ "resource": "" }
q19657
HipChat.Room.statistics
train
def statistics(options = {}) response = self.class.get(@api.statistics_config[:url], :query => { :room_id => room_id, :date => options[:date], :timezone => options[:timezone], :format => options[:format], :auth_token => @token, }.reject!{|k,v| v.nil?}, :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :room, room_id, response response.body end
ruby
{ "resource": "" }
q19658
HipChat.Room.create_webhook
train
def create_webhook(url, event, options = {}) raise InvalidEvent.new("Invalid event: #{event}") unless %w(room_message room_notification room_exit room_enter room_topic_change room_archived room_deleted room_unarchived).include? event begin u = URI::parse(url) raise InvalidUrl.new("Invalid Scheme: #{url}") unless %w(http https).include? u.scheme rescue URI::InvalidURIError raise InvalidUrl.new("Invalid URL: #{url}") end merged_options = { :pattern => '', :name => '' }.merge options response = self.class.post(@api.webhook_config[:url], :query => { :auth_token => @token }, :body => {:url => url, :pattern => merged_options[:pattern], :event => event, :name => merged_options[:name]}.send(@api.send_config[:body_format]), :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :room, room_id, response response.body end
ruby
{ "resource": "" }
q19659
HipChat.Room.delete_webhook
train
def delete_webhook(webhook_id) response = self.class.delete("#{@api.webhook_config[:url]}/#{URI::escape(webhook_id)}", :query => { :auth_token => @token }, :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :webhook, webhook_id, response true end
ruby
{ "resource": "" }
q19660
HipChat.Room.get_all_webhooks
train
def get_all_webhooks(options = {}) merged_options = {:'start-index' => 0, :'max-results' => 100}.merge(options) response = self.class.get(@api.webhook_config[:url], :query => { :auth_token => @token, :'start-index' => merged_options[:'start-index'], :'max-results' => merged_options[:'max-results'] }, :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :room, room_id, response response.body end
ruby
{ "resource": "" }
q19661
HipChat.Room.get_webhook
train
def get_webhook(webhook_id) response = self.class.get("#{@api.webhook_config[:url]}/#{URI::escape(webhook_id)}", :query => { :auth_token => @token }, :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :webhook, webhook_id, response response.body end
ruby
{ "resource": "" }
q19662
Soulmate.Loader.add
train
def add(item, opts = {}) opts = { :skip_duplicate_check => false }.merge(opts) raise ArgumentError, "Items must specify both an id and a term" unless item["id"] && item["term"] # kill any old items with this id remove("id" => item["id"]) unless opts[:skip_duplicate_check] Soulmate.redis.pipelined do # store the raw data in a separate key to reduce memory usage Soulmate.redis.hset(database, item["id"], MultiJson.encode(item)) phrase = ([item["term"]] + (item["aliases"] || [])).join(' ') prefixes_for_phrase(phrase).each do |p| Soulmate.redis.sadd(base, p) # remember this prefix in a master set Soulmate.redis.zadd("#{base}:#{p}", item["score"], item["id"]) # store the id of this term in the index end end end
ruby
{ "resource": "" }
q19663
Soulmate.Loader.remove
train
def remove(item) prev_item = Soulmate.redis.hget(database, item["id"]) if prev_item prev_item = MultiJson.decode(prev_item) # undo the operations done in add Soulmate.redis.pipelined do Soulmate.redis.hdel(database, prev_item["id"]) phrase = ([prev_item["term"]] + (prev_item["aliases"] || [])).join(' ') prefixes_for_phrase(phrase).each do |p| Soulmate.redis.srem(base, p) Soulmate.redis.zrem("#{base}:#{p}", prev_item["id"]) end end end end
ruby
{ "resource": "" }
q19664
HipChat.User.send
train
def send(message, options = {}) message_format = options[:message_format] ? options[:message_format] : 'text' notify = options[:notify] ? options[:notify] : false response = self.class.post(@api.send_config[:url], :query => { :auth_token => @token }, :body => { :message => message, :message_format => message_format, :notify => notify }.send(@api.send_config[:body_format]), :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :user, user_id, response true end
ruby
{ "resource": "" }
q19665
HipChat.User.send_file
train
def send_file(message, file) response = self.class.post(@api.send_file_config[:url], :query => { :auth_token => @token }, :body => file_body({ :message => message }.send(@api.send_config[:body_format]), file), :headers => file_body_headers(@api.headers) ) ErrorHandler.response_code_to_exception_for :user, user_id, response true end
ruby
{ "resource": "" }
q19666
HipChat.User.view
train
def view response = self.class.get(@api.view_config[:url], :query => { :auth_token => @token }.merge(@api.view_config[:query_params]), :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :user, user_id, response User.new(@token, response.merge(:api_version => @api.version, :server_url => server_url)) end
ruby
{ "resource": "" }
q19667
HipChat.User.rooms
train
def rooms response = self.class.get(@api.user_joined_rooms_config[:url], :query => { :auth_token => @token }.merge(@api.user_joined_rooms_config[:query_params]), :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :user, user_id, response User.new(@token, response.merge(:api_version => @api.version)) end
ruby
{ "resource": "" }
q19668
HipChat.FileHelper.file_body
train
def file_body(message, file) file_name = File.basename(file.path) mime_type = MimeMagic.by_path(file_name) file_content = Base64.encode64(file.read) body = ["--#{BOUNDARY}"] body << 'Content-Type: application/json; charset=UTF-8' body << 'Content-Disposition: attachment; name="metadata"' body << '' body << message body << "--#{BOUNDARY}" body << "Content-Type: #{mime_type}; charset=UTF-8" body << 'Content-Transfer-Encoding: base64' body << %{Content-Disposition: attachment; name="file"; filename="#{file_name}"} body << '' body << file_content body << "--#{BOUNDARY}--" body.join("\n") end
ruby
{ "resource": "" }
q19669
HipChat.Client.scopes
train
def scopes(room: nil) path = "#{@api.scopes_config[:url]}/#{URI::escape(@token)}" response = self.class.get(path, :query => { :auth_token => @token }, :headers => @api.headers ) ErrorHandler.response_code_to_exception_for :room, 'scopes', response return response['scopes'] unless response['client']['room'] if room && response['client']['room']['id'] == room.room_id return response['scopes'] end end
ruby
{ "resource": "" }
q19670
Instana.Span.add_stack
train
def add_stack(limit: nil, stack: Kernel.caller) frame_count = 0 @data[:stack] = [] stack.each do |i| # If the stack has the full instana gem version in it's path # then don't include that frame. Also don't exclude the Rack module. if !i.match(/instana\/instrumentation\/rack.rb/).nil? || (i.match(::Instana::VERSION_FULL).nil? && i.match('lib/instana/').nil?) break if limit && frame_count >= limit x = i.split(':') @data[:stack] << { :c => x[0], :n => x[1], :m => x[2] } frame_count = frame_count + 1 if limit end end end
ruby
{ "resource": "" }
q19671
Instana.Span.add_error
train
def add_error(e) @data[:error] = true if @data.key?(:ec) @data[:ec] = @data[:ec] + 1 else @data[:ec] = 1 end # If a valid exception has been passed in, log the information about it # In case of just logging an error for things such as HTTP client 5xx # responses, an exception/backtrace may not exist. if e if e.backtrace.is_a?(Array) add_stack(stack: e.backtrace) end if HTTP_SPANS.include?(@data[:n]) set_tags(:http => { :error => "#{e.class}: #{e.message}" }) else log(:error, Time.now, { :message => e.message, :parameters => e.class.to_s }) end e.instance_variable_set(:@instana_logged, true) end self end
ruby
{ "resource": "" }
q19672
Instana.Span.set_tags
train
def set_tags(tags) return unless tags.is_a?(Hash) tags.each do |k,v| set_tag(k, v) end self end
ruby
{ "resource": "" }
q19673
Instana.Span.tags
train
def tags(key = nil) if custom? tags = @data[:data][:sdk][:custom][:tags] else tags = @data[:data][key] end key ? tags[key] : tags end
ruby
{ "resource": "" }
q19674
Riiif.Resize.reduce?
train
def reduce? case size when IIIF::Image::Size::Full, IIIF::Image::Size::Max false when IIIF::Image::Size::Absolute aspect_ratio = width.to_f / height in_delta?(image_info.aspect, aspect_ratio, 0.001) else true end end
ruby
{ "resource": "" }
q19675
Riiif.KakaduTransformer.post_process
train
def post_process(intermediate_file, reduction_factor) # Calculate a new set of transforms with respect to reduction_factor transformation = if reduction_factor reduce(without_crop, reduction_factor) else without_crop end Riiif::File.new(intermediate_file).extract(transformation, image_info) end
ruby
{ "resource": "" }
q19676
Riiif.KakaduTransformer.without_crop
train
def without_crop IIIF::Image::Transformation.new(region: IIIF::Image::Region::Full.new, size: transformation.size.dup, quality: transformation.quality, rotation: transformation.rotation, format: transformation.format) end
ruby
{ "resource": "" }
q19677
Riiif.KakaduTransformer.reduce
train
def reduce(transformation, factor) resize = Resize.new(transformation.size, image_info) IIIF::Image::Transformation.new(region: transformation.region.dup, size: resize.reduce(factor), quality: transformation.quality, rotation: transformation.rotation, format: transformation.format) end
ruby
{ "resource": "" }
q19678
Instana.Agent.setup
train
def setup # The announce timer # We attempt to announce this ruby sensor to the host agent. # In case of failure, we try again in 30 seconds. @announce_timer = @timers.every(30) do if @state == :unannounced if host_agent_available? && announce_sensor transition_to(:announced) ::Instana.logger.info "Host agent available. We're in business. (#{@state} pid:#{Process.pid} #{@process[:name]})" end end end # The collect timer # If we are in announced state, send metric data (only delta reporting) # every ::Instana.config[:collector][:interval] seconds. @collect_timer = @timers.every(::Instana.config[:collector][:interval]) do # Make sure that this block doesn't get called more often than the interval. This can # happen on high CPU load and a back up of timer runs. If we are called before `interval` # then we just skip. unless (Time.now - @last_collect_run) < ::Instana.config[:collector][:interval] @last_collect_run = Time.now if @state == :announced if !::Instana.collector.collect_and_report # If report has been failing for more than 1 minute, # fall back to unannounced state if (Time.now - @entity_last_seen) > 60 ::Instana.logger.warn "Host agent offline for >1 min. Going to sit in a corner..." transition_to(:unannounced) end end ::Instana.processor.send end end end end
ruby
{ "resource": "" }
q19679
Instana.Agent.start
train
def start if !host_agent_available? if !ENV.key?("INSTANA_QUIET") ::Instana.logger.warn "Host agent not available. Will retry periodically. (Set env INSTANA_QUIET=1 to shut these messages off)" end end loop do if @state == :unannounced @collect_timer.pause @announce_timer.resume else @announce_timer.pause @collect_timer.resume end @timers.wait end rescue Exception => e ::Instana.logger.warn "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" ::Instana.logger.debug e.backtrace.join("\r\n") ensure if @state == :announced # Pause the timers so they don't fire while we are # reporting traces @collect_timer.pause @announce_timer.pause ::Instana.logger.debug "#{Thread.current}: Agent exiting. Reporting final #{::Instana.processor.queue_count} trace(s)." ::Instana.processor.send end end
ruby
{ "resource": "" }
q19680
Instana.Agent.announce_sensor
train
def announce_sensor unless @discovered ::Instana.logger.debug("#{__method__} called but discovery hasn't run yet!") return false end # Always re-collect process info before announce in case the process name has been # re-written (looking at you puma!) @process = ::Instana::Util.collect_process_info announce_payload = {} announce_payload[:pid] = pid_namespace? ? get_real_pid : Process.pid announce_payload[:name] = @process[:name] announce_payload[:args] = @process[:arguments] if @is_linux && !::Instana.test? # We create an open socket to the host agent in case we are running in a container # and the real pid needs to be detected. socket = TCPSocket.new @discovered[:agent_host], @discovered[:agent_port] announce_payload[:fd] = socket.fileno announce_payload[:inode] = File.readlink("/proc/#{Process.pid}/fd/#{socket.fileno}") end uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{DISCOVERY_PATH}") req = Net::HTTP::Put.new(uri) req.body = Oj.dump(announce_payload, OJ_OPTIONS) ::Instana.logger.debug "Announce: http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{DISCOVERY_PATH} - payload: #{req.body}" response = make_host_agent_request(req) if response && (response.code.to_i == 200) data = Oj.load(response.body, OJ_OPTIONS) @process[:report_pid] = data['pid'] @agent_uuid = data['agentUuid'] if data.key?('extraHeaders') @extra_headers = data['extraHeaders'] end true else false end rescue => e Instana.logger.info "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" Instana.logger.debug e.backtrace.join("\r\n") return false ensure socket.close if socket end
ruby
{ "resource": "" }
q19681
Instana.Agent.report_metrics
train
def report_metrics(payload) unless @discovered ::Instana.logger.debug("#{__method__} called but discovery hasn't run yet!") return false end path = "com.instana.plugin.ruby.#{@process[:report_pid]}" uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{path}") req = Net::HTTP::Post.new(uri) req.body = Oj.dump(payload, OJ_OPTIONS) response = make_host_agent_request(req) if response if response.body && response.body.length > 2 # The host agent returned something indicating that is has a request for us that we # need to process. handle_agent_tasks(response.body) end if response.code.to_i == 200 @entity_last_seen = Time.now return true end end false rescue => e Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" Instana.logger.debug e.backtrace.join("\r\n") end
ruby
{ "resource": "" }
q19682
Instana.Agent.report_spans
train
def report_spans(spans) return unless @state == :announced unless @discovered ::Instana.logger.debug("#{__method__} called but discovery hasn't run yet!") return false end path = "com.instana.plugin.ruby/traces.#{@process[:report_pid]}" uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{path}") req = Net::HTTP::Post.new(uri) opts = OJ_OPTIONS.merge({omit_nil: true}) req.body = Oj.dump(spans, opts) response = make_host_agent_request(req) if response last_trace_response = response.code.to_i if [200, 204].include?(last_trace_response) return true end end false rescue => e Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" Instana.logger.debug e.backtrace.join("\r\n") end
ruby
{ "resource": "" }
q19683
Instana.Agent.host_agent_available?
train
def host_agent_available? @discovered ||= run_discovery if @discovered # Try default location or manually configured (if so) uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/") req = Net::HTTP::Get.new(uri) response = make_host_agent_request(req) if response && (response.code.to_i == 200) return true end end false rescue => e Instana.logger.debug "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" Instana.logger.debug e.backtrace.join("\r\n") unless ::Instana.test? return false end
ruby
{ "resource": "" }
q19684
Instana.Tracer.start_or_continue_trace
train
def start_or_continue_trace(name, kvs = {}, incoming_context = {}, &block) log_start_or_continue(name, kvs, incoming_context) block.call rescue Exception => e log_error(e) raise ensure log_end(name) end
ruby
{ "resource": "" }
q19685
Instana.Tracer.trace
train
def trace(name, kvs = {}, &block) log_entry(name, kvs) result = block.call result rescue Exception => e log_error(e) raise ensure log_exit(name) end
ruby
{ "resource": "" }
q19686
Instana.Tracer.log_start_or_continue
train
def log_start_or_continue(name, kvs = {}, incoming_context = {}) return if !::Instana.agent.ready? || !::Instana.config[:tracing][:enabled] ::Instana.logger.debug "#{__method__} passed a block. Use `start_or_continue` instead!" if block_given? self.current_trace = ::Instana::Trace.new(name, kvs, incoming_context) end
ruby
{ "resource": "" }
q19687
Instana.Tracer.log_exit
train
def log_exit(name, kvs = {}) return unless tracing? if ::Instana.debug? || ::Instana.test? unless current_span_name?(name) ::Instana.logger.debug "Span mismatch: Attempt to exit #{name} span but #{current_span.name} is active." end end self.current_trace.end_span(kvs) end
ruby
{ "resource": "" }
q19688
Instana.Tracer.log_end
train
def log_end(name, kvs = {}, end_time = ::Instana::Util.now_in_ms) return unless tracing? if ::Instana.debug? || ::Instana.test? unless current_span_name?(name) ::Instana.logger.debug "Span mismatch: Attempt to end #{name} span but #{current_span.name} is active." end end self.current_trace.finish(kvs, end_time) if ::Instana.agent.ready? if !self.current_trace.has_async? || (self.current_trace.has_async? && self.current_trace.complete?) Instana.processor.add(self.current_trace) else # This trace still has outstanding/uncompleted asynchronous spans. # Put it in the staging queue until the async span closes out or # 5 minutes has passed. Whichever comes first. Instana.processor.stage(self.current_trace) end end self.current_trace = nil end
ruby
{ "resource": "" }
q19689
Instana.Tracer.log_async_info
train
def log_async_info(kvs, span) # Asynchronous spans can persist longer than the parent # trace. With the trace ID, we check the current trace # but otherwise, we search staged traces. if tracing? && self.current_trace.id == span.context.trace_id self.current_trace.add_async_info(kvs, span) else trace = ::Instana.processor.staged_trace(span.context.trace_id) if trace trace.add_async_info(kvs, span) else ::Instana.logger.debug "#{__method__}: Couldn't find staged trace. #{span.inspect}" end end end
ruby
{ "resource": "" }
q19690
Instana.Tracer.log_async_error
train
def log_async_error(e, span) # Asynchronous spans can persist longer than the parent # trace. With the trace ID, we check the current trace # but otherwise, we search staged traces. if tracing? && self.current_trace.id == span.context.trace_id self.current_trace.add_async_error(e, span) else trace = ::Instana.processor.staged_trace(span.context.trace_id) if trace trace.add_async_error(e, span) else ::Instana.logger.debug "#{__method__}: Couldn't find staged trace. #{span.inspect}" end end end
ruby
{ "resource": "" }
q19691
Instana.Tracer.log_async_exit
train
def log_async_exit(_name, kvs, span) # An asynchronous span can end after the current trace has # already completed so we make sure that we end the span # on the right trace. if tracing? && self.current_trace.id == span.context.trace_id self.current_trace.end_async_span(kvs, span) else # Different trace from current so find the staged trace # and close out the span on it. trace = ::Instana.processor.staged_trace(span.context.trace_id) if trace trace.end_async_span(kvs, span) else ::Instana.logger.debug "#{__method__}: Couldn't find staged trace. #{span.inspect}" end end end
ruby
{ "resource": "" }
q19692
Instana.Tracer.inject
train
def inject(span_context, format, carrier) case format when OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY ::Instana.logger.debug 'Unsupported inject format' when OpenTracing::FORMAT_RACK carrier['X-Instana-T'] = ::Instana::Util.id_to_header(span_context.trace_id) carrier['X-Instana-S'] = ::Instana::Util.id_to_header(span_context.span_id) else ::Instana.logger.debug 'Unknown inject format' end end
ruby
{ "resource": "" }
q19693
Instana.Tracer.extract
train
def extract(format, carrier) case format when OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY ::Instana.logger.debug 'Unsupported extract format' when OpenTracing::FORMAT_RACK ::Instana::SpanContext.new(::Instana::Util.header_to_id(carrier['HTTP_X_INSTANA_T']), ::Instana::Util.header_to_id(carrier['HTTP_X_INSTANA_S'])) else ::Instana.logger.debug 'Unknown inject format' nil end end
ruby
{ "resource": "" }
q19694
Instana.Processor.add
train
def add(trace) # Do a quick checkup on our background thread. if ::Instana.agent.collect_thread.nil? || !::Instana.agent.collect_thread.alive? ::Instana.agent.spawn_background_thread end # ::Instana.logger.debug("Queuing completed trace id: #{trace.id}") @queue.push(trace) end
ruby
{ "resource": "" }
q19695
Instana.Processor.staged_trace
train
def staged_trace(trace_id) candidate = nil @staging_lock.synchronize { @staging_queue.each do |trace| if trace.id == trace_id candidate = trace break end end } unless candidate ::Instana.logger.debug("Couldn't find staged trace with trace_id: #{trace_id}") end candidate end
ruby
{ "resource": "" }
q19696
Instana.Trace.new_span
train
def new_span(name, kvs = nil, start_time = ::Instana::Util.now_in_ms, child_of = nil) return unless @current_span if child_of && child_of.is_a?(::Instana::Span) new_span = Span.new(name, @id, parent_id: child_of.id, start_time: start_time) new_span.parent = child_of new_span.baggage = child_of.baggage.dup else new_span = Span.new(name, @id, parent_id: @current_span.id, start_time: start_time) new_span.parent = @current_span new_span.baggage = @current_span.baggage.dup end new_span.set_tags(kvs) if kvs @spans.add(new_span) @current_span = new_span end
ruby
{ "resource": "" }
q19697
Instana.Trace.add_error
train
def add_error(e, span = nil) # Return if we've already logged this exception and it # is just propogating up the spans. return if e && e.instance_variable_get(:@instana_logged) || @current_span.nil? span ||= @current_span span.add_error(e) end
ruby
{ "resource": "" }
q19698
Instana.Trace.end_span
train
def end_span(kvs = {}, end_time = ::Instana::Util.now_in_ms) return unless @current_span @current_span.close(end_time) add_info(kvs) if kvs && !kvs.empty? @current_span = @current_span.parent unless @current_span.is_root? end
ruby
{ "resource": "" }
q19699
Instana.Trace.end_async_span
train
def end_async_span(kvs = {}, span) span.set_tags(kvs) unless kvs.empty? span.close end
ruby
{ "resource": "" }