Skip to content

Commit

Permalink
Add cloud_run_job to MonitoredResource (open-telemetry#101)
Browse files Browse the repository at this point in the history
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
  • Loading branch information
fiadliel and lalitb committed Aug 29, 2024
1 parent e6feb3c commit 8b10ca3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions opentelemetry-stackdriver/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## vNext

### Added

- Added support for `MonitoredResource::CloudRunJob` [#100](https://github.com/open-telemetry/opentelemetry-rust-contrib/issues/100)

## v0.21.0

### Changed
Expand Down
23 changes: 23 additions & 0 deletions opentelemetry-stackdriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,24 @@ impl From<LogContext> for InternalLogContext {
fn from(cx: LogContext) -> Self {
let mut labels = HashMap::default();
let resource = match cx.resource {
MonitoredResource::CloudRunJob {
project_id,
job_name,
location,
} => {
labels.insert("project_id".to_string(), project_id);
if let Some(job_name) = job_name {
labels.insert("job_name".to_string(), job_name);
}
if let Some(location) = location {
labels.insert("location".to_string(), location);
}

proto::api::MonitoredResource {
r#type: "cloud_run_job".to_owned(),
labels,
}
}
MonitoredResource::CloudRunRevision {
project_id,
service_name,
Expand Down Expand Up @@ -665,6 +683,11 @@ pub enum MonitoredResource {
job: Option<String>,
task_id: Option<String>,
},
CloudRunJob {
project_id: String,
job_name: Option<String>,
location: Option<String>,
},
CloudRunRevision {
project_id: String,
service_name: Option<String>,
Expand Down

0 comments on commit 8b10ca3

Please sign in to comment.