Sha256: f17daaf3cd64daceab9e3195148b72352369b385f3550b418a8a075282295882
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
require 'net/http' module Bib module Opsworks class Newrelic include Logging def publish_deployment(app_name, deploy_data, newrelic_api_key) newrelic_params = prepare_publishing_data(app_name, deploy_data) newrelic_url = "https://rpm.newrelic.com/deployments.xml" url = URI.parse(newrelic_url) request = Net::HTTP::Post.new(url.request_uri) request.add_field('X-Api-Key', newrelic_api_key) request.set_form_data(newrelic_params) log.debug("Newrelic Data: " + newrelic_params.inspect) http = Net::HTTP.new(url.host, url.port) http.use_ssl = true resp = http.request(request) log.debug("Newrelic Response: " + resp.inspect ) resp.is_a? Net::HTTPSuccess end def prepare_publishing_data(app_name, deploy_data) scm_revision = deploy_data["scm"]["revision"] if deploy_data["deploying_user"].nil? or deploy_data["deploying_user"].empty? deployment_user = "opsworks" else deployment_user = deploy_data["deploying_user"].split('/')[1] end newrelic_params = {} { :app_name => app_name, :user => deployment_user, :revision => scm_revision }.each do |k, v| newrelic_params["deployment[#{k}]"] = v unless v.nil? || v == '' end newrelic_params end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
BibOpsworks-0.0.9.3 | lib/bib/opsworks/newrelic.rb |
BibOpsworks-0.0.9.2 | lib/bib/opsworks/newrelic.rb |