@@ -551,6 +551,46 @@ impl From<LogContext> for InternalLogContext {
551
551
fn from ( cx : LogContext ) -> Self {
552
552
let mut labels = HashMap :: default ( ) ;
553
553
let resource = match cx. resource {
554
+ MonitoredResource :: AppEngine {
555
+ project_id,
556
+ module_id,
557
+ version_id,
558
+ zone,
559
+ } => {
560
+ labels. insert ( "project_id" . to_string ( ) , project_id) ;
561
+ if let Some ( module_id) = module_id {
562
+ labels. insert ( "module_id" . to_string ( ) , module_id) ;
563
+ }
564
+ if let Some ( version_id) = version_id {
565
+ labels. insert ( "version_id" . to_string ( ) , version_id) ;
566
+ }
567
+ if let Some ( zone) = zone {
568
+ labels. insert ( "zone" . to_string ( ) , zone) ;
569
+ }
570
+
571
+ proto:: api:: MonitoredResource {
572
+ r#type : "gae_app" . to_owned ( ) ,
573
+ labels,
574
+ }
575
+ }
576
+ MonitoredResource :: CloudFunction {
577
+ project_id,
578
+ function_name,
579
+ region,
580
+ } => {
581
+ labels. insert ( "project_id" . to_string ( ) , project_id) ;
582
+ if let Some ( function_name) = function_name {
583
+ labels. insert ( "function_name" . to_string ( ) , function_name) ;
584
+ }
585
+ if let Some ( region) = region {
586
+ labels. insert ( "region" . to_string ( ) , region) ;
587
+ }
588
+
589
+ proto:: api:: MonitoredResource {
590
+ r#type : "cloud_function" . to_owned ( ) ,
591
+ labels,
592
+ }
593
+ }
554
594
MonitoredResource :: CloudRunJob {
555
595
project_id,
556
596
job_name,
@@ -595,6 +635,26 @@ impl From<LogContext> for InternalLogContext {
595
635
labels,
596
636
}
597
637
}
638
+
639
+ MonitoredResource :: ComputeEngine {
640
+ project_id,
641
+ instance_id,
642
+ zone,
643
+ } => {
644
+ labels. insert ( "project_id" . to_string ( ) , project_id) ;
645
+ if let Some ( instance_id) = instance_id {
646
+ labels. insert ( "instance_id" . to_string ( ) , instance_id) ;
647
+ }
648
+ if let Some ( zone) = zone {
649
+ labels. insert ( "zone" . to_string ( ) , zone) ;
650
+ }
651
+
652
+ proto:: api:: MonitoredResource {
653
+ r#type : "gce_instance" . to_owned ( ) ,
654
+ labels,
655
+ }
656
+ }
657
+
598
658
MonitoredResource :: GenericNode {
599
659
project_id,
600
660
location,
@@ -650,6 +710,36 @@ impl From<LogContext> for InternalLogContext {
650
710
labels,
651
711
}
652
712
}
713
+ MonitoredResource :: KubernetesEngine {
714
+ project_id,
715
+ cluster_name,
716
+ location,
717
+ pod_name,
718
+ namespace_name,
719
+ container_name,
720
+ } => {
721
+ labels. insert ( "project_id" . to_string ( ) , project_id) ;
722
+ if let Some ( cluster_name) = cluster_name {
723
+ labels. insert ( "cluster_name" . to_string ( ) , cluster_name) ;
724
+ }
725
+ if let Some ( location) = location {
726
+ labels. insert ( "location" . to_string ( ) , location) ;
727
+ }
728
+ if let Some ( pod_name) = pod_name {
729
+ labels. insert ( "pod_name" . to_string ( ) , pod_name) ;
730
+ }
731
+ if let Some ( namespace_name) = namespace_name {
732
+ labels. insert ( "namespace_name" . to_string ( ) , namespace_name) ;
733
+ }
734
+ if let Some ( container_name) = container_name {
735
+ labels. insert ( "container_name" . to_string ( ) , container_name) ;
736
+ }
737
+
738
+ proto:: api:: MonitoredResource {
739
+ r#type : "k8s_container" . to_owned ( ) ,
740
+ labels,
741
+ }
742
+ }
653
743
} ;
654
744
655
745
Self {
@@ -665,8 +755,41 @@ impl From<LogContext> for InternalLogContext {
665
755
/// Please submit an issue or pull request if you want to use a resource type not listed here.
666
756
#[ derive( Clone ) ]
667
757
pub enum MonitoredResource {
668
- Global {
758
+ AppEngine {
759
+ project_id : String ,
760
+ module_id : Option < String > ,
761
+ version_id : Option < String > ,
762
+ zone : Option < String > ,
763
+ } ,
764
+ CloudFunction {
765
+ project_id : String ,
766
+ function_name : Option < String > ,
767
+ region : Option < String > ,
768
+ } ,
769
+ CloudRunJob {
770
+ project_id : String ,
771
+ job_name : Option < String > ,
772
+ location : Option < String > ,
773
+ } ,
774
+ CloudRunRevision {
669
775
project_id : String ,
776
+ service_name : Option < String > ,
777
+ revision_name : Option < String > ,
778
+ location : Option < String > ,
779
+ configuration_name : Option < String > ,
780
+ } ,
781
+ ComputeEngine {
782
+ project_id : String ,
783
+ instance_id : Option < String > ,
784
+ zone : Option < String > ,
785
+ } ,
786
+ KubernetesEngine {
787
+ project_id : String ,
788
+ location : Option < String > ,
789
+ cluster_name : Option < String > ,
790
+ namespace_name : Option < String > ,
791
+ pod_name : Option < String > ,
792
+ container_name : Option < String > ,
670
793
} ,
671
794
GenericNode {
672
795
project_id : String ,
@@ -681,17 +804,8 @@ pub enum MonitoredResource {
681
804
job : Option < String > ,
682
805
task_id : Option < String > ,
683
806
} ,
684
- CloudRunJob {
685
- project_id : String ,
686
- job_name : Option < String > ,
687
- location : Option < String > ,
688
- } ,
689
- CloudRunRevision {
807
+ Global {
690
808
project_id : String ,
691
- service_name : Option < String > ,
692
- revision_name : Option < String > ,
693
- location : Option < String > ,
694
- configuration_name : Option < String > ,
695
809
} ,
696
810
}
697
811
0 commit comments