Sha256: 3d5899938294135127b22702277ea2ad9622a7e509b64db1350e18e4c00c37d3
Contents?: true
Size: 1.45 KB
Versions: 3
Compression:
Stored size: 1.45 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 sending 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.code + " " + resp.message ) 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
BibOpsworks-0.1.2 | lib/bib/opsworks/newrelic.rb |
BibOpsworks-0.1.1 | lib/bib/opsworks/newrelic.rb |
BibOpsworks-0.1 | lib/bib/opsworks/newrelic.rb |