pyroscope 0.5.2 → 0.5.6

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: 2df2aadb375817510148da8e0beb6c84f7e8dcf559880cead304769cd9064288
4
- data.tar.gz: 1e5bebc0f191213f0094fde5d6d0e8d77a9bb4154af6a3bd6b3e1c0668eb93b5
3
+ metadata.gz: f09d48a6590ce6d6d1769b357d43838a9bf53fb650de63587dc88e21a4e5bdaa
4
+ data.tar.gz: e22bc8052b1860f411e739c2709964d5838001ebd78255427a54ff2904ee9db7
5
5
  SHA512:
6
- metadata.gz: 936d218a6d14fad7f10a9363dffe23f4c4c79b80024f37175c2ec2320d7a4ef3c5c28efcf6cfcd124059edc269f40cd8b4340d698b4b5da8f129d6c1c9d77159
7
- data.tar.gz: 2629463e69eee473fb92e42ae836127fe2410d7c8789c32364b993497b1d9a19d02c6bc79b89f4359261bd000849639108064bb007ce433bc2e0b49be632e239
6
+ metadata.gz: c449397e5319bd6be334f939d59513edbbb9464221a4b96498657f067e2ef33664cf20b00a24ae717a81adb16498ebb24a6f75ae1f7de141c4778250510415ca
7
+ data.tar.gz: 4b434d44f410272bd4b12c41bd02fd2f40f2469796f211e89f9d3b03ac0ead5f66fb7d2d9801bc67b1c2cba44ab1cb948e427f4887fef6f15056f9732cacc8a8
data/ext/rbspy/Cargo.lock CHANGED
@@ -373,16 +373,6 @@ dependencies = [
373
373
  "crossbeam-utils",
374
374
  ]
375
375
 
376
- [[package]]
377
- name = "core-foundation"
378
- version = "0.9.3"
379
- source = "registry+https://github.com/rust-lang/crates.io-index"
380
- checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
381
- dependencies = [
382
- "core-foundation-sys",
383
- "libc",
384
- ]
385
-
386
376
  [[package]]
387
377
  name = "core-foundation-sys"
388
378
  version = "0.8.3"
@@ -636,21 +626,6 @@ version = "1.0.7"
636
626
  source = "registry+https://github.com/rust-lang/crates.io-index"
637
627
  checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
638
628
 
639
- [[package]]
640
- name = "foreign-types"
641
- version = "0.3.2"
642
- source = "registry+https://github.com/rust-lang/crates.io-index"
643
- checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
644
- dependencies = [
645
- "foreign-types-shared",
646
- ]
647
-
648
- [[package]]
649
- name = "foreign-types-shared"
650
- version = "0.1.1"
651
- source = "registry+https://github.com/rust-lang/crates.io-index"
652
- checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
653
-
654
629
  [[package]]
655
630
  name = "form_urlencoded"
656
631
  version = "1.1.0"
@@ -917,19 +892,6 @@ dependencies = [
917
892
  "tokio-rustls",
918
893
  ]
919
894
 
920
- [[package]]
921
- name = "hyper-tls"
922
- version = "0.5.0"
923
- source = "registry+https://github.com/rust-lang/crates.io-index"
924
- checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
925
- dependencies = [
926
- "bytes",
927
- "hyper",
928
- "native-tls",
929
- "tokio",
930
- "tokio-native-tls",
931
- ]
932
-
933
895
  [[package]]
934
896
  name = "iana-time-zone"
935
897
  version = "0.1.53"
@@ -1085,6 +1047,12 @@ dependencies = [
1085
1047
  "wasm-bindgen",
1086
1048
  ]
1087
1049
 
1050
+ [[package]]
1051
+ name = "json"
1052
+ version = "0.12.4"
1053
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1054
+ checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"
1055
+
1088
1056
  [[package]]
1089
1057
  name = "lazy_static"
1090
1058
  version = "0.1.16"
@@ -1285,24 +1253,6 @@ dependencies = [
1285
1253
  "rand 0.8.5",
1286
1254
  ]
1287
1255
 
1288
- [[package]]
1289
- name = "native-tls"
1290
- version = "0.2.11"
1291
- source = "registry+https://github.com/rust-lang/crates.io-index"
1292
- checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
1293
- dependencies = [
1294
- "lazy_static 1.4.0",
1295
- "libc",
1296
- "log",
1297
- "openssl",
1298
- "openssl-probe",
1299
- "openssl-sys",
1300
- "schannel",
1301
- "security-framework",
1302
- "security-framework-sys",
1303
- "tempfile",
1304
- ]
1305
-
1306
1256
  [[package]]
