diff options
| author | Hazel Atkinson <yellowsink@riseup.net> | 2025-04-11 15:42:18 +0100 |
|---|---|---|
| committer | Hazel Atkinson <yellowsink@riseup.net> | 2025-04-11 15:42:18 +0100 |
| commit | 1639ee0c63380d7a1fc8dd0c418dcf678a966d38 (patch) | |
| tree | 734dc42a4e9c59f5d269d97f3d9ae08aef3386f4 | |
| parent | 9d50644328b1ccee3d9ce197bb1af250e9a86763 (diff) | |
| download | containerspy-1639ee0c63380d7a1fc8dd0c418dcf678a966d38.tar.gz containerspy-1639ee0c63380d7a1fc8dd0c418dcf678a966d38.tar.bz2 containerspy-1639ee0c63380d7a1fc8dd0c418dcf678a966d38.zip | |
fix memory leak
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | src/stats_task.rs | 7 |
3 files changed, 3 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index da99fd1..300eee9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # pending - use structured (json or syslog) logging to integrate nicely with log aggregation systems like Loki - fix exit signal in docker container + - fix memory leak # v0.1.1-beta - Hello, World!
\ No newline at end of file @@ -139,9 +139,6 @@ the chosen protocol (`http://localhost:4318` for HTTP, `http://localhost:4317` f [here](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md) and [here](https://github.com/open-telemetry/opentelemetry-rust/blob/bc82d4f6/opentelemetry-otlp/src/exporter/mod.rs#L60)). -Note: to send directly to Prometheus (with `--enable-feature=otlp-write-receiver`), use -http://localhost:9090/api/v1/otlp/v1/metrics as your endpoint, swapping `localhost:9090` for your Prometheus `host:port`. - ## Exporting to [Prometheus](https://prometheus.io/) First, enable Prometheus' OTLP write receiver by starting it with the `--enable-feature=otlp-write-receiver` flag. diff --git a/src/stats_task.rs b/src/stats_task.rs index 4434f08..8eb40e8 100644 --- a/src/stats_task.rs +++ b/src/stats_task.rs @@ -2,7 +2,7 @@ use bollard::container::{BlkioStatsEntry, MemoryStatsStats, Stats, StatsOptions} use bollard::models::ContainerSummary; use bollard::Docker; use opentelemetry::metrics::MeterProvider; -use opentelemetry::KeyValue; +use opentelemetry::{InstrumentationScope, KeyValue}; use opentelemetry_sdk::metrics::SdkMeterProvider; use std::mem::MaybeUninit; use std::sync::Arc; @@ -28,9 +28,6 @@ pub fn launch_stats_task( .map(|n| n.trim_start_matches("/").to_owned()); let meter_name = "cspy_".to_string() + container_id.as_str(); - // lol 'static moment - // TODO: this is acceptable for specifically the use case of the michiru deployment, but not more generally at all - let meter_name = &*Box::leak(meter_name.into_boxed_str()); let mut stats_stream = docker.stats( container_id.as_str(), @@ -121,7 +118,7 @@ pub fn launch_stats_task( //println!("Starting reporting for container: {shared_labels:?}"); // create meters - let meter = meter_provider.meter(meter_name); + let meter = meter_provider.meter_with_scope(InstrumentationScope::builder(meter_name).build()); let meter_container_cpu_usage_seconds_total = meter .f64_counter("container_cpu_usage_seconds_total") |
