policy-rs 1.6.0

Policy library for working with protobuf-defined policy objects
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
// This file is @generated by prost-build.
/// AttributePath specifies how to access an attribute value.
///
/// The path is represented as an array of string segments. Each segment represents
/// a key to traverse into nested maps.
///
/// Example usage:
///
///    For an attribute structure like:
///      Attributes: map\[string\]any{
///          "http": map\[string\]any{
///              "method":      "POST",
///              "status_code": 200,
///          },
///          "user_id": "u123",
///      }
///
///    - To access "user_id": \["user_id"\]
///    - To access http.method: \["http", "method"\]
///
/// YAML/JSON Unmarshaling:
///
/// Implementations MUST accept both the canonical proto form and shorthand forms
/// for ergonomic policy authoring:
///
///    Canonical (proto-native):
///      log_attribute:
///        path: \["http", "method"\]
///
///    Shorthand array (MUST be supported):
///      log_attribute: \["http", "method"\]
///
///    Shorthand string (MUST be supported for single-segment paths):
///      log_attribute: "user_id"           # equivalent to \["user_id"\]
///
/// When marshaling, implementations SHOULD use the shorthand array form for
/// cleaner output.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AttributePath {
    /// Path segments for attribute traversal.
    /// A single-element array accesses a flat attribute.
    /// Multiple elements traverse nested maps.
    #[prost(string, repeated, tag = "1")]
    pub path: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// LogTarget defines matching and actions for logs.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogTarget {
    /// Matchers to identify which logs this policy applies to (AND logic).
    /// Implementations MUST reject policies with an empty match list.
    #[prost(message, repeated, tag = "1")]
    pub r#match: ::prost::alloc::vec::Vec<LogMatcher>,
    /// The keep field controls whether matching telemetry survives. It unifies
    /// dropping, sampling, and rate limiting into a single concept: what percentage
    /// or amount of matching telemetry continues to the next stage?
    ///
    /// Valid values:
    ///    "all"  - Keep everything (default, can be omitted)
    ///    "none" - Drop everything
    ///    "N%"   - Keep N percent (0-100), e.g. "50%"
    ///    "N/s"  - Keep at most N per second (shorthand for "N/1s"), e.g. "100/s"
    ///    "N/m"  - Keep at most N per minute (shorthand for "N/1m"), e.g. "1000/m"
    ///    "N/Ds" - Keep at most N per D-second window, e.g. "1/5s"
    ///    "N/Dm" - Keep at most N per D-minute window, e.g. "1/5m"
    ///
    /// For rate limiting, both N and D must be positive integers. Fractional
    /// values are invalid and should be rejected by implementations.
    #[prost(string, tag = "2")]
    pub keep: ::prost::alloc::string::String,
    /// Transform operations to apply
    #[prost(message, optional, tag = "3")]
    pub transform: ::core::option::Option<LogTransform>,
    /// Field to use as the sampling key for consistent sampling.
    /// When set, all logs with the same value for this field get the same
    /// keep/drop decision. Use for lifecycle events (request_id, trace_id, job_id)
    /// to avoid sampling individual log lines independently.
    ///
    /// Only applies when keep is a sampling value (N%, N/s, N/m, N/Ds, N/Dm).
    /// Example: sample_key = log_attribute\["request_id"\] with keep = "10%" means
    /// 10% of requests are kept, with all logs from each kept request preserved.
    #[prost(message, optional, tag = "4")]
    pub sample_key: ::core::option::Option<LogSampleKey>,
}
/// LogSampleKey specifies which field to use as the sampling key for consistent
/// sampling decisions.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogSampleKey {
    /// FIELD SELECTION (subset of LogMatcher fields appropriate for sampling keys)
    /// The field to use as the sampling key. Exactly one must be set.
    #[prost(oneof = "log_sample_key::Field", tags = "1, 2, 3, 4")]
    pub field: ::core::option::Option<log_sample_key::Field>,
}
/// Nested message and enum types in `LogSampleKey`.
pub mod log_sample_key {
    /// FIELD SELECTION (subset of LogMatcher fields appropriate for sampling keys)
    /// The field to use as the sampling key. Exactly one must be set.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Field {
        /// Simple fields (trace_id, span_id, etc.)
        #[prost(enumeration = "super::LogField", tag = "1")]
        LogField(i32),
        /// Log record attribute by key or path
        #[prost(message, tag = "2")]
        LogAttribute(super::AttributePath),
        /// Resource attribute by key or path
        #[prost(message, tag = "3")]
        ResourceAttribute(super::AttributePath),
        /// Scope attribute by key or path
        #[prost(message, tag = "4")]
        ScopeAttribute(super::AttributePath),
    }
}
/// LogMatcher provides a way to match against log telemetry data using known fields.
///
/// IMPORTANT CONSTRAINTS:
/// - Multiple matchers are ANDed together: all matchers must match for the
///    overall match to succeed.
/// - The list of matchers should uniquely identify a specific pattern of telemetry
///    for that policy. Matchers should NOT be used as a catch-all; they should be
///    specific enough to target the intended telemetry precisely.
///
/// All regex fields use RE2 syntax for consistency across implementations.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogMatcher {
    /// If true, inverts the match result
    #[prost(bool, tag = "20")]
    pub negate: bool,
    /// If true, applies case-insensitive matching to all match types
    #[prost(bool, tag = "21")]
    pub case_insensitive: bool,
    /// FIELD SELECTION (keep in sync with LogRedact, LogRename, LogAdd, LogRemove)
    /// The field to match against. Exactly one must be set.
    #[prost(oneof = "log_matcher::Field", tags = "1, 2, 3, 4")]
    pub field: ::core::option::Option<log_matcher::Field>,
    /// Match type. Exactly one must be set.
    #[prost(oneof = "log_matcher::Match", tags = "10, 11, 12, 13, 14, 15")]
    pub r#match: ::core::option::Option<log_matcher::Match>,
}
/// Nested message and enum types in `LogMatcher`.
pub mod log_matcher {
    /// FIELD SELECTION (keep in sync with LogRedact, LogRename, LogAdd, LogRemove)
    /// The field to match against. Exactly one must be set.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Field {
        /// Simple fields (body, severity_text, trace_id, span_id, etc.)
        #[prost(enumeration = "super::LogField", tag = "1")]
        LogField(i32),
        /// Log record attribute by key or path
        #[prost(message, tag = "2")]
        LogAttribute(super::AttributePath),
        /// Resource attribute by key or path
        #[prost(message, tag = "3")]
        ResourceAttribute(super::AttributePath),
        /// Scope attribute by key or path
        #[prost(message, tag = "4")]
        ScopeAttribute(super::AttributePath),
    }
    /// Match type. Exactly one must be set.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Match {
        /// Exact string match
        #[prost(string, tag = "10")]
        Exact(::prost::alloc::string::String),
        /// Regular expression match
        #[prost(string, tag = "11")]
        Regex(::prost::alloc::string::String),
        /// Field existence check
        #[prost(bool, tag = "12")]
        Exists(bool),
        /// Literal prefix match
        #[prost(string, tag = "13")]
        StartsWith(::prost::alloc::string::String),
        /// Literal suffix match
        #[prost(string, tag = "14")]
        EndsWith(::prost::alloc::string::String),
        /// Literal substring match
        #[prost(string, tag = "15")]
        Contains(::prost::alloc::string::String),
    }
}
/// LogTransform defines modifications to logs.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogTransform {
    /// Fields to remove
    #[prost(message, repeated, tag = "1")]
    pub remove: ::prost::alloc::vec::Vec<LogRemove>,
    /// Fields to redact
    #[prost(message, repeated, tag = "2")]
    pub redact: ::prost::alloc::vec::Vec<LogRedact>,
    /// Fields to rename
    #[prost(message, repeated, tag = "3")]
    pub rename: ::prost::alloc::vec::Vec<LogRename>,
    /// Fields to add
    #[prost(message, repeated, tag = "4")]
    pub add: ::prost::alloc::vec::Vec<LogAdd>,
}
/// LogRemove removes a field.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogRemove {
    /// FIELD SELECTION (keep in sync with LogMatcher, LogRedact, LogRename, LogAdd)
    /// The field to remove. Exactly one must be set.
    #[prost(oneof = "log_remove::Field", tags = "1, 2, 3, 4")]
    pub field: ::core::option::Option<log_remove::Field>,
}
/// Nested message and enum types in `LogRemove`.
pub mod log_remove {
    /// FIELD SELECTION (keep in sync with LogMatcher, LogRedact, LogRename, LogAdd)
    /// The field to remove. Exactly one must be set.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Field {
        /// Simple fields (body, severity_text, trace_id, span_id, etc.)
        #[prost(enumeration = "super::LogField", tag = "1")]
        LogField(i32),
        /// Log record attribute by key or path
        #[prost(message, tag = "2")]
        LogAttribute(super::AttributePath),
        /// Resource attribute by key or path
        #[prost(message, tag = "3")]
        ResourceAttribute(super::AttributePath),
        /// Scope attribute by key or path
        #[prost(message, tag = "4")]
        ScopeAttribute(super::AttributePath),
    }
}
/// LogRedact masks a field value.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogRedact {
    /// Replacement value (e.g., "\[REDACTED\]"). When regex is set, this is
    /// interpreted as a replacement template.
    #[prost(string, tag = "10")]
    pub replacement: ::prost::alloc::string::String,
    /// Optional RE2 regular expression for targeted replacement. If unset, the
    /// entire field value is replaced. If set and no match is present, no
    /// modification is applied. If set and a match is present, all non-overlapping
    /// instances of the full regular expression match are replaced. Capture groups
    /// may be referenced from the replacement string, but do not change the
    /// replacement range.
    #[prost(string, optional, tag = "11")]
    pub regex: ::core::option::Option<::prost::alloc::string::String>,
    /// FIELD SELECTION (keep in sync with LogMatcher, LogRemove, LogRename, LogAdd)
    /// The field to redact. Exactly one must be set.
    #[prost(oneof = "log_redact::Field", tags = "1, 2, 3, 4")]
    pub field: ::core::option::Option<log_redact::Field>,
}
/// Nested message and enum types in `LogRedact`.
pub mod log_redact {
    /// FIELD SELECTION (keep in sync with LogMatcher, LogRemove, LogRename, LogAdd)
    /// The field to redact. Exactly one must be set.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Field {
        /// Simple fields (body, severity_text, trace_id, span_id, etc.)
        #[prost(enumeration = "super::LogField", tag = "1")]
        LogField(i32),
        /// Log record attribute by key or path
        #[prost(message, tag = "2")]
        LogAttribute(super::AttributePath),
        /// Resource attribute by key or path
        #[prost(message, tag = "3")]
        ResourceAttribute(super::AttributePath),
        /// Scope attribute by key or path
        #[prost(message, tag = "4")]
        ScopeAttribute(super::AttributePath),
    }
}
/// LogRename changes a field name.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogRename {
    /// The new field name
    #[prost(string, tag = "10")]
    pub to: ::prost::alloc::string::String,
    /// If true, overwrites the target field if it already exists
    #[prost(bool, tag = "11")]
    pub upsert: bool,
    /// FIELD SELECTION (keep in sync with LogMatcher, LogRemove, LogRedact, LogAdd)
    /// The field to rename. Exactly one must be set.
    #[prost(oneof = "log_rename::From", tags = "1, 2, 3, 4")]
    pub from: ::core::option::Option<log_rename::From>,
}
/// Nested message and enum types in `LogRename`.
pub mod log_rename {
    /// FIELD SELECTION (keep in sync with LogMatcher, LogRemove, LogRedact, LogAdd)
    /// The field to rename. Exactly one must be set.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum From {
        /// Simple fields (body, severity_text, trace_id, span_id, etc.)
        #[prost(enumeration = "super::LogField", tag = "1")]
        FromLogField(i32),
        /// Log record attribute by key or path
        #[prost(message, tag = "2")]
        FromLogAttribute(super::AttributePath),
        /// Resource attribute by key or path
        #[prost(message, tag = "3")]
        FromResourceAttribute(super::AttributePath),
        /// Scope attribute by key or path
        #[prost(message, tag = "4")]
        FromScopeAttribute(super::AttributePath),
    }
}
/// LogAdd inserts a field.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogAdd {
    /// The value to set
    #[prost(string, tag = "10")]
    pub value: ::prost::alloc::string::String,
    /// If true, overwrites the field if it already exists
    #[prost(bool, tag = "11")]
    pub upsert: bool,
    /// FIELD SELECTION (keep in sync with LogMatcher, LogRemove, LogRedact, LogRename)
    /// The field to add. Exactly one must be set.
    #[prost(oneof = "log_add::Field", tags = "1, 2, 3, 4")]
    pub field: ::core::option::Option<log_add::Field>,
}
/// Nested message and enum types in `LogAdd`.
pub mod log_add {
    /// FIELD SELECTION (keep in sync with LogMatcher, LogRemove, LogRedact, LogRename)
    /// The field to add. Exactly one must be set.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Field {
        /// Simple fields (body, severity_text, trace_id, span_id, etc.)
        #[prost(enumeration = "super::LogField", tag = "1")]
        LogField(i32),
        /// Log record attribute by key or path
        #[prost(message, tag = "2")]
        LogAttribute(super::AttributePath),
        /// Resource attribute by key or path
        #[prost(message, tag = "3")]
        ResourceAttribute(super::AttributePath),
        /// Scope attribute by key or path
        #[prost(message, tag = "4")]
        ScopeAttribute(super::AttributePath),
    }
}
/// LogField identifies simple log fields (non-keyed).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum LogField {
    Unspecified = 0,
    /// Log record fields
    Body = 1,
    SeverityText = 2,
    TraceId = 3,
    SpanId = 4,
    EventName = 5,
    /// Schema URLs
    ResourceSchemaUrl = 10,
    ScopeSchemaUrl = 11,
}
impl LogField {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "LOG_FIELD_UNSPECIFIED",
            Self::Body => "LOG_FIELD_BODY",
            Self::SeverityText => "LOG_FIELD_SEVERITY_TEXT",
            Self::TraceId => "LOG_FIELD_TRACE_ID",
            Self::SpanId => "LOG_FIELD_SPAN_ID",
            Self::EventName => "LOG_FIELD_EVENT_NAME",
            Self::ResourceSchemaUrl => "LOG_FIELD_RESOURCE_SCHEMA_URL",
            Self::ScopeSchemaUrl => "LOG_FIELD_SCOPE_SCHEMA_URL",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "LOG_FIELD_UNSPECIFIED" => Some(Self::Unspecified),
            "LOG_FIELD_BODY" => Some(Self::Body),
            "LOG_FIELD_SEVERITY_TEXT" => Some(Self::SeverityText),
            "LOG_FIELD_TRACE_ID" => Some(Self::TraceId),
            "LOG_FIELD_SPAN_ID" => Some(Self::SpanId),
            "LOG_FIELD_EVENT_NAME" => Some(Self::EventName),
            "LOG_FIELD_RESOURCE_SCHEMA_URL" => Some(Self::ResourceSchemaUrl),
            "LOG_FIELD_SCOPE_SCHEMA_URL" => Some(Self::ScopeSchemaUrl),
            _ => None,
        }
    }
}
/// MetricTarget defines matching and actions for metrics.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MetricTarget {
    /// Matchers to identify which metrics this policy applies to (AND logic).
    /// Implementations MUST reject policies with an empty match list.
    #[prost(message, repeated, tag = "1")]
    pub r#match: ::prost::alloc::vec::Vec<MetricMatcher>,
    /// Whether to keep matching metrics (true) or drop them (false)
    #[prost(bool, tag = "2")]
    pub keep: bool,
}
/// MetricMatcher provides a way to match against metric telemetry data using known fields.
///
/// IMPORTANT CONSTRAINTS:
/// - Multiple matchers are ANDed together: all matchers must match for the
///    overall match to succeed.
/// - The list of matchers should uniquely identify a specific pattern of telemetry
///    for that policy. Matchers should NOT be used as a catch-all; they should be
///    specific enough to target the intended telemetry precisely.
///
/// All regex fields use RE2 syntax for consistency across implementations.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MetricMatcher {
    /// If true, inverts the match result
    #[prost(bool, tag = "20")]
    pub negate: bool,
    /// If true, applies case-insensitive matching to all match types
    #[prost(bool, tag = "21")]
    pub case_insensitive: bool,
    /// FIELD SELECTION
    /// The field to match against. Exactly one must be set.
    #[prost(oneof = "metric_matcher::Field", tags = "1, 2, 3, 4, 5, 6")]
    pub field: ::core::option::Option<metric_matcher::Field>,
    /// Match type. Exactly one must be set.
    /// Note: For metric_type field, only exists is valid (type equality is implicit).
    #[prost(oneof = "metric_matcher::Match", tags = "10, 11, 12, 13, 14, 15")]
    pub r#match: ::core::option::Option<metric_matcher::Match>,
}
/// Nested message and enum types in `MetricMatcher`.
pub mod metric_matcher {
    /// FIELD SELECTION
    /// The field to match against. Exactly one must be set.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Field {
        /// Simple fields (name, description, unit, etc.)
        #[prost(enumeration = "super::MetricField", tag = "1")]
        MetricField(i32),
        /// Data point attribute by key or path
        #[prost(message, tag = "2")]
        DatapointAttribute(super::AttributePath),
        /// Resource attribute by key or path
        #[prost(message, tag = "3")]
        ResourceAttribute(super::AttributePath),
        /// Scope attribute by key or path
        #[prost(message, tag = "4")]
        ScopeAttribute(super::AttributePath),
        /// Metric type matcher
        #[prost(enumeration = "super::MetricType", tag = "5")]
        MetricType(i32),
        /// Aggregation temporality matcher (applies to Sum, Histogram, ExponentialHistogram)
        #[prost(enumeration = "super::AggregationTemporality", tag = "6")]
        AggregationTemporality(i32),
    }
    /// Match type. Exactly one must be set.
    /// Note: For metric_type field, only exists is valid (type equality is implicit).
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Match {
        /// Exact string match
        #[prost(string, tag = "10")]
        Exact(::prost::alloc::string::String),
        /// Regular expression match
        #[prost(string, tag = "11")]
        Regex(::prost::alloc::string::String),
        /// Field existence check
        #[prost(bool, tag = "12")]
        Exists(bool),
        /// Literal prefix match
        #[prost(string, tag = "13")]
        StartsWith(::prost::alloc::string::String),
        /// Literal suffix match
        #[prost(string, tag = "14")]
        EndsWith(::prost::alloc::string::String),
        /// Literal substring match
        #[prost(string, tag = "15")]
        Contains(::prost::alloc::string::String),
    }
}
/// MetricField identifies simple metric fields (non-keyed).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum MetricField {
    Unspecified = 0,
    /// Metric descriptor fields
    Name = 1,
    Description = 2,
    Unit = 3,
    /// Schema URLs
    ResourceSchemaUrl = 10,
    ScopeSchemaUrl = 11,
    /// Scope fields (InstrumentationScope)
    ScopeName = 12,
    ScopeVersion = 13,
}
impl MetricField {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "METRIC_FIELD_UNSPECIFIED",
            Self::Name => "METRIC_FIELD_NAME",
            Self::Description => "METRIC_FIELD_DESCRIPTION",
            Self::Unit => "METRIC_FIELD_UNIT",
            Self::ResourceSchemaUrl => "METRIC_FIELD_RESOURCE_SCHEMA_URL",
            Self::ScopeSchemaUrl => "METRIC_FIELD_SCOPE_SCHEMA_URL",
            Self::ScopeName => "METRIC_FIELD_SCOPE_NAME",
            Self::ScopeVersion => "METRIC_FIELD_SCOPE_VERSION",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "METRIC_FIELD_UNSPECIFIED" => Some(Self::Unspecified),
            "METRIC_FIELD_NAME" => Some(Self::Name),
            "METRIC_FIELD_DESCRIPTION" => Some(Self::Description),
            "METRIC_FIELD_UNIT" => Some(Self::Unit),
            "METRIC_FIELD_RESOURCE_SCHEMA_URL" => Some(Self::ResourceSchemaUrl),
            "METRIC_FIELD_SCOPE_SCHEMA_URL" => Some(Self::ScopeSchemaUrl),
            "METRIC_FIELD_SCOPE_NAME" => Some(Self::ScopeName),
            "METRIC_FIELD_SCOPE_VERSION" => Some(Self::ScopeVersion),
            _ => None,
        }
    }
}
/// MetricType identifies the type of metric for matching.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum MetricType {
    Unspecified = 0,
    Gauge = 1,
    Sum = 2,
    Histogram = 3,
    ExponentialHistogram = 4,
    Summary = 5,
}
impl MetricType {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "METRIC_TYPE_UNSPECIFIED",
            Self::Gauge => "METRIC_TYPE_GAUGE",
            Self::Sum => "METRIC_TYPE_SUM",
            Self::Histogram => "METRIC_TYPE_HISTOGRAM",
            Self::ExponentialHistogram => "METRIC_TYPE_EXPONENTIAL_HISTOGRAM",
            Self::Summary => "METRIC_TYPE_SUMMARY",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "METRIC_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
            "METRIC_TYPE_GAUGE" => Some(Self::Gauge),
            "METRIC_TYPE_SUM" => Some(Self::Sum),
            "METRIC_TYPE_HISTOGRAM" => Some(Self::Histogram),
            "METRIC_TYPE_EXPONENTIAL_HISTOGRAM" => Some(Self::ExponentialHistogram),
            "METRIC_TYPE_SUMMARY" => Some(Self::Summary),
            _ => None,
        }
    }
}
/// AggregationTemporality defines how a metric aggregator reports aggregated values.
/// Mirrors opentelemetry.proto.metrics.v1.AggregationTemporality.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum AggregationTemporality {
    Unspecified = 0,
    Delta = 1,
    Cumulative = 2,
}
impl AggregationTemporality {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "AGGREGATION_TEMPORALITY_UNSPECIFIED",
            Self::Delta => "AGGREGATION_TEMPORALITY_DELTA",
            Self::Cumulative => "AGGREGATION_TEMPORALITY_CUMULATIVE",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "AGGREGATION_TEMPORALITY_UNSPECIFIED" => Some(Self::Unspecified),
            "AGGREGATION_TEMPORALITY_DELTA" => Some(Self::Delta),
            "AGGREGATION_TEMPORALITY_CUMULATIVE" => Some(Self::Cumulative),
            _ => None,
        }
    }
}
/// TraceTarget defines matching and sampling actions for traces/spans.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TraceTarget {
    /// Matchers to identify which spans this policy applies to (AND logic).
    /// Implementations MUST reject policies with an empty match list.
    #[prost(message, repeated, tag = "1")]
    pub r#match: ::prost::alloc::vec::Vec<TraceMatcher>,
    /// The keep field controls whether matching spans are sampled.
    /// For traces, this uses probabilistic sampling with tracestate support.
    #[prost(message, optional, tag = "2")]
    pub keep: ::core::option::Option<TraceSamplingConfig>,
}
/// TraceMatcher provides a way to match against trace/span telemetry data using known fields.
///
/// IMPORTANT CONSTRAINTS:
/// - Multiple matchers are ANDed together: all matchers must match for the
///    overall match to succeed.
/// - The list of matchers should uniquely identify a specific pattern of telemetry
///    for that policy. Matchers should NOT be used as a catch-all; they should be
///    specific enough to target the intended telemetry precisely.
///
/// All regex fields use RE2 syntax for consistency across implementations.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TraceMatcher {
    /// If true, inverts the match result
    #[prost(bool, tag = "20")]
    pub negate: bool,
    /// If true, applies case-insensitive matching to all match types
    #[prost(bool, tag = "21")]
    pub case_insensitive: bool,
    /// FIELD SELECTION
    /// The field to match against. Exactly one must be set.
    #[prost(oneof = "trace_matcher::Field", tags = "1, 2, 3, 4, 5, 6, 7, 8, 9")]
    pub field: ::core::option::Option<trace_matcher::Field>,
    /// Match type. Exactly one must be set.
    /// Note: For span_kind and span_status fields, only exists is valid (equality is implicit).
    #[prost(oneof = "trace_matcher::Match", tags = "10, 11, 12, 13, 14, 15")]
    pub r#match: ::core::option::Option<trace_matcher::Match>,
}
/// Nested message and enum types in `TraceMatcher`.
pub mod trace_matcher {
    /// FIELD SELECTION
    /// The field to match against. Exactly one must be set.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Field {
        /// Simple fields (name, trace_id, span_id, etc.)
        #[prost(enumeration = "super::TraceField", tag = "1")]
        TraceField(i32),
        /// Span attribute by key or path
        #[prost(message, tag = "2")]
        SpanAttribute(super::AttributePath),
        /// Resource attribute by key or path
        #[prost(message, tag = "3")]
        ResourceAttribute(super::AttributePath),
        /// Scope attribute by key or path
        #[prost(message, tag = "4")]
        ScopeAttribute(super::AttributePath),
        /// Span kind matcher
        #[prost(enumeration = "super::SpanKind", tag = "5")]
        SpanKind(i32),
        /// Span status code matcher
        #[prost(enumeration = "super::SpanStatusCode", tag = "6")]
        SpanStatus(i32),
        /// Event name matcher (matches if span contains an event with this name)
        #[prost(string, tag = "7")]
        EventName(::prost::alloc::string::String),
        /// Event attribute matcher (matches if span contains an event with this attribute)
        #[prost(message, tag = "8")]
        EventAttribute(super::AttributePath),
        /// Link trace ID matcher (matches if span has a link to this trace)
        #[prost(string, tag = "9")]
        LinkTraceId(::prost::alloc::string::String),
    }
    /// Match type. Exactly one must be set.
    /// Note: For span_kind and span_status fields, only exists is valid (equality is implicit).
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Match {
        /// Exact string match
        #[prost(string, tag = "10")]
        Exact(::prost::alloc::string::String),
        /// Regular expression match
        #[prost(string, tag = "11")]
        Regex(::prost::alloc::string::String),
        /// Field existence check
        #[prost(bool, tag = "12")]
        Exists(bool),
        /// Literal prefix match
        #[prost(string, tag = "13")]
        StartsWith(::prost::alloc::string::String),
        /// Literal suffix match
        #[prost(string, tag = "14")]
        EndsWith(::prost::alloc::string::String),
        /// Literal substring match
        #[prost(string, tag = "15")]
        Contains(::prost::alloc::string::String),
    }
}
/// TraceSamplingConfig configures probabilistic sampling for traces.
///
/// This configuration follows the OpenTelemetry probability sampling specification:
/// <https://opentelemetry.io/docs/specs/otel/trace/tracestate-probability-sampling/>
///
/// Implementations MUST follow tracestate standards to allow multi-stage sampling:
/// <https://opentelemetry.io/docs/specs/otel/trace/tracestate-handling/#sampling-threshold-value-th>
///
/// The sampling decision is based on comparing a 56-bit randomness value (R) against
/// a rejection threshold (T). If R >= T, the span is kept; otherwise it is dropped.
/// The threshold is derived from the configured percentage:
///    T = (1 - percentage/100) * 2^56
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TraceSamplingConfig {
    /// Percentage at which items are sampled (0-100).
    /// >= 100 samples all items, 0 rejects all items.
    /// This is a 32-bit floating point value for precision.
    #[prost(float, tag = "1")]
    pub percentage: f32,
    /// Sampling mode determines how the sampling decision is made.
    /// Optional. Default is SAMPLING_MODE_HASH_SEED.
    #[prost(enumeration = "SamplingMode", optional, tag = "2")]
    pub mode: ::core::option::Option<i32>,
    /// Determines the number of hexadecimal digits used to encode the sampling threshold
    /// in the tracestate. Permitted values are 1-14.
    /// Optional. Default is 4.
    /// Higher precision allows finer-grained sampling probabilities.
    /// The threshold is encoded with trailing zeros removed.
    #[prost(uint32, optional, tag = "3")]
    pub sampling_precision: ::core::option::Option<u32>,
    /// An integer used to compute the hash algorithm.
    /// All collectors for a given tier (e.g., behind the same load balancer)
    /// should have the same hash_seed to ensure consistent sampling decisions.
    /// Optional. Default is 0.
    #[prost(uint32, optional, tag = "4")]
    pub hash_seed: ::core::option::Option<u32>,
    /// Determines behavior when sampling errors occur.
    /// When true (default), items with errors are rejected (fail closed).
    /// When false, items with errors are accepted (fail open).
    /// Optional. Default is true.
    #[prost(bool, optional, tag = "5")]
    pub fail_closed: ::core::option::Option<bool>,
}
/// TraceField identifies simple span fields (non-keyed).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum TraceField {
    Unspecified = 0,
    /// Span fields
    Name = 1,
    TraceId = 2,
    SpanId = 3,
    ParentSpanId = 4,
    TraceState = 5,
    /// Schema URLs
    ResourceSchemaUrl = 10,
    ScopeSchemaUrl = 11,
    /// Scope fields (InstrumentationScope)
    ScopeName = 12,
    ScopeVersion = 13,
}
impl TraceField {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "TRACE_FIELD_UNSPECIFIED",
            Self::Name => "TRACE_FIELD_NAME",
            Self::TraceId => "TRACE_FIELD_TRACE_ID",
            Self::SpanId => "TRACE_FIELD_SPAN_ID",
            Self::ParentSpanId => "TRACE_FIELD_PARENT_SPAN_ID",
            Self::TraceState => "TRACE_FIELD_TRACE_STATE",
            Self::ResourceSchemaUrl => "TRACE_FIELD_RESOURCE_SCHEMA_URL",
            Self::ScopeSchemaUrl => "TRACE_FIELD_SCOPE_SCHEMA_URL",
            Self::ScopeName => "TRACE_FIELD_SCOPE_NAME",
            Self::ScopeVersion => "TRACE_FIELD_SCOPE_VERSION",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "TRACE_FIELD_UNSPECIFIED" => Some(Self::Unspecified),
            "TRACE_FIELD_NAME" => Some(Self::Name),
            "TRACE_FIELD_TRACE_ID" => Some(Self::TraceId),
            "TRACE_FIELD_SPAN_ID" => Some(Self::SpanId),
            "TRACE_FIELD_PARENT_SPAN_ID" => Some(Self::ParentSpanId),
            "TRACE_FIELD_TRACE_STATE" => Some(Self::TraceState),
            "TRACE_FIELD_RESOURCE_SCHEMA_URL" => Some(Self::ResourceSchemaUrl),
            "TRACE_FIELD_SCOPE_SCHEMA_URL" => Some(Self::ScopeSchemaUrl),
            "TRACE_FIELD_SCOPE_NAME" => Some(Self::ScopeName),
            "TRACE_FIELD_SCOPE_VERSION" => Some(Self::ScopeVersion),
            _ => None,
        }
    }
}
/// SpanKind identifies the type of span for matching.
/// Mirrors opentelemetry.proto.trace.v1.Span.SpanKind.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SpanKind {
    Unspecified = 0,
    Internal = 1,
    Server = 2,
    Client = 3,
    Producer = 4,
    Consumer = 5,
}
impl SpanKind {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "SPAN_KIND_UNSPECIFIED",
            Self::Internal => "SPAN_KIND_INTERNAL",
            Self::Server => "SPAN_KIND_SERVER",
            Self::Client => "SPAN_KIND_CLIENT",
            Self::Producer => "SPAN_KIND_PRODUCER",
            Self::Consumer => "SPAN_KIND_CONSUMER",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "SPAN_KIND_UNSPECIFIED" => Some(Self::Unspecified),
            "SPAN_KIND_INTERNAL" => Some(Self::Internal),
            "SPAN_KIND_SERVER" => Some(Self::Server),
            "SPAN_KIND_CLIENT" => Some(Self::Client),
            "SPAN_KIND_PRODUCER" => Some(Self::Producer),
            "SPAN_KIND_CONSUMER" => Some(Self::Consumer),
            _ => None,
        }
    }
}
/// SpanStatusCode identifies the span status for matching.
/// Mirrors opentelemetry.proto.trace.v1.Status.StatusCode.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SpanStatusCode {
    Unspecified = 0,
    Ok = 1,
    Error = 2,
}
impl SpanStatusCode {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "SPAN_STATUS_CODE_UNSPECIFIED",
            Self::Ok => "SPAN_STATUS_CODE_OK",
            Self::Error => "SPAN_STATUS_CODE_ERROR",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "SPAN_STATUS_CODE_UNSPECIFIED" => Some(Self::Unspecified),
            "SPAN_STATUS_CODE_OK" => Some(Self::Ok),
            "SPAN_STATUS_CODE_ERROR" => Some(Self::Error),
            _ => None,
        }
    }
}
/// SamplingMode determines how the sampling decision is made.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SamplingMode {
    Unspecified = 0,
    /// hash_seed mode: Uses a hash of the trace ID combined with the hash_seed
    /// to make deterministic sampling decisions. This is the default mode.
    /// Suitable when you want consistent sampling across multiple collectors.
    HashSeed = 1,
    /// proportional mode: Multiplies the incoming probability by the configured
    /// percentage to compute the output threshold. This reduces traffic by a
    /// fixed factor regardless of arriving thresholds.
    ///    T_o = ProbabilityToThreshold(percentage/100 * ThresholdToProbability(T_s))
    /// For example, if incoming spans are sampled at 50% and percentage is 10%,
    /// the output probability is 0.1 * 0.5 = 5%.
    Proportional = 2,
    /// equalizing mode: Aims to make all spans have an equal threshold after
    /// passing this stage. When the incoming threshold T_s is already more
    /// restrictive than the configured target T_d, the span is kept with T_s
    /// unchanged. Otherwise, spans are selected using the target threshold T_d.
    /// This preferentially keeps rare spans while applying a hard cutoff to
    /// over-sampled spans.
    Equalizing = 3,
}
impl SamplingMode {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "SAMPLING_MODE_UNSPECIFIED",
            Self::HashSeed => "SAMPLING_MODE_HASH_SEED",
            Self::Proportional => "SAMPLING_MODE_PROPORTIONAL",
            Self::Equalizing => "SAMPLING_MODE_EQUALIZING",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "SAMPLING_MODE_UNSPECIFIED" => Some(Self::Unspecified),
            "SAMPLING_MODE_HASH_SEED" => Some(Self::HashSeed),
            "SAMPLING_MODE_PROPORTIONAL" => Some(Self::Proportional),
            "SAMPLING_MODE_EQUALIZING" => Some(Self::Equalizing),
            _ => None,
        }
    }
}
/// Policy represents a complete telemetry policy definition.
/// Policies are designed to be:
/// - Implementation Agnostic: Works in SDK, Collector, or any component
/// - Standalone: No need to understand pipeline configuration
/// - Dynamic: Can be updated post-instantiation
/// - Idempotent: Safe to apply to multiple components
/// - Fail-Open: Does not interfere with telemetry on failure
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Policy {
    /// Unique identifier for this policy
    #[prost(string, tag = "1")]
    pub id: ::prost::alloc::string::String,
    /// Human-readable name
    #[prost(string, tag = "2")]
    pub name: ::prost::alloc::string::String,
    /// Optional description
    #[prost(string, tag = "3")]
    pub description: ::prost::alloc::string::String,
    /// Whether this policy is enabled
    #[prost(bool, tag = "4")]
    pub enabled: bool,
    /// Timestamp when this policy was created (Unix epoch nanoseconds)
    #[prost(fixed64, tag = "5")]
    pub created_at_unix_nano: u64,
    /// Timestamp when this policy was last modified (Unix epoch nanoseconds)
    #[prost(fixed64, tag = "6")]
    pub modified_at_unix_nano: u64,
    /// Labels for metadata and routing
    #[prost(message, repeated, tag = "7")]
    pub labels: ::prost::alloc::vec::Vec<
        super::super::super::opentelemetry::proto::common::v1::KeyValue,
    >,
    /// Target configuration. Exactly one must be set.
    #[prost(oneof = "policy::Target", tags = "10, 11, 12")]
    pub target: ::core::option::Option<policy::Target>,
}
/// Nested message and enum types in `Policy`.
pub mod policy {
    /// Target configuration. Exactly one must be set.
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Target {
        #[prost(message, tag = "10")]
        Log(super::LogTarget),
        #[prost(message, tag = "11")]
        Metric(super::MetricTarget),
        #[prost(message, tag = "12")]
        Trace(super::TraceTarget),
    }
}
/// ClientMetadata contains information about the client requesting policies.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ClientMetadata {
    /// Policy stages this client supports
    #[prost(enumeration = "PolicyStage", repeated, tag = "1")]
    pub supported_policy_stages: ::prost::alloc::vec::Vec<i32>,
    /// Additional metadata labels
    #[prost(message, repeated, tag = "2")]
    pub labels: ::prost::alloc::vec::Vec<
        super::super::super::opentelemetry::proto::common::v1::KeyValue,
    >,
    /// Resource attributes describing this client's identity
    /// REQUIRED:
    /// * service.instance.id
    /// * service.name
    /// * service.namespace
    /// * service.version
    #[prost(message, repeated, tag = "3")]
    pub resource_attributes: ::prost::alloc::vec::Vec<
        super::super::super::opentelemetry::proto::common::v1::KeyValue,
    >,
}
/// TransformStageStatus reports hits and misses for a single transform stage.
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct TransformStageStatus {
    /// Number of times this stage was applied.
    #[prost(int64, tag = "1")]
    pub hits: i64,
    /// Number of times this stage was evaluated but the field selected nothing.
    #[prost(int64, tag = "2")]
    pub misses: i64,
}
/// PolicySyncStatus reports the status of an individual policy during sync.
/// Used to communicate policy execution metrics and errors back to the provider.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PolicySyncStatus {
    /// The policy ID this status refers to.
    #[prost(string, tag = "1")]
    pub id: ::prost::alloc::string::String,
    /// Number of times this policy matched telemetry since the last sync.
    #[prost(int64, tag = "2")]
    pub match_hits: i64,
    /// Number of times this policy was evaluated but did not match.
    #[prost(int64, tag = "3")]
    pub match_misses: i64,
    /// Error messages encountered while applying this policy.
    #[prost(string, repeated, tag = "4")]
    pub errors: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// Transform stage statistics
    #[prost(message, optional, tag = "10")]
    pub remove: ::core::option::Option<TransformStageStatus>,
    #[prost(message, optional, tag = "11")]
    pub redact: ::core::option::Option<TransformStageStatus>,
    #[prost(message, optional, tag = "12")]
    pub rename: ::core::option::Option<TransformStageStatus>,
    #[prost(message, optional, tag = "13")]
    pub add: ::core::option::Option<TransformStageStatus>,
}
/// SyncRequest is sent by clients to request policy updates.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SyncRequest {
    /// Client identification and capabilities
    #[prost(message, optional, tag = "1")]
    pub client_metadata: ::core::option::Option<ClientMetadata>,
    /// Request full sync (ignore policy_statuses)
    #[prost(bool, tag = "2")]
    pub full_sync: bool,
    /// Last sync timestamp (Unix epoch nanoseconds)
    #[prost(fixed64, tag = "3")]
    pub last_sync_timestamp_unix_nano: u64,
    /// The hash of the policy list as last received by the client.
    #[prost(string, tag = "4")]
    pub last_successful_hash: ::prost::alloc::string::String,
    /// Status of individual policies within this set.
    #[prost(message, repeated, tag = "5")]
    pub policy_statuses: ::prost::alloc::vec::Vec<PolicySyncStatus>,
}
/// SyncResponse contains policy updates for the client.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SyncResponse {
    /// The policies to sync
    #[prost(message, repeated, tag = "1")]
    pub policies: ::prost::alloc::vec::Vec<Policy>,
    /// Hash of the entire list of policies (for change detection)
    #[prost(string, tag = "2")]
    pub hash: ::prost::alloc::string::String,
    /// Timestamp of this sync (Unix epoch nanoseconds)
    #[prost(fixed64, tag = "3")]
    pub sync_timestamp_unix_nano: u64,
    /// Suggested interval before next sync (in seconds)
    #[prost(uint32, tag = "4")]
    pub recommended_sync_interval_seconds: u32,
    /// Whether this is a full replacement or incremental update
    #[prost(enumeration = "SyncType", tag = "5")]
    pub sync_type: i32,
    /// Error message if sync failed
    #[prost(string, tag = "6")]
    pub error_message: ::prost::alloc::string::String,
}
/// PolicyStage identifies the execution stage for a policy.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum PolicyStage {
    Unspecified = 0,
    /// Log filtering stage (keep/drop decisions)
    LogFilter = 1,
    /// Log transformation stage (field modifications)
    LogTransform = 2,
    /// Metric filtering stage (keep/drop decisions)
    MetricFilter = 3,
    /// Trace probabilistic sampling stage
    TraceSampling = 4,
}
impl PolicyStage {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "POLICY_STAGE_UNSPECIFIED",
            Self::LogFilter => "POLICY_STAGE_LOG_FILTER",
            Self::LogTransform => "POLICY_STAGE_LOG_TRANSFORM",
            Self::MetricFilter => "POLICY_STAGE_METRIC_FILTER",
            Self::TraceSampling => "POLICY_STAGE_TRACE_SAMPLING",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "POLICY_STAGE_UNSPECIFIED" => Some(Self::Unspecified),
            "POLICY_STAGE_LOG_FILTER" => Some(Self::LogFilter),
            "POLICY_STAGE_LOG_TRANSFORM" => Some(Self::LogTransform),
            "POLICY_STAGE_METRIC_FILTER" => Some(Self::MetricFilter),
            "POLICY_STAGE_TRACE_SAMPLING" => Some(Self::TraceSampling),
            _ => None,
        }
    }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SyncType {
    Unspecified = 0,
    Full = 1,
}
impl SyncType {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "SYNC_TYPE_UNSPECIFIED",
            Self::Full => "SYNC_TYPE_FULL",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "SYNC_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
            "SYNC_TYPE_FULL" => Some(Self::Full),
            _ => None,
        }
    }
}
/// Generated client implementations.
#[cfg(feature = "grpc")]
pub mod policy_service_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// PolicyService defines the gRPC service for policy providers.
    #[derive(Debug, Clone)]
    pub struct PolicyServiceClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl PolicyServiceClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> PolicyServiceClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::BoxBody>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> PolicyServiceClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::BoxBody>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::BoxBody>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            PolicyServiceClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// Sync policies with the provider
        pub async fn sync(
            &mut self,
            request: impl tonic::IntoRequest<super::SyncRequest>,
        ) -> std::result::Result<tonic::Response<super::SyncResponse>, tonic::Status> {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/tero.policy.v1.PolicyService/Sync",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("tero.policy.v1.PolicyService", "Sync"));
            self.inner.unary(req, path, codec).await
        }
    }
}