Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: readd http metrics #351

Merged
merged 1 commit into from
Nov 27, 2023
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
3 changes: 1 addition & 2 deletions server/src/metrics/actix_web_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl RequestMetricsBuilder {
/// construct meters for this crate
fn get_versioned_meter(meter_provider: impl MeterProvider) -> Meter {
meter_provider.versioned_meter(
"actix_web_opentelemetry",
"unleash_edge",
Some(env!("CARGO_PKG_VERSION")),
Some(opentelemetry_semantic_conventions::SCHEMA_URL),
None,
Expand Down Expand Up @@ -384,7 +384,6 @@ where
timer.elapsed().map(|t| t.as_secs_f64()).unwrap_or_default(),
&attributes,
);

Ok(res)
} else {
res
Expand Down
18 changes: 14 additions & 4 deletions server/src/prom_metrics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::cli::LogFormat;
use opentelemetry::global;
use opentelemetry_sdk::metrics::MeterProvider;
use opentelemetry_semantic_conventions::resource::SERVICE_NAME;
#[cfg(target_os = "linux")]
use prometheus::process_collector::ProcessCollector;
use tracing_subscriber::layer::SubscriberExt;
Expand Down Expand Up @@ -47,11 +49,19 @@ fn instantiate_prometheus_metrics_handler(
registry: prometheus::Registry,
) -> (PrometheusMetricsHandler, RequestMetrics) {
let resource = opentelemetry_sdk::Resource::new(vec![
opentelemetry::KeyValue::new("service.name", "unleash-edge"),
opentelemetry::KeyValue::new("edge.version", crate::types::build::PKG_VERSION),
opentelemetry::KeyValue::new("edge.githash", crate::types::build::SHORT_COMMIT),
opentelemetry::KeyValue::new(SERVICE_NAME, "unleash-edge"),
opentelemetry::KeyValue::new("edge_version", crate::types::build::PKG_VERSION),
opentelemetry::KeyValue::new("edge_githash", crate::types::build::SHORT_COMMIT),
]);
let provider = MeterProvider::builder().with_resource(resource).build();
let exporter = opentelemetry_prometheus::exporter()
.with_registry(registry.clone())
.build()
.expect("Failed to setup prometheus");
let provider = MeterProvider::builder()
.with_resource(resource)
.with_reader(exporter)
.build();
global::set_meter_provider(provider.clone());
(
PrometheusMetricsHandler::new(registry),
RequestMetricsBuilder::new()
Expand Down
Loading