From be0e1f6416a9947bbf7ff882a50cf898d2f402ed Mon Sep 17 00:00:00 2001 From: Weiwei Lin Date: Sun, 24 Jul 2022 05:11:17 +1000 Subject: [PATCH] [stackdriver] add MonitoredResource::CloudRunRevision (#847) --- opentelemetry-stackdriver/src/lib.rs | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/opentelemetry-stackdriver/src/lib.rs b/opentelemetry-stackdriver/src/lib.rs index d324714f80..af1a13f19b 100644 --- a/opentelemetry-stackdriver/src/lib.rs +++ b/opentelemetry-stackdriver/src/lib.rs @@ -565,6 +565,32 @@ impl From for InternalLogContext { fn from(cx: LogContext) -> Self { let mut labels = HashMap::default(); let resource = match cx.resource { + MonitoredResource::CloudRunRevision { + project_id, + service_name, + revision_name, + location, + configuration_name, + } => { + labels.insert("project_id".to_string(), project_id); + if let Some(service_name) = service_name { + labels.insert("service_name".to_string(), service_name); + } + if let Some(revision_name) = revision_name { + labels.insert("revision_name".to_string(), revision_name); + } + if let Some(location) = location { + labels.insert("location".to_string(), location); + } + if let Some(configuration_name) = configuration_name { + labels.insert("configuration_name".to_string(), configuration_name); + } + + proto::api::MonitoredResource { + r#type: "cloud_run_revision".to_owned(), + labels, + } + } MonitoredResource::GenericNode { project_id, location, @@ -651,6 +677,13 @@ pub enum MonitoredResource { job: Option, task_id: Option, }, + CloudRunRevision { + project_id: String, + service_name: Option, + revision_name: Option, + location: Option, + configuration_name: Option, + }, } impl From for Attributes {