1307
1257
  name = "nix"
1308
1258
  version = "0.25.1"
@@ -1394,51 +1344,6 @@ version = "1.17.1"
1394
1344
  source = "registry+https://github.com/rust-lang/crates.io-index"
1395
1345
  checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
1396
1346
 
1397
- [[package]]
1398
- name = "openssl"
1399
- version = "0.10.45"
1400
- source = "registry+https://github.com/rust-lang/crates.io-index"
1401
- checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1"
1402
- dependencies = [
1403
- "bitflags",
1404
- "cfg-if",
1405
- "foreign-types",
1406
- "libc",
1407
- "once_cell",
1408
- "openssl-macros",
1409
- "openssl-sys",
1410
- ]
1411
-
1412
- [[package]]
1413
- name = "openssl-macros"
1414
- version = "0.1.0"
1415
- source = "registry+https://github.com/rust-lang/crates.io-index"
1416
- checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
1417
- dependencies = [
1418
- "proc-macro2",
1419
- "quote",
1420
- "syn",
1421
- ]
1422
-
1423
- [[package]]
1424
- name = "openssl-probe"
1425
- version = "0.1.5"
1426
- source = "registry+https://github.com/rust-lang/crates.io-index"
1427
- checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
1428
-
1429
- [[package]]
1430
- name = "openssl-sys"
1431
- version = "0.9.80"
1432
- source = "registry+https://github.com/rust-lang/crates.io-index"
1433
- checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7"
1434
- dependencies = [
1435
- "autocfg",
1436
- "cc",
1437
- "libc",
1438
- "pkg-config",
1439
- "vcpkg",
1440
- ]
1441
-
1442
1347
  [[package]]
1443
1348
  name = "os_str_bytes"
1444
1349
  version = "6.4.1"
@@ -1488,12 +1393,6 @@ version = "0.1.0"
1488
1393
  source = "registry+https://github.com/rust-lang/crates.io-index"
1489
1394
  checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
1490
1395
 
1491
- [[package]]
1492
- name = "pkg-config"
1493
- version = "0.3.26"
1494
- source = "registry+https://github.com/rust-lang/crates.io-index"
1495
- checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
1496
-
1497
1396
  [[package]]
1498
1397
  name = "plain"
1499
1398
  version = "0.2.3"
