Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libdd-profiling/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixed

- reduce OOM edges in `ProfileExporter::build`

### Changed
- Updated `prost` dependency from 0.13.5 to 0.14.1

Expand Down
25 changes: 17 additions & 8 deletions libdd-profiling/src/exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ impl ProfileExporter {
let mut tags_profiler = String::new();
let other_tags = additional_tags.into_iter();
for tag in self.tags.iter().chain(other_tags).flatten() {
tags_profiler.push_str(tag.as_ref());
let t = tag.as_ref();
tags_profiler.try_reserve(t.len() + ','.len_utf8())?;
tags_profiler.push_str(t);
tags_profiler.push(',');
}

Expand Down Expand Up @@ -245,23 +247,30 @@ impl ProfileExporter {
("aas.site.type", aas_metadata.get_site_type()),
("aas.subscription.id", aas_metadata.get_subscription_id()),
];
aas_tags.into_iter().for_each(|(name, value)| {
for (name, value) in aas_tags {
if let Ok(tag) = Tag::new(name, value) {
tags_profiler.push_str(tag.as_ref());
let t = tag.as_ref();
tags_profiler.try_reserve(t.len() + ','.len_utf8())?;
tags_profiler.push_str(t);
tags_profiler.push(',');
}
});
}
}

// Since this is the last tag, we add it without a comma afterward. If
// any tags get added after this one, you'll need to add the comma
// between them.
tags_profiler.push_str(self.runtime_platform_tag().as_ref());
{
let t = self.runtime_platform_tag();
// Using try_reserve_exact since this is the last tag.
tags_profiler.try_reserve_exact(t.as_ref().len())?;
tags_profiler.push_str(t.as_ref());
}

let attachments: Vec<String> = files_to_compress_and_export
let attachments: Vec<&str> = files_to_compress_and_export
.iter()
.map(|file| file.name.to_owned())
.chain(iter::once("profile.pprof".to_string()))
.map(|file| file.name)
.chain(iter::once("profile.pprof"))
.collect();

let endpoint_counts = if profile.endpoints_stats.is_empty() {
Expand Down
Loading