Skip to content

Commit 5170373

Browse files
committed
refactor(tags): change tags parameter type to Vec
1 parent 9f53527 commit 5170373

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

examples/async.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn hash_rounds2(n: u64) -> u64 {
3636
async fn main() -> Result<()> {
3737
let mut agent = PyroscopeAgent::builder("http://localhost:4040", "example.async")
3838
.backend(Pprof::new(PprofConfig::new(100)))
39-
.tags(&[("TagA", "ValueA"), ("TagB", "ValueB")])
39+
.tags([("TagA", "ValueA"), ("TagB", "ValueB")].to_vec())
4040
.build()?;
4141

4242
// Start Agent

examples/backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn hash_rounds(n: u64) -> u64 {
2121
fn main() -> Result<()> {
2222
let mut agent = PyroscopeAgent::builder("http://localhost:4040", "example.backend")
2323
.backend(Pprof::new(PprofConfig::new(113)))
24-
.tags(&[("TagA", "ValueA"), ("TagB", "ValueB")])
24+
.tags([("TagA", "ValueA"), ("TagB", "ValueB")].to_vec())
2525
.build()?;
2626

2727
agent.start()?;

examples/basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn hash_rounds(n: u64) -> u64 {
2121
fn main() -> Result<()> {
2222
let mut agent = PyroscopeAgent::builder("http://localhost:4040", "example.basic")
2323
.backend(Pprof::new(PprofConfig::new(100)))
24-
.tags(&[("TagA", "ValueA"), ("TagB", "ValueB")])
24+
.tags([("TagA", "ValueA"), ("TagB", "ValueB")].to_vec())
2525
.build()?;
2626

2727
// Show start time

examples/tags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn hash_rounds(n: u64) -> u64 {
2121
fn main() -> Result<()> {
2222
let mut agent = PyroscopeAgent::builder("http://localhost:4040", "example.tags")
2323
.backend(Pprof::new(PprofConfig::new(100)))
24-
.tags(&[("Hostname", "pyroscope")])
24+
.tags([("Hostname", "pyroscope")].to_vec())
2525
.build()?;
2626

2727
// Start Agent

src/pyroscope.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl PyroscopeConfig {
7979
/// let config = PyroscopeConfig::new("http://localhost:8080", "my-app")
8080
/// .tags(vec![("env", "dev")])?;
8181
/// ```
82-
pub fn tags(self, tags: &[(&str, &str)]) -> Self {
82+
pub fn tags(self, tags: Vec<(&str, &str)>) -> Self {
8383
// Convert &[(&str, &str)] to HashMap(String, String)
8484
let tags_hashmap: HashMap<String, String> = tags
8585
.to_owned()
@@ -156,7 +156,7 @@ impl PyroscopeAgentBuilder {
156156
/// .build()
157157
/// ?;
158158
/// ```
159-
pub fn tags(self, tags: &[(&str, &str)]) -> Self {
159+
pub fn tags(self, tags: Vec<(&str, &str)>) -> Self {
160160
Self {
161161
config: self.config.tags(tags),
162162
..self

tests/agent.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ fn test_config_tags_empty() {
2323

2424
#[test]
2525
fn test_config_tags() {
26-
let config = PyroscopeConfig::new("http://localhost:8080", "myapp").tags(&[("tag", "value")]);
26+
let config =
27+
PyroscopeConfig::new("http://localhost:8080", "myapp").tags([("tag", "value")].to_vec());
2728
assert_eq!(config.tags.len(), 1);
2829
assert_eq!(config.tags.get("tag"), Some(&"value".to_owned()));
2930
}
3031

3132
#[test]
3233
fn test_config_tags_multiple() {
3334
let config = PyroscopeConfig::new("http://localhost:8080", "myapp")
34-
.tags(&[("tag1", "value1"), ("tag2", "value2")]);
35+
.tags([("tag1", "value1"), ("tag2", "value2")].to_vec());
3536
assert_eq!(config.tags.len(), 2);
3637
assert_eq!(config.tags.get("tag1"), Some(&"value1".to_owned()));
3738
assert_eq!(config.tags.get("tag2"), Some(&"value2".to_owned()));

0 commit comments

Comments
 (0)