Module: Bottompad1
- Defined in:
- lib/bottompad1.rb,
lib/bottompad1/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
Class Method Details
.set_sftrace_config(current_path, env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/bottompad1.rb', line 9 def self.set_sftrace_config(current_path, env) sftrace_config_file = current_path + "/sftrace-" + env + "-config.yaml" if (File.exist?(sftrace_config_file)) sftrace_array = YAML.load_file(sftrace_config_file) else puts "[SFTRACE] Please provide a sftrace config.yaml file." return end if ((sftrace_array["key"] != nil) && (sftrace_array["tags"] != nil) && (sftrace_array["tags"]["serviceName"] != nil) && (sftrace_array["tags"]["appName"] != nil) && (sftrace_array["tags"]["projectName"] != nil) ) decoded_key = Base64.decode64("U25hcHB5RmxvdzEyMzQ1Ng==") decoded_profile_key = Base64.decode64(sftrace_array["key"]) decipher = OpenSSL::Cipher::AES.new(128, :CBC) decipher.decrypt decipher.key = decoded_key decipher.iv = decoded_profile_key[0, 16] plain = decipher.update(decoded_profile_key[16..-1]) + decipher.final plain_json = JSON.parse(plain) global_labels = "_tag_projectName=" + sftrace_array["tags"]["projectName"] + ",_tag_appName=" + sftrace_array["tags"]["appName"] + ",_tag_profileId=" + plain_json["profile_id"] ENV['ELASTIC_APM_VERIFY_SERVER_CERT'] = "false" ENV['ELASTIC_APM_CENTRAL_CONFIG'] = "false" ENV['ELASTIC_APM_SPAN_FRAMES_MIN_DURATION'] = "1s" ENV['ELASTIC_APM_STACK_TRACE_LIMIT'] = "2" ENV['ELASTIC_APM_SERVICE_NAME'] = sftrace_array["tags"]["serviceName"] ENV['ELASTIC_APM_SERVER_URL'] = plain_json["trace_server_url"] ENV['ELASTIC_APM_GLOBAL_LABELS'] = global_labels puts "[SFTRACE] SERVICE_NAME : " + ENV['ELASTIC_APM_SERVICE_NAME'] puts "[SFTRACE] SERVER_URL : " + ENV['ELASTIC_APM_SERVER_URL'] puts "[SFTRACE] GLOBAL_LABELS : " + ENV['ELASTIC_APM_GLOBAL_LABELS'] else puts "[SFTRACE] Add all the required details in sftrace config.yaml file." end end |