@@ -1611,8 +1510,9 @@ dependencies = [
1611
1510
 
1612
1511
  [[package]]
1613
1512
  name = "pyroscope"
1614
- version = "0.5.4"
1513
+ version = "0.5.5"
1615
1514
  dependencies = [
1515
+ "json",
1616
1516
  "libc",
1617
1517
  "libflate",
1618
1518
  "log",
@@ -1626,7 +1526,7 @@ dependencies = [
1626
1526
 
1627
1527
  [[package]]
1628
1528
  name = "pyroscope_rbspy"
1629
- version = "0.2.3"
1529
+ version = "0.2.5"
1630
1530
  dependencies = [
1631
1531
  "anyhow",
1632
1532
  "inferno",
@@ -1725,6 +1625,7 @@ dependencies = [
1725
1625
  "cbindgen",
1726
1626
  "ffikit",
1727
1627
  "inferno",
1628
+ "log",
1728
1629
  "pretty_env_logger",
1729
1630
  "pyroscope",
1730
1631
  "pyroscope_rbspy",
@@ -1875,29 +1776,26 @@ dependencies = [
1875
1776
  "http-body",
1876
1777
  "hyper",
1877
1778
  "hyper-rustls",
1878
- "hyper-tls",
1879
1779
  "ipnet",
1880
1780
  "js-sys",
1881
1781
  "log",
1882
1782
  "mime",
1883
- "native-tls",
1884
1783
  "once_cell",
1885
1784
  "percent-encoding",
1886
1785
  "pin-project-lite",
1887
1786
  "rustls",
1888
- "rustls-native-certs",
1889
1787
  "rustls-pemfile",
1890
1788
  "serde",
1891
1789
  "serde_json",
1892
1790
  "serde_urlencoded",
1893
1791
  "tokio",
1894
- "tokio-native-tls",
1895
1792
  "tokio-rustls",
1896
1793
  "tower-service",
1897
1794
  "url",
1898
1795
  "wasm-bindgen",
1899
1796
  "wasm-bindgen-futures",
1900
1797
  "web-sys",
1798
+ "webpki-roots",
1901
1799
  "winreg",
1902
1800
  ]
1903
1801
 
@@ -1978,18 +1876,6 @@ dependencies = [
1978
1876
  "webpki",
1979
1877
  ]
1980
1878
 
1981
- [[package]]
1982
- name = "rustls-native-certs"
1983
- version = "0.6.2"
1984
- source = "registry+https://github.com/rust-lang/crates.io-index"
1985
- checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50"
1986
- dependencies = [
1987
- "openssl-probe",
1988
- "rustls-pemfile",
1989
- "schannel",
1990
- "security-framework",
1991
- ]
1992
-
1993
1879
  [[package]]
1994
1880
  name = "rustls-pemfile"
1995
1881
  version = "1.0.2"
@@ -2005,15 +1891,6 @@ version = "1.0.12"
2005
1891
  source = "registry+https://github.com/rust-lang/crates.io-index"
2006
1892
  checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
2007
1893
 
2008
- [[package]]
2009
- name = "schannel"
2010
- version = "0.1.21"
2011
- source = "registry+https://github.com/rust-lang/crates.io-index"
2012
- checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3"
2013
- dependencies = [
2014
- "windows-sys 0.42.0",
2015
- ]
2016
-
2017
1894
  [[package]]
2018
1895
  name = "scopeguard"
2019
1896
  version = "1.1.0"
@@ -2056,29 +1933,6 @@ dependencies = [
2056
1933
  "untrusted",
2057
1934
  ]
2058
1935
 
2059
- [[package]]
2060
- name = "security-framework"
2061
- version = "2.8.2"
2062
- source = "registry+https://github.com/rust-lang/crates.io-index"
2063
- checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254"
2064
- dependencies = [
2065
- "bitflags",
2066
- "core-foundation",
2067
- "core-foundation-sys",
2068
- "libc",
2069
- "security-framework-sys",
2070
- ]
2071
-
2072
- [[package]]
2073
- name = "security-framework-sys"
2074
- version = "2.8.0"
2075
- source = "registry+https://github.com/rust-lang/crates.io-index"
2076
- checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4"
2077
- dependencies = [
2078
- "core-foundation-sys",
2079
- "libc",
2080
- ]
2081
-
2082
1936
  [[package]]
2083
1937
  name = "semver"
2084
1938
  version = "1.0.16"
@@ -2359,16 +2213,6 @@ dependencies = [
2359
2213
  "windows-sys 0.42.0",
2360
2214
  ]
2361
2215
 
2362
- [[package]]
2363
- name = "tokio-native-tls"
2364
- version = "0.3.1"
2365
- source = "registry+https://github.com/rust-lang/crates.io-index"
2366
- checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
2367
- dependencies = [
2368
- "native-tls",
2369
- "tokio",
2370
- ]
2371
-
2372
2216
  [[package]]
2373
2217
  name = "tokio-rustls"
2374
2218
  version = "0.23.4"
@@ -2485,12 +2329,6 @@ dependencies = [
2485
2329
  "percent-encoding",
2486
2330
  ]
2487
2331
 
2488
- [[package]]
2489
- name = "vcpkg"
2490
- version = "0.2.15"
2491
- source = "registry+https://github.com/rust-lang/crates.io-index"
2492
- checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
2493
-
2494
2332
  [[package]]
2495
2333
  name = "vec_map"
2496
2334
  version = "0.8.2"
@@ -2623,6 +2461,15 @@ dependencies = [
2623
2461
  "untrusted",
2624
2462
  ]
2625
2463
 
2464
+ [[package]]
2465
+ name = "webpki-roots"
2466
+ version = "0.22.6"
2467
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2468
+ checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
2469
+ dependencies = [
2470
+ "webpki",
2471
+ ]
2472
+
2626
2473
  [[package]]
2627
2474
  name = "which"
2628
2475
  version = "4.4.0"
data/ext/rbspy/Cargo.toml CHANGED
@@ -14,6 +14,7 @@ pyroscope_rbspy = { path = "../../../../pyroscope_backends/pyroscope_rbspy" }
14
14
  ffikit = { path = "../../../ffikit" }
15
15
  pretty_env_logger = "0.4.0"
16
16
  inferno = "=0.11.14"
17
+ log = "0.4"
17
18
 
18
19
  [build-dependencies]
19
20
  cbindgen = "0.20.0"
data/ext/rbspy/src/lib.rs CHANGED
@@ -8,10 +8,14 @@ use std::str::FromStr;
8
8
  use ffikit::Signal;
9
9
  use pyroscope_rbspy::{rbspy_backend, RbspyConfig};
10
10
 
11
+ use pyroscope;
11
12
  use pyroscope::{pyroscope::Compression, PyroscopeAgent};
12
13
  use pyroscope::backend::{Report, StackFrame, Tag};
13
14
  use pyroscope::pyroscope::ReportEncoding;
14
15
 
16
+ const LOG_TAG: &str = "Pyroscope::rbspy::ffi";
17
+
18
+
15
19
  pub fn transform_report(report: Report) -> Report {
16
20
  let cwd = env::current_dir().unwrap();
17
21
  let cwd = cwd.to_str().unwrap_or("");
@@ -106,10 +110,21 @@ pub extern "C" fn initialize_logging(logging_level: u32) -> bool {
106
110
 
107
111
  #[no_mangle]
108
112
  pub extern "C" fn initialize_agent(
109
- application_name: *const c_char, server_address: *const c_char, auth_token: *const c_char,
110
- sample_rate: u32, detect_subprocesses: bool, oncpu: bool, report_pid: bool,
111
- report_thread_id: bool, tags: *const c_char, compression: *const c_char,
112
- report_encoding: *const c_char
113
+ application_name: *const c_char,
114
+ server_address: *const c_char,
115
+ auth_token: *const c_char,
116
+ basic_auth_user: *const c_char,
117
+ basic_auth_password: *const c_char,
118
+ sample_rate: u32,
119
+ detect_subprocesses: bool,
120
+ oncpu: bool,
121
+ report_pid: bool,
122
+ report_thread_id: bool,
123
+ tags: *const c_char,
124
+ compression: *const c_char,
125
+ report_encoding: *const c_char,
126
+ scope_org_id: *const c_char,
127
+ http_headers_json: *const c_char,
113
128
  ) -> bool {
114
129
  // Initialize FFIKit
115
130
  let recv = ffikit::initialize_ffi().unwrap();
@@ -129,6 +144,16 @@ pub extern "C" fn initialize_agent(
129
144
  .unwrap()
130
145
  .to_string();
131
146
 
147
+ let basic_auth_user = unsafe { CStr::from_ptr(basic_auth_user) }
148
+ .to_str()
149
+ .unwrap()
150
+ .to_string();
151
+
152
+ let basic_auth_password = unsafe { CStr::from_ptr(basic_auth_password) }
153
+ .to_str()
154
+ .unwrap()
155
+ .to_string();
156
+
132
157
  let tags_string = unsafe { CStr::from_ptr(tags) }
133
158
  .to_str()
134
159
  .unwrap()
@@ -144,6 +169,16 @@ pub extern "C" fn initialize_agent(
144
169
  .unwrap()
145
170
  .to_string();
146
171
 
172
+ let scope_org_id = unsafe { CStr::from_ptr(scope_org_id) }
173
+ .to_str()
174
+ .unwrap()
175
+ .to_string();
176
+
177
+ let http_headers_json = unsafe { CStr::from_ptr(http_headers_json) }
178
+ .to_str()
179
+ .unwrap()
180
+ .to_string();
181
+
147
182
  let compression = Compression::from_str(&compression_string);
148
183
  let report_encoding = ReportEncoding::from_str(&report_encoding)
149
184
  .unwrap_or(ReportEncoding::FOLDED);
@@ -170,6 +205,30 @@ pub extern "C" fn initialize_agent(
170
205
 
171
206
  if auth_token != "" {
172
207
  agent_builder = agent_builder.auth_token(auth_token);
208
+ } else if basic_auth_user != "" && basic_auth_password != "" {
209
+ agent_builder = agent_builder.basic_auth(basic_auth_user, basic_auth_password);
210
+ }
211
+
212
+ if scope_org_id != "" {
213
+ agent_builder = agent_builder.scope_org_id(scope_org_id);
214
+ }
215
+
216
+ let http_headers = pyroscope::pyroscope::parse_http_headers_json(http_headers_json);
217
+ match http_headers {
218
+ Ok(http_headers) => {
219
+ agent_builder = agent_builder.http_headers(http_headers);
220
+ }
221
+ Err(e) => {
222
+ match e {
223
+ pyroscope::PyroscopeError::Json(e) => {
224
+ log::error!(target: LOG_TAG, "parse_http_headers_json error {}", e);
225
+ }
226
+ pyroscope::PyroscopeError::AdHoc(e) => {
227
+ log::error!(target: LOG_TAG, "parse_http_headers_json {}", e);
228
+ }
229
+ _ => {}
230
+ }
231
+ }
173
232
  }
174
233
 
175
234
  if let Ok(compression) = compression {
@@ -1,3 +1,3 @@
1
1
  module Pyroscope
2
- VERSION = '0.5.2'.freeze
2
+ VERSION = '0.5.6'.freeze
3
3
  end
data/lib/pyroscope.rb CHANGED
@@ -2,13 +2,14 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'ffi'
5
+ require 'json'
5
6
 
6
7
  module Pyroscope
7
8
  module Rust
8
9
  extend FFI::Library
9
10
  ffi_lib File.expand_path(File.dirname(__FILE__)) + "/rbspy/rbspy.#{RbConfig::CONFIG["DLEXT"]}"
10
11
  attach_function :initialize_logging, [:int], :bool
11
- attach_function :initialize_agent, [:string, :string, :string, :int, :bool, :bool, :bool, :bool, :string, :string, :string], :bool
12
+ attach_function :initialize_agent, [:string, :string, :string, :string, :string, :int, :bool, :bool, :bool, :bool, :string, :string, :string, :string, :string], :bool
12
13
  attach_function :add_thread_tag, [:uint64, :string, :string], :bool
13
14
  attach_function :remove_thread_tag, [:uint64, :string, :string], :bool
14
15
  attach_function :add_global_tag, [:string, :string], :bool
@@ -37,6 +38,8 @@ module Pyroscope
37
38
  :app_name,
38
39
  :server_address,
39
40
  :auth_token,
41
+ :basic_auth_username,
42
+ :basic_auth_password,
40
43
  :log_level,
41
44
  :sample_rate,
42
45
  :detect_subprocesses,
@@ -47,6 +50,8 @@ module Pyroscope
47
50
  :compression,
48
51
  :report_encoding,
49
52
  :autoinstrument_rails,
53
+ :scope_org_id,
54
+ :http_headers,
50
55
  ) do
51
56
  def initialize(*)
52
57
  super
@@ -54,6 +59,8 @@ module Pyroscope
54
59
  self.application_name = ''
55
60
  self.server_address = 'http://localhost:4040'
56
61
  self.auth_token = ''
62
+ self.basic_auth_username = ''
63
+ self.basic_auth_password = ''
57
64
  self.sample_rate = 100
58
65
  self.detect_subprocesses = false
59
66
  self.oncpu = true
@@ -64,6 +71,8 @@ module Pyroscope
64
71
  self.compression = 'gzip'
65
72
  self.report_encoding = 'pprof'
66
73
  self.autoinstrument_rails = true
74
+ self.scope_org_id = ''
75
+ self.http_headers = {}
67
76
  end
68
77
  end
69
78
 
@@ -101,6 +110,8 @@ module Pyroscope
101
110
  @config.app_name || @config.application_name || "",
102
111
  @config.server_address || "",
103
112
  @config.auth_token || "",
113
+ @config.basic_auth_username || "",
114
+ @config.basic_auth_password || "",
104
115
  @config.sample_rate || 100,
105
116
  @config.detect_subprocesses || false,
106
117
  @config.oncpu || false,
@@ -108,7 +119,9 @@ module Pyroscope
108
119
  @config.report_thread_id || false,
109
120
  tags_to_string(@config.tags || {}),
110
121
  @config.compression || "",
111
- @config.report_encoding || "pprof"
122
+ @config.report_encoding || "pprof",
123
+ @config.scope_org_id || "",
124
+ http_headers_to_json(@config.http_headers || {})
112
125
  )
113
126
  end
114
127
 
@@ -170,5 +183,10 @@ module Pyroscope
170
183
  def tags_to_string(tags)
171
184
  tags.map { |k, v| "#{k}=#{v}" }.join(',')
172
185
  end
186
+
187
+ def http_headers_to_json(http_headers)
188
+ JSON.dump(http_headers)
189
+ end
190
+
173
191
  end
174
192
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pyroscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pyroscope Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-21 00:00:00.000000000 Z
11
+ date: 2023-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi