sftrace-agent 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '089b4350dffee510ef60ac8318aa207c14a5042c3b55bf2ffb821879d4e52271'
4
- data.tar.gz: 91a85800408842cad4b8a581d30e086caa10dd358f25c3f3412eb922d78805d2
3
+ metadata.gz: ccbd4586ca78a5351e5af9500f5a675e6c22f42f05f853ab7dbd3149103c971e
4
+ data.tar.gz: a5c1b3950348cedb9eb0041827381895abb4fd28fa5a73c6760fc5d2791cde45
5
5
  SHA512:
6
- metadata.gz: bc6d6a396721b6d608ae64fbdc8dccb5f39c1da098352a1129d6a6ada044865d7de1857d760a62401f111fba7fee7ff36f68815c1928f747ba307136b81d7bd3
7
- data.tar.gz: 21446ff215bc6f1c6b39e2afa23098bd7ed784cb952b20ddc25d82ee773fea80f07b44926482fad015a6e98b4fa4250c5b65f68542676c1c061d73b50a5090b1
6
+ metadata.gz: b737638874179bff24bb0fbaa3239d46b3b7d4b4456f6cb8b214b9d7cb0984eda791c7afce5b811779d8269976698b6665a327376e8a083a1bd637efff2004dc
7
+ data.tar.gz: 71a475e5d22a0beb80815d944e46c39c8c2f9e3a64d38f29131b15ce035cedf6909a4d889a760cc31250edc7bf7de98b7052fd6229c56370dbce3bb90df72805
data/lib/sftrace/agent.rb CHANGED
@@ -7,26 +7,57 @@ module Sftrace
7
7
 
8
8
  class Error < StandardError; end
9
9
 
10
- def self.set_sftrace_config(current_path, env)
10
+ def self.set_sftrace_config(serviceName)
11
11
 
12
- sftrace_config_file = current_path + "/sftrace-" + env + "-config.yaml"
12
+ sftrace_config_file = "/opt/sfagent/config.yaml"
13
13
 
14
14
  if (File.exist?(sftrace_config_file))
15
+
15
16
  sftrace_array = YAML.load_file(sftrace_config_file)
17
+
18
+ if ((sftrace_array["key"] != nil) &&
19
+ (sftrace_array["tags"] != nil) &&
20
+ (sftrace_array["tags"]["appName"] != nil) &&
21
+ (sftrace_array["tags"]["projectName"] != nil)
22
+ )
23
+
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
+
51
+ else
52
+ puts "[SFTRACE] Add all the required details in sftrace config.yaml file."
53
+ end
54
+
16
55
  else
17
- puts "[SFTRACE] Please provide a sftrace config.yaml file."
18
- return
19
- end
20
-
21
- if ((sftrace_array["key"] != nil) &&
22
- (sftrace_array["tags"] != nil) &&
23
- (sftrace_array["tags"]["serviceName"] != nil) &&
24
- (sftrace_array["tags"]["appName"] != nil) &&
25
- (sftrace_array["tags"]["projectName"] != nil)
26
- )
27
-
56
+
57
+ puts "[SFTRACE] Please provide a sftrace config.yaml file or else will read from env. variables."
58
+
28
59
  decoded_key = Base64.decode64("U25hcHB5RmxvdzEyMzQ1Ng==")
29
- decoded_profile_key = Base64.decode64(sftrace_array["key"])
60
+ decoded_profile_key = Base64.decode64(ENV['SFTRACE_PROFILE_KEY'])
30
61
 
31
62
  decipher = OpenSSL::Cipher::AES.new(128, :CBC)
32
63
  decipher.decrypt
@@ -35,25 +66,24 @@ module Sftrace
35
66
  plain = decipher.update(decoded_profile_key[16..-1]) + decipher.final
36
67
  plain_json = JSON.parse(plain)
37
68
 
38
- global_labels = "_tag_projectName=" + sftrace_array["tags"]["projectName"] +
39
- ",_tag_appName=" + sftrace_array["tags"]["appName"] +
69
+ global_labels = "_tag_projectName=" + ENV['SFTRACE_PROJECT_NAME'] +
70
+ ",_tag_appName=" + ENV['SFTRACE_APP_NAME'] +
40
71
  ",_tag_profileId=" + plain_json["profile_id"]
41
-
72
+
42
73
  ENV['ELASTIC_APM_VERIFY_SERVER_CERT'] = "false"
43
74
  ENV['ELASTIC_APM_CENTRAL_CONFIG'] = "false"
44
75
  ENV['ELASTIC_APM_SPAN_FRAMES_MIN_DURATION'] = "1s"
45
76
  ENV['ELASTIC_APM_STACK_TRACE_LIMIT'] = "2"
46
77
 
47
- ENV['ELASTIC_APM_SERVICE_NAME'] = sftrace_array["tags"]["serviceName"]
78
+ ENV['ELASTIC_APM_SERVICE_NAME'] = ENV['SFTRACE_SERVICE_NAME']
48
79
  ENV['ELASTIC_APM_SERVER_URL'] = plain_json["trace_server_url"]
49
80
  ENV['ELASTIC_APM_GLOBAL_LABELS'] = global_labels
50
-
81
+
51
82
  puts "[SFTRACE] ELASTIC_APM_SERVICE_NAME : " + ENV['ELASTIC_APM_SERVICE_NAME']
52
83
  puts "[SFTRACE] ELASTIC_APM_SERVER_URL : " + ENV['ELASTIC_APM_SERVER_URL']
53
84
  puts "[SFTRACE] ELASTIC_APM_GLOBAL_LABELS : " + ENV['ELASTIC_APM_GLOBAL_LABELS']
54
-
55
- else
56
- puts "[SFTRACE] Add all the required details in sftrace config.yaml file."
85
+
86
+ return
57
87
  end
58
88
 
59
89
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sftrace
4
4
  module Agent
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = "SnappyFlow tracing allows you to monitor software services and applications in real time."
13
13
  spec.description = "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."
14
- spec.homepage = "https://www.snappyflow.io/#/resources/sftracing/Ruby"
14
+ spec.homepage = "https://www.snappyflow.io/#/resources/sftracing/ruby"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.required_ruby_version = ">= 2.4.0"
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - SnappyFlow
@@ -45,7 +45,7 @@ files:
45
45
  - lib/sftrace/agent.rb
46
46
  - lib/sftrace/agent/version.rb
47
47
  - sftrace-agent.gemspec
48
- homepage: https://www.snappyflow.io/#/resources/sftracing/Ruby
48
+ homepage: https://www.snappyflow.io/#/resources/sftracing/ruby
49
49
  licenses:
50
50
  - MIT
51
51
  metadata: {}