sftrace-agent 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '089b4350dffee510ef60ac8318aa207c14a5042c3b55bf2ffb821879d4e52271'
4
+ data.tar.gz: 91a85800408842cad4b8a581d30e086caa10dd358f25c3f3412eb922d78805d2
5
+ SHA512:
6
+ metadata.gz: bc6d6a396721b6d608ae64fbdc8dccb5f39c1da098352a1129d6a6ada044865d7de1857d760a62401f111fba7fee7ff36f68815c1928f747ba307136b81d7bd3
7
+ data.tar.gz: 21446ff215bc6f1c6b39e2afa23098bd7ed784cb952b20ddc25d82ee773fea80f07b44926482fad015a6e98b4fa4250c5b65f68542676c1c061d73b50a5090b1
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in sftrace-agent.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Anchal Gupta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # Sftrace::Agent
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.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sftrace-agent'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install sftrace-agent
20
+
21
+ ## Usage
22
+
23
+ Add the dependency at the top in the application.rb file.
24
+
25
+ ```ruby
26
+ require "elastic-apm"
27
+ ```
28
+
29
+ Add the following line inside the class of the main module in the application.rb file.
30
+
31
+ ```ruby
32
+ Sftrace::Agent.set_sftrace_config(File.dirname(__FILE__), ENV['RAILS_ENV'])
33
+ ```
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
+ ```
42
+
43
+ The config file should have the following details.
44
+
45
+ ```yaml
46
+ tags:
47
+ serviceName: sftrace-demo
48
+ appName: ruby
49
+ projectName: sftrace
50
+ key: k64QokCTjcgxlBZ6m0tBn0+iZpXB3602LED5nsnhPsWSvRtPfEioLRkF8BMQDZDki5R6kLCozgeoWsNXPa7zl7q6OdHjbHKHbLetc39ABseSq75tuGc6HUGpXhtiXkjO0l8IW2zFv5+2NxhY8ybJX/0Y8WgDr3CtyDVNLuaNeKljjTyNBMFO+iP4oOR9kA2YjV8f1//e/niu3FhJFA1CI7bXh+c3BsRPrpOkC8NOEjuvLbKRZLQYb5VilvxY5rxOyKTiKNer+J+MgXIUm+laAMBF9rXfW1m9YgpFoPtK2s1xysvLsjZteIvvPSBDZdA9PW/oa44y4etiwhEQQ5PUO3sSkyHKefkwyk+LqdqyJdm0XJja/a/n9/DbSn/G1MceaFC/f1Jt8u9AQq9OGnAkpA==
51
+ ```
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "sftrace/agent"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "agent/version"
4
+
5
+ module Sftrace
6
+ module Agent
7
+
8
+ class Error < StandardError; end
9
+
10
+ def self.set_sftrace_config(current_path, env)
11
+
12
+ sftrace_config_file = current_path + "/sftrace-" + env + "-config.yaml"
13
+
14
+ if (File.exist?(sftrace_config_file))
15
+ sftrace_array = YAML.load_file(sftrace_config_file)
16
+ 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
+
28
+ decoded_key = Base64.decode64("U25hcHB5RmxvdzEyMzQ1Ng==")
29
+ decoded_profile_key = Base64.decode64(sftrace_array["key"])
30
+
31
+ decipher = OpenSSL::Cipher::AES.new(128, :CBC)
32
+ decipher.decrypt
33
+ decipher.key = decoded_key
34
+ decipher.iv = decoded_profile_key[0, 16]
35
+ plain = decipher.update(decoded_profile_key[16..-1]) + decipher.final
36
+ plain_json = JSON.parse(plain)
37
+
38
+ global_labels = "_tag_projectName=" + sftrace_array["tags"]["projectName"] +
39
+ ",_tag_appName=" + sftrace_array["tags"]["appName"] +
40
+ ",_tag_profileId=" + plain_json["profile_id"]
41
+
42
+ ENV['ELASTIC_APM_VERIFY_SERVER_CERT'] = "false"
43
+ ENV['ELASTIC_APM_CENTRAL_CONFIG'] = "false"
44
+ ENV['ELASTIC_APM_SPAN_FRAMES_MIN_DURATION'] = "1s"
45
+ ENV['ELASTIC_APM_STACK_TRACE_LIMIT'] = "2"
46
+
47
+ ENV['ELASTIC_APM_SERVICE_NAME'] = sftrace_array["tags"]["serviceName"]
48
+ ENV['ELASTIC_APM_SERVER_URL'] = plain_json["trace_server_url"]
49
+ ENV['ELASTIC_APM_GLOBAL_LABELS'] = global_labels
50
+
51
+ puts "[SFTRACE] ELASTIC_APM_SERVICE_NAME : " + ENV['ELASTIC_APM_SERVICE_NAME']
52
+ puts "[SFTRACE] ELASTIC_APM_SERVER_URL : " + ENV['ELASTIC_APM_SERVER_URL']
53
+ 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."
57
+ end
58
+
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sftrace
4
+ module Agent
5
+ VERSION = "0.1.1"
6
+ end
7
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/sftrace/agent/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+
7
+ spec.name = "sftrace-agent"
8
+ spec.version = Sftrace::Agent::VERSION
9
+ spec.authors = ["SnappyFlow"]
10
+ spec.email = ["no-reply@snappyflow.io"]
11
+
12
+ spec.summary = "SnappyFlow tracing allows you to monitor software services and applications in real time."
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"
15
+ spec.license = "MIT"
16
+
17
+ spec.required_ruby_version = ">= 2.4.0"
18
+
19
+ # spec.metadata["allowed_push_host"] = "Set to 'https://mygemserver.com'"
20
+
21
+ # spec.metadata["homepage_uri"] = spec.homepage
22
+ # spec.metadata["source_code_uri"] = "Put your gem's public repo URL here."
23
+ # spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ # Uncomment to register a new dependency of your gem
35
+ # spec.add_dependency "example-gem", "~> 1.0"
36
+ spec.add_dependency "elastic-apm", "~> 4.3"
37
+
38
+ # For more information and examples about making a new gem, checkout our
39
+ # guide at: https://bundler.io/guides/creating_gem.html
40
+
41
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sftrace-agent
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - SnappyFlow
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-08-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: elastic-apm
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.3'
27
+ description: Sftracing enables you to analyze performance throughout your microservices
28
+ architecture all in one view. This is accomplished by tracing all of the requests
29
+ - from the initial web request to your front-end service - to queries made to your
30
+ back-end services. This makes finding possible bottlenecks throughout your application
31
+ much easier and faster.
32
+ email:
33
+ - no-reply@snappyflow.io
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - ".gitignore"
39
+ - Gemfile
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - bin/console
44
+ - bin/setup
45
+ - lib/sftrace/agent.rb
46
+ - lib/sftrace/agent/version.rb
47
+ - sftrace-agent.gemspec
48
+ homepage: https://www.snappyflow.io/#/resources/sftracing/Ruby
49
+ licenses:
50
+ - MIT
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.4.0
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubygems_version: 3.1.6
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: SnappyFlow tracing allows you to monitor software services and applications
71
+ in real time.
72
+ test_files: []