sftrace-agent 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccbd4586ca78a5351e5af9500f5a675e6c22f42f05f853ab7dbd3149103c971e
4
- data.tar.gz: a5c1b3950348cedb9eb0041827381895abb4fd28fa5a73c6760fc5d2791cde45
3
+ metadata.gz: 1942a879d87a1ddbd17b16a20975a194c8dbcedc4af140a2f5a3405f10e54842
4
+ data.tar.gz: 26f69f657c6750ee4994955f4c66966c92600b8bc9a9c1e0293fd0fab1e2b398
5
5
  SHA512:
6
- metadata.gz: b737638874179bff24bb0fbaa3239d46b3b7d4b4456f6cb8b214b9d7cb0984eda791c7afce5b811779d8269976698b6665a327376e8a083a1bd637efff2004dc
7
- data.tar.gz: 71a475e5d22a0beb80815d944e46c39c8c2f9e3a64d38f29131b15ce035cedf6909a4d889a760cc31250edc7bf7de98b7052fd6229c56370dbce3bb90df72805
6
+ metadata.gz: f39d5e1bb9efeb6cb3d3dc0a7be0168ae8de21f27c1a42427d7a7a58db0eb105b6b4b9e8a2338f47d80e45252114f2ea88a8bdcc3a7b939fc15c48ffbcdbda6d
7
+ data.tar.gz: 28b684b6a16556b9e5af32538134207573ed6d160eb182a6092c32842052ec26ad525e2463d87944f75d36332917a15e5e083bcc5b391f5236855752c85c4ef0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Sftrace::Agent
2
2
 
3
- Sftracing enables you to analyze performance throughout your microservices architecture all in one view. This is accomplished by tracing all of the requests - from the initial web request to your front-end service - to queries made to your back-end services. This makes finding possible bottlenecks throughout your application much easier and faster.
3
+ Sftracing enables you to analyze performance throughout your microservices architecture all in one view. This is accomplished by tracing all the requests - from the initial web request to your front-end service - to queries made to your back-end services. This makes finding possible bottlenecks throughout your application much easier and faster.
4
4
 
5
5
  ## Installation
6
6
 
@@ -29,16 +29,10 @@ require "elastic-apm"
29
29
  Add the following line inside the class of the main module in the application.rb file.
30
30
 
31
31
  ```ruby
32
- Sftrace::Agent.set_sftrace_config(File.dirname(__FILE__), ENV['RAILS_ENV'])
32
+ Sftrace::Agent.set_sftrace_config('sftrace-demo', '/opt/sfagent/config.yaml')
33
33
  ```
34
34
 
35
- Create config.yaml file inside the config folder.
36
-
37
- The file name should be of the following format :
38
-
39
- ```
40
- sftrace-development-config.yaml OR sftrace-production-config.yaml
41
- ```
35
+ Create config.yaml file either inside the `config` folder of the Ruby on Rails Application or inside the `/opt/sfagent/` folder.
42
36
 
43
37
  The config file should have the following details.
44
38
 
@@ -50,6 +44,16 @@ tags:
50
44
  key: k64QokCTjcgxlBZ6m0tBn0+iZpXB3602LED5nsnhPsWSvRtPfEioLRkF8BMQDZDki5R6kLCozgeoWsNXPa7zl7q6OdHjbHKHbLetc39ABseSq75tuGc6HUGpXhtiXkjO0l8IW2zFv5+2NxhY8ybJX/0Y8WgDr3CtyDVNLuaNeKljjTyNBMFO+iP4oOR9kA2YjV8f1//e/niu3FhJFA1CI7bXh+c3BsRPrpOkC8NOEjuvLbKRZLQYb5VilvxY5rxOyKTiKNer+J+MgXIUm+laAMBF9rXfW1m9YgpFoPtK2s1xysvLsjZteIvvPSBDZdA9PW/oa44y4etiwhEQQ5PUO3sSkyHKefkwyk+LqdqyJdm0XJja/a/n9/DbSn/G1MceaFC/f1Jt8u9AQq9OGnAkpA==
