Skip to content

Commit ddc5d13

Browse files
authored
Merge pull request #32 from pyroscope-io/0.5.3
0.5.3
2 parents 83b0bb2 + eaff8c0 commit ddc5d13

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+875
-2513
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!--
2+
Thanks for helping out!
3+
4+
Please link the appropriate issue from your PR.
5+
6+
If you don't have an issue, we'd recommend starting with one first so the PR can focus on the
7+
implementation (unless its an obvious bug or documentation fix that will have
8+
little conversation).
9+
-->

.github/dependabot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: cargo
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
time: "07:00"
8+
open-pull-requests-limit: 10
9+
labels:
10+
- C-dependencies
11+
- package-ecosystem: "github-actions"
12+
directory: "/"
13+
schedule:
14+
interval: weekly
15+
open-pull-requests-limit: 10
16+
labels:
17+
- "C-dependencies"

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# v0.5.3
2+
## New features
3+
- Add BackendConfig to make reporting of pid, thread_id and thread_name
4+
optional.
5+
- Backends can add a suffix to the "application_name"
6+
7+
## Bug Fixes
8+
- **main**: fixed an obsecure bug when counting stacktraces ([Abid Omar](https://github.com/pyroscope-io/pyroscope-rs/commit/bdecaa13aeae3ce7d4c3d97f88bdd104ec35e7c5))
9+
110
# v0.5.2
211
## New features
312
- Authentication Token support

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Contributing to Pyroscope
2+
3+
Thank you for your interest in contributing to Pyroscope! We welcome all people who want to contribute in a healthy and constructive manner within our community. To help us create a safe and positive community experience for all, we require all participants to adhere to the [Code of Conduct](CODE_OF_CONDUCT.md).
4+
5+
This document is a guide to help you through the process of contributing to Pyroscope.
6+
7+
## Where do I start
8+
9+
* Set up your [development environment](https://pyroscope.io/docs/developer-guide).
10+
* Read the [style guides](https://pyroscope.io/docs/style-guide) we use.
11+
* Check out the list of [good first issues](https://github.com/pyroscope-io/pyroscope/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Pyroscope Profiler Agent for continuous profiling of Rust, Python and Ruby appli
55
"""
66
keywords = ["pyroscope", "profiler", "profiling", "pprof"]
77
authors = ["Abid Omar <[email protected]>"]
8-
version = "0.5.2"
8+
version = "0.5.3"
99
edition = "2021"
1010
license = "Apache-2.0"
1111
homepage = "https://pyroscope.io/docs/rust"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Add this to your `Cargo.toml`:
3232

3333
```toml
3434
[dependencies]
35-
pyroscope = "0.5.2"
35+
pyroscope = "0.5.3"
3636
pyroscope_pprofrs = "0.2"
3737
```
3838

examples/multi-thread-report.rs

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
extern crate pyroscope;
2+
3+
use pyroscope::{PyroscopeAgent, Result};
4+
use pyroscope_pprofrs::{pprof_backend, PprofConfig};
5+
use std::{
6+
collections::hash_map::DefaultHasher,
7+
hash::{Hash, Hasher},
8+
thread,
9+
};
10+
11+
fn hash_rounds1(n: u64) -> u64 {
12+
let hash_str = "Some string to hash";
13+
let mut default_hasher = DefaultHasher::new();
14+
15+
for _ in 0..n {
16+
for _ in 0..1000 {
17+
default_hasher.write(hash_str.as_bytes());
18+
}
19+
hash_str.hash(&mut default_hasher);
20+
}
21+
22+
n
23+
}
24+
25+
fn hash_rounds2(n: u64) -> u64 {
26+
let hash_str = "Some string to hash";
27+
let mut default_hasher = DefaultHasher::new();
28+
29+
for _ in 0..n {
30+
for _ in 0..1000 {
31+
default_hasher.write(hash_str.as_bytes());
32+
}
33+
hash_str.hash(&mut default_hasher);
34+
}
35+
36+
n
37+
}
38+
39+
fn extra_rounds1(n: u64) -> u64 {
40+
let hash_str = "Some string to hash";
41+
let mut default_hasher = DefaultHasher::new();
42+
43+
for _ in 0..n {
44+
for _ in 0..1000 {
45+
default_hasher.write(hash_str.as_bytes());
46+
}
47+
hash_str.hash(&mut default_hasher);
48+
}
49+
50+
n
51+
}
52+
53+
fn extra_rounds2(n: u64) -> u64 {
54+
let hash_str = "Some string to hash";
55+
let mut default_hasher = DefaultHasher::new();
56+
57+
for _ in 0..n {
58+
for _ in 0..1000 {
59+
default_hasher.write(hash_str.as_bytes());
60+
}
61+
hash_str.hash(&mut default_hasher);
62+
}
63+
64+
n
65+
}
66+
67+
fn main() -> Result<()> {
68+
let agent = PyroscopeAgent::builder("http://localhost:4040", "example.multithread.report")
69+
.tags([("Host", "Rust")].to_vec())
70+
.backend(pprof_backend(
71+
PprofConfig::new()
72+
.sample_rate(100)
73+
.report_thread_id()
74+
.report_thread_name(),
75+
))
76+
.build()?;
77+
78+
// Show start time
79+
let start = std::time::SystemTime::now()
80+
.duration_since(std::time::UNIX_EPOCH)
81+
.unwrap()
82+
.as_secs();
83+
println!("Start Time: {}", start);
84+
85+
// Start Agent
86+
let agent_running = agent.start()?;
87+
88+
let (add_tag, remove_tag) = agent_running.tag_wrapper();
89+
90+
let handle_1 = thread::Builder::new()
91+
.name("thread-1".to_string())
92+
.spawn(move || {
93+
hash_rounds1(300_000);
94+
add_tag("extra".to_string(), "round-1".to_string()).unwrap();
95+
extra_rounds1(200_000);
96+
remove_tag("extra".to_string(), "round-1".to_string()).unwrap();
97+
})?;
98+
99+
let (add_tag, remove_tag) = agent_running.tag_wrapper();
100+
101+
let handle_2 = thread::Builder::new()
102+
.name("thread-2".to_string())
103+
.spawn(move || {
104+
add_tag("extra".to_string(), "round-2".to_string()).unwrap();
105+
extra_rounds2(100_000);
106+
remove_tag("extra".to_string(), "round-2".to_string()).unwrap();
107+
hash_rounds2(500_000);
108+
})?;
109+
110+
// Wait for the threads to complete
111+
handle_1.join().unwrap();
112+
handle_2.join().unwrap();
113+
114+
// Stop Agent
115+
let agent_ready = agent_running.stop()?;
116+
117+
// Shutdown the Agent
118+
agent_ready.shutdown();
119+
120+
// Show program exit time
121+
let exit = std::time::SystemTime::now()
122+
.duration_since(std::time::UNIX_EPOCH)
123+
.unwrap()
124+
.as_secs();
125+
println!("Exit Time: {}", exit);
126+
127+
Ok(())
128+
}

pyroscope_backends/pyroscope_pprofrs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ readme = "README.md"
1515

1616

1717
[dependencies]
18-
pprof = "0.9.1"
18+
pprof = "0.10.0"
1919
pyroscope = {version = "0.5.2", path = "../../" }
2020
thiserror ="1.0"
2121

0 commit comments

Comments
 (0)