libddprof 0.2.0.beta1-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.standard.yml +3 -0
  4. data/README.md +29 -0
  5. data/Rakefile +149 -0
  6. data/docker-compose.yml +14 -0
  7. data/gems.rb +13 -0
  8. data/lib/libddprof/version.rb +9 -0
  9. data/lib/libddprof.rb +30 -0
  10. data/vendor/libddprof-0.2.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/LICENSE +202 -0
  11. data/vendor/libddprof-0.2.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/LICENSE-3rdparty.yml +767 -0
  12. data/vendor/libddprof-0.2.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/NOTICE +4 -0
  13. data/vendor/libddprof-0.2.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/cmake/DDProfConfig.cmake +41 -0
  14. data/vendor/libddprof-0.2.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/include/ddprof/ffi.h +455 -0
  15. data/vendor/libddprof-0.2.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/lib/libddprof_ffi.a +0 -0
  16. data/vendor/libddprof-0.2.0/x86_64-linux/libddprof-x86_64-unknown-linux-gnu/lib/pkgconfig/ddprof_ffi.pc +17 -0
  17. data/vendor/libddprof-0.2.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/LICENSE +202 -0
  18. data/vendor/libddprof-0.2.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/LICENSE-3rdparty.yml +767 -0
  19. data/vendor/libddprof-0.2.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/NOTICE +4 -0
  20. data/vendor/libddprof-0.2.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/cmake/DDProfConfig.cmake +41 -0
  21. data/vendor/libddprof-0.2.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/include/ddprof/ffi.h +455 -0
  22. data/vendor/libddprof-0.2.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/lib/libddprof_ffi.a +0 -0
  23. data/vendor/libddprof-0.2.0/x86_64-linux-musl/libddprof-x86_64-alpine-linux-musl/lib/pkgconfig/ddprof_ffi.pc +17 -0
  24. metadata +70 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a5410b5f6103dfd1b522775ca785fcddc64d690fe09bc111ac2d3a7e5ee46a26
4
+ data.tar.gz: e68e10cf9fb634e171df1d636bf7e69df2468f41e2e1af840bc3a2954bfb4adf
5
+ SHA512:
6
+ metadata.gz: 908426356711dc9f5c71c3a450f07f46f9e5aa53b7a3af766af60360bd7ef1b312609e268cb779fc447396716d77a359db724025bca2b8b537822844eac797cf
7
+ data.tar.gz: 4dddd8e664ef4dda3620e03104192cf232783b6867d3133a0097cea718a8c641a3a57705ddaaff1b75d0e8253792d397fdfdc286c80471106928b396a4733728
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.1
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # libddprof Ruby gem
2
+
3
+ `libddprof` provides a shared library containing common code used in the implementation of Datadog's
4
+ [Continuous Profilers](https://docs.datadoghq.com/tracing/profiler/).
5
+
6
+ **NOTE**: If you're building a new profiler or want to contribute to Datadog's existing profilers, you've come to the
7
+ right place!
8
+ Otherwise, this is possibly not the droid you were looking for.
9
+
10
+ ## Development
11
+
12
+ Run `bundle exec rake` to run the tests and the style autofixer.
13
+ You can also run `bundle exec pry` for an interactive prompt that will allow you to experiment.
14
+
15
+ ## Releasing a new version to rubygems.org
16
+
17
+ Note: No Ruby needed to run this! It all runs inside docker :)
18
+
19
+ 1. [ ] Locate the new libddprof release on GitHub: <https://github.com/DataDog/libddprof/releases>
20
+ 2. [ ] Update the `LIB_GITHUB_RELEASES` section of the <Rakefile> with the new version
21
+ 3. [ ] Update the <lib/libddprof/version.rb> file with the `LIB_VERSION` and `VERSION` to use
22
+ 4. [ ] Commit change, open PR, get it merged
23
+ 5. [ ] Release by running `docker-compose run push_to_rubygems`.
24
+ (When asked for rubygems credentials, check your local friendly 1Password.)
25
+ 6. [ ] Verify that release shows up correctly on: <https://rubygems.org/gems/libddprof>
26
+
27
+ ## Contributing
28
+
29
+ See <../CONTRIBUTING.md>.
data/Rakefile ADDED
@@ -0,0 +1,149 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "standard/rake" unless RUBY_VERSION < "2.5"
6
+
7
+ require "fileutils"
8
+ require "http"
9
+ require "pry"
10
+ require "rubygems/package"
11
+
12
+ RSpec::Core::RakeTask.new(:spec)
13
+
14
+ LIB_GITHUB_RELEASES = {
15
+ "0.2.0" => [
16
+ {
17
+ file: "libddprof-x86_64-unknown-linux-gnu.tar.gz",
18
+ sha256: "cba0f24074d44781d7252b912faff50d330957e84a8f40a172a8138e81001f27",
19
+ ruby_platform: "x86_64-linux"
20
+ },
21
+ {
22
+ file: "libddprof-x86_64-alpine-linux-musl.tar.gz",
23
+ sha256: "d519a6241d78260522624b8e79e98502510f11d5d9551f5f80fc1134e95fa146",
24
+ ruby_platform: "x86_64-linux-musl"
25
+ }
26
+ ]
27
+ # Add more versions here
28
+ }
29
+
30
+ task default: [
31
+ :spec,
32
+ (:'standard:fix' unless RUBY_VERSION < "2.5")
33
+ ].compact
34
+
35
+ desc "Download lib release from github"
36
+ task :fetch do
37
+ Helpers.each_github_release_variant do |file:, sha256:, target_directory:, target_file:, **_|
38
+ target_url = "https://github.com/DataDog/libddprof/releases/download/v#{Libddprof::LIB_VERSION}/#{file}"
39
+
40
+ if File.exist?(target_file)
41
+ if Digest::SHA256.hexdigest(File.read(target_file)) == sha256
42
+ puts "Found #{target_file} matching the expected sha256, skipping download"
43
+ next
44
+ else
45
+ puts "Found #{target_file} BUT IT DID NOT MATCH THE EXPECTED sha256, skipping download"
46
+ end
47
+ end
48
+
49
+ puts "Going to download #{target_url} into #{target_file}"
50
+
51
+ File.open(target_file, "wb") do |file|
52
+ HTTP.follow.get(target_url).body.each { |chunk| file.write(chunk) }
53
+ end
54
+
55
+ if Digest::SHA256.hexdigest(File.read(target_file)) == sha256
56
+ puts "Success!"
57
+ else
58
+ raise "Downloaded file is corrupt, does not match expected sha256"
59
+ end
60
+ end
61
+ end
62
+
63
+ desc "Extract lib downloaded releases"
64
+ task extract: [:fetch] do
65
+ Helpers.each_github_release_variant do |target_directory:, target_file:, **_|
66
+ puts "Extracting #{target_file}"
67
+ File.open(target_file, "rb") do |file|
68
+ Gem::Package.new("").extract_tar_gz(file, target_directory)
69
+ end
70
+ end
71
+ end
72
+
73
+ desc "Package lib downloaded releases as gems"
74
+ task package: [:spec, :'standard:fix', :extract] do
75
+ gemspec = eval(File.read("libddprof.gemspec"), nil, "libddprof.gemspec") # standard:disable Security/Eval
76
+ FileUtils.mkdir_p("pkg")
77
+
78
+ Helpers.package_without_binaries(gemspec)
79
+ Helpers.package_linux_x86_64(gemspec)
80
+ end
81
+
82
+ desc "Release all packaged gems"
83
+ task push_to_rubygems: [
84
+ :package,
85
+ :'release:guard_clean'
86
+ ] do
87
+ system("gem signout") # make sure there are no existing credentials in use
88
+
89
+ system("gem push pkg/libddprof-#{Libddprof::VERSION}.gem")
90
+ system("gem push pkg/libddprof-#{Libddprof::VERSION}-x86_64-linux.gem")
91
+
92
+ system("gem signout") # leave no credentials behind
93
+ end
94
+
95
+ module Helpers
96
+ def self.each_github_release_variant(version: Libddprof::LIB_VERSION)
97
+ LIB_GITHUB_RELEASES.fetch(version).each do |variant|
98
+ file = variant.fetch(:file)
99
+ sha256 = variant.fetch(:sha256)
100
+ ruby_platform = variant.fetch(:ruby_platform)
101
+
102
+ # These two are so common that we just centralize them here
103
+ target_directory = "vendor/libddprof-#{version}/#{ruby_platform}"
104
+ target_file = "#{target_directory}/#{file}"
105
+
106
+ FileUtils.mkdir_p(target_directory)
107
+
108
+ yield(file: file, sha256: sha256, ruby_platform: ruby_platform, target_directory: target_directory, target_file: target_file)
109
+ end
110
+ end
111
+
112
+ def self.package_without_binaries(gemspec)
113
+ target_gemspec = gemspec.dup
114
+
115
+ puts "Building a variant without binaries including:"
116
+ pp target_gemspec.files
117
+
118
+ package = Gem::Package.build(target_gemspec)
119
+ FileUtils.mv(package, "pkg")
120
+ puts("-" * 80)
121
+ end
122
+
123
+ def self.package_linux_x86_64(gemspec)
124
+ # We include both glibc and musl variants in the same binary gem to avoid the issues
125
+ # documented in https://github.com/rubygems/rubygems/issues/3174
126
+ target_gemspec = gemspec.dup
127
+ target_gemspec.files += files_for("x86_64-linux", "x86_64-linux-musl")
128
+ target_gemspec.platform = "x86_64-linux"
129
+
130
+ puts "Building for x86_64-linux including: (this can take a while)"
131
+ pp target_gemspec.files
132
+
133
+ package = Gem::Package.build(target_gemspec)
134
+ FileUtils.mv(package, "pkg")
135
+ puts("-" * 80)
136
+ end
137
+
138
+ def self.files_for(*included_platforms, version: Libddprof::LIB_VERSION)
139
+ files = []
140
+
141
+ each_github_release_variant(version: version) do |ruby_platform:, target_directory:, target_file:, **_|
142
+ next unless included_platforms.include?(ruby_platform)
143
+
144
+ files += Dir.glob("#{target_directory}/**/*").select { |path| File.file?(path) } - [target_file]
145
+ end
146
+
147
+ files
148
+ end
149
+ end
@@ -0,0 +1,14 @@
1
+ version: '3.2'
2
+ services:
3
+ push_to_rubygems:
4
+ image: ruby:3.1
5
+ platform: linux/x86_64
6
+ stdin_open: true
7
+ tty: true
8
+ command: bash -c 'cd /libddprof/ruby && bundle install && bundle exec rake push_to_rubygems'
9
+ volumes:
10
+ - ..:/libddprof
11
+ - bundle-3.1:/usr/local/bundle
12
+
13
+ volumes:
14
+ bundle-3.1:
data/gems.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in libddprof.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "rspec", "~> 3.10"
10
+ gem "standard", "~> 1.3" unless RUBY_VERSION < "2.5"
11
+ gem "http", "~> 5.0"
12
+ gem "pry"
13
+ gem "pry-byebug"
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Libddprof
4
+ # Current libddprof version
5
+ LIB_VERSION = "0.2.0"
6
+
7
+ # This is the Ruby gem version -- often it will match LIB_VERSION, but sometimes it may not
8
+ VERSION = "#{LIB_VERSION}.beta1"
9
+ end
data/lib/libddprof.rb ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "libddprof/version"
4
+
5
+ module Libddprof
6
+ # Is this a no-op libddprof release without binaries?
7
+ def self.no_binaries?
8
+ available_binaries.empty?
9
+ end
10
+
11
+ def self.available_binaries
12
+ Dir.children(vendor_directory)
13
+ end
14
+
15
+ def self.pkgconfig_folder
16
+ current_platform = Gem::Platform.local.to_s
17
+
18
+ return unless available_binaries.include?(current_platform)
19
+
20
+ pkgconfig_file = Dir.glob("#{vendor_directory}/#{current_platform}/**/ddprof_ffi.pc").first
21
+
22
+ return unless pkgconfig_file
23
+
24
+ File.absolute_path(File.dirname(pkgconfig_file))
25
+ end
26
+
27
+ private_class_method def self.vendor_directory
28
+ ENV["LIBDDPROF_VENDOR_OVERRIDE"] || "#{__dir__}/../vendor/libddprof-#{Libddprof::LIB_VERSION}/"
29
+ end
30
+ end
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.