51
45
  ```
52
46
 
47
+ ## Development
48
+
49
+ If you want to edit the Gem, then you can edit the following :
50
+
51
+ `lib/sftrace/agent.rb` : contains the actual logic
52
+
53
+ `lib/sftrace/agent/version.rb` : contains the Gem version
54
+
55
+ `sftrace-agent.gemspec` : contains the Gem specification
56
+
53
57
  ## License
54
58
 
55
59
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/lib/sftrace/agent.rb CHANGED
@@ -7,47 +7,56 @@ module Sftrace
7
7
 
8
8
  class Error < StandardError; end
9
9
 
10
- def self.set_sftrace_config(serviceName)
10
+ def self.set_config(profile_key, project_name, app_name, service_name)
11
11
 
12
- sftrace_config_file = "/opt/sfagent/config.yaml"
13
-
14
- if (File.exist?(sftrace_config_file))
12
+ decoded_key = Base64.decode64("U25hcHB5RmxvdzEyMzQ1Ng==")
13
+ decoded_profile_key = Base64.decode64(profile_key)
14
+
15
+ decipher = OpenSSL::Cipher::AES.new(128, :CBC)
16
+ decipher.decrypt
17
+ decipher.key = decoded_key
18
+ decipher.iv = decoded_profile_key[0, 16]
19
+ plain = decipher.update(decoded_profile_key[16..-1]) + decipher.final
20
+ plain_json = JSON.parse(plain)
21
+
22
+ global_labels = "_tag_projectName=" + project_name +
23
+ ",_tag_appName=" + app_name +
24
+ ",_tag_profileId=" + plain_json["profile_id"]
25
+
26
+ ENV['ELASTIC_APM_VERIFY_SERVER_CERT'] = "false"
27
+ ENV['ELASTIC_APM_CENTRAL_CONFIG'] = "false"
28
+ ENV['ELASTIC_APM_SPAN_FRAMES_MIN_DURATION'] = "1s"
29
+ ENV['ELASTIC_APM_STACK_TRACE_LIMIT'] = "2"
30
+
31
+ ENV['ELASTIC_APM_SERVICE_NAME'] = service_name
32
+ ENV['ELASTIC_APM_SERVER_URL'] = plain_json["trace_server_url"]
33
+ ENV['ELASTIC_APM_GLOBAL_LABELS'] = global_labels
34
+
35
+ puts "[SFTRACE] ELASTIC_APM_SERVICE_NAME : " + ENV['ELASTIC_APM_SERVICE_NAME']
36
+ puts "[SFTRACE] ELASTIC_APM_SERVER_URL : " + ENV['ELASTIC_APM_SERVER_URL']
37
+ puts "[SFTRACE] ELASTIC_APM_GLOBAL_LABELS : " + ENV['ELASTIC_APM_GLOBAL_LABELS']
38
+
39
+ end
15
40
 
16
- sftrace_array = YAML.load_file(sftrace_config_file)
41
+ def self.set_sftrace_config(service_name, config_path)
42
+
43
+ if (File.exist?(config_path))
44
+
45
+ sftrace_array = YAML.load_file(config_path)
17
46
 
18
47
  if ((sftrace_array["key"] != nil) &&
19
48
  (sftrace_array["tags"] != nil) &&
20
- (sftrace_array["tags"]["appName"] != nil) &&
21
- (sftrace_array["tags"]["projectName"] != nil)
49
+ (sftrace_array["tags"]["projectName"] != nil) &&
50
+ (sftrace_array["tags"]["appName"] != nil)
22
51
  )
23
52
 
24
- decoded_key = Base64.decode64("U25hcHB5RmxvdzEyMzQ1Ng==")
25
- decoded_profile_key = Base64.decode64(sftrace_array["key"])
26
-
27
- decipher = OpenSSL::Cipher::AES.new(128, :CBC)
28
- decipher.decrypt
29
- decipher.key = decoded_key
30
- decipher.iv = decoded_profile_key[0, 16]
31
- plain = decipher.update(decoded_profile_key[16..-1]) + decipher.final
32
- plain_json = JSON.parse(plain)
33
-
34
- global_labels = "_tag_projectName=" + sftrace_array["tags"]["projectName"] +
35
- ",_tag_appName=" + sftrace_array["tags"]["appName"] +
36
- ",_tag_profileId=" + plain_json["profile_id"]
37
-
38
- ENV['ELASTIC_APM_VERIFY_SERVER_CERT'] = "false"
39
- ENV['ELASTIC_APM_CENTRAL_CONFIG'] = "false"
40
- ENV['ELASTIC_APM_SPAN_FRAMES_MIN_DURATION'] = "1s"
41
- ENV['ELASTIC_APM_STACK_TRACE_LIMIT'] = "2"
42
-
43
- ENV['ELASTIC_APM_SERVICE_NAME'] = serviceName
44
- ENV['ELASTIC_APM_SERVER_URL'] = plain_json["trace_server_url"]
45
- ENV['ELASTIC_APM_GLOBAL_LABELS'] = global_labels
46
-
47
- puts "[SFTRACE] ELASTIC_APM_SERVICE_NAME : " + ENV['ELASTIC_APM_SERVICE_NAME']
48
- puts "[SFTRACE] ELASTIC_APM_SERVER_URL : " + ENV['ELASTIC_APM_SERVER_URL']
49
- puts "[SFTRACE] ELASTIC_APM_GLOBAL_LABELS : " + ENV['ELASTIC_APM_GLOBAL_LABELS']
50
-
53
+ set_config(
54
+ sftrace_array["key"],
55
+ sftrace_array["tags"]["projectName"],
56
+ sftrace_array["tags"]["appName"],
57
+ service_name
58
+ )
59
+
51
60
  else
52
61
  puts "[SFTRACE] Add all the required details in sftrace config.yaml file."
53
62
  end
@@ -56,34 +65,13 @@ module Sftrace
56
65
 
57
66
  puts "[SFTRACE] Please provide a sftrace config.yaml file or else will read from env. variables."
58
67
 
59
- decoded_key = Base64.decode64("U25hcHB5RmxvdzEyMzQ1Ng==")
60
- decoded_profile_key = Base64.decode64(ENV['SFTRACE_PROFILE_KEY'])
61
-
62
- decipher = OpenSSL::Cipher::AES.new(128, :CBC)
63
- decipher.decrypt
64
- decipher.key = decoded_key
65
- decipher.iv = decoded_profile_key[0, 16]
66
- plain = decipher.update(decoded_profile_key[16..-1]) + decipher.final
67
- plain_json = JSON.parse(plain)
68
-
69
- global_labels = "_tag_projectName=" + ENV['SFTRACE_PROJECT_NAME'] +
70
- ",_tag_appName=" + ENV['SFTRACE_APP_NAME'] +
71
- ",_tag_profileId=" + plain_json["profile_id"]
72
-
73
- ENV['ELASTIC_APM_VERIFY_SERVER_CERT'] = "false"
74
- ENV['ELASTIC_APM_CENTRAL_CONFIG'] = "false"
75
- ENV['ELASTIC_APM_SPAN_FRAMES_MIN_DURATION'] = "1s"
76
- ENV['ELASTIC_APM_STACK_TRACE_LIMIT'] = "2"
77
-
78
- ENV['ELASTIC_APM_SERVICE_NAME'] = ENV['SFTRACE_SERVICE_NAME']
79
- ENV['ELASTIC_APM_SERVER_URL'] = plain_json["trace_server_url"]
80
- ENV['ELASTIC_APM_GLOBAL_LABELS'] = global_labels
81
-
82
- puts "[SFTRACE] ELASTIC_APM_SERVICE_NAME : " + ENV['ELASTIC_APM_SERVICE_NAME']
83
- puts "[SFTRACE] ELASTIC_APM_SERVER_URL : " + ENV['ELASTIC_APM_SERVER_URL']
84
- puts "[SFTRACE] ELASTIC_APM_GLOBAL_LABELS : " + ENV['ELASTIC_APM_GLOBAL_LABELS']
68
+ set_config(
69
+ ENV['SFTRACE_PROFILE_KEY'],
70
+ ENV['SFTRACE_PROJECT_NAME'],
71
+ ENV['SFTRACE_APP_NAME'],
72
+ ENV['SFTRACE_SERVICE_NAME']
73
+ )
85
74
 
86
- return
87
75
  end
88
76
 
89
77
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sftrace
4
4
  module Agent
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sftrace-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - SnappyFlow