Skip to content

Commit c60241f

Browse files
authored
feat(pubsub): add support for ingestion platform logging settings (#10969)
* feat(pubsub): add support for ingestion platform logging settings * remove kafka logging
1 parent f0b05e2 commit c60241f

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

pubsub/topic.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ type TopicConfigToUpdate struct {
352352
// data source into this topic.
353353
//
354354
// When changing this value, the entire data source settings object must be applied,
355-
// rather than just the differences.
355+
// rather than just the differences. This includes the source and logging settings.
356356
//
357357
// Use the zero value &IngestionDataSourceSettings{} to remove the ingestion settings from the topic.
358358
IngestionDataSourceSettings *IngestionDataSourceSettings
@@ -429,6 +429,8 @@ func messageStoragePolicyToProto(msp *MessageStoragePolicy) *pb.MessageStoragePo
429429
// IngestionDataSourceSettings enables ingestion from a data source into this topic.
430430
type IngestionDataSourceSettings struct {
431431
Source IngestionDataSource
432+
433+
PlatformLogsSettings *PlatformLogsSettings
432434
}
433435

434436
// IngestionDataSource is the kind of ingestion source to be used.
@@ -624,6 +626,13 @@ func protoToIngestionDataSourceSettings(pbs *pb.IngestionDataSourceSettings) *In
624626
MatchGlob: cs.GetMatchGlob(),
625627
}
626628
}
629+
630+
if pbs.PlatformLogsSettings != nil {
631+
s.PlatformLogsSettings = &PlatformLogsSettings{
632+
Severity: PlatformLogsSeverity(pbs.PlatformLogsSettings.Severity),
633+
}
634+
}
635+
627636
return s
628637
}
629638

@@ -636,6 +645,11 @@ func (i *IngestionDataSourceSettings) toProto() *pb.IngestionDataSourceSettings
636645
return nil
637646
}
638647
pbs := &pb.IngestionDataSourceSettings{}
648+
if i.PlatformLogsSettings != nil {
649+
pbs.PlatformLogsSettings = &pb.PlatformLogsSettings{
650+
Severity: pb.PlatformLogsSettings_Severity(i.PlatformLogsSettings.Severity),
651+
}
652+
}
639653
if out := i.Source; out != nil {
640654
if k, ok := out.(*IngestionDataSourceAWSKinesis); ok {
641655
pbs.Source = &pb.IngestionDataSourceSettings_AwsKinesis_{
@@ -694,6 +708,30 @@ func (i *IngestionDataSourceSettings) toProto() *pb.IngestionDataSourceSettings
694708
return pbs
695709
}
696710

711+
// PlatformLogsSettings configures logging produced by Pub/Sub.
712+
// Currently only valid on Cloud Storage ingestion topics.
713+
type PlatformLogsSettings struct {
714+
Severity PlatformLogsSeverity
715+
}
716+
717+
// PlatformLogsSeverity are the severity levels of Platform Logs.
718+
type PlatformLogsSeverity int32
719+
720+
const (
721+
// PlatformLogsSeverityUnspecified is the default value. Logs level is unspecified. Logs will be disabled.
722+
PlatformLogsSeverityUnspecified PlatformLogsSeverity = iota
723+
// PlatformLogsSeverityDisabled means logs will be disabled.
724+
PlatformLogsSeverityDisabled
725+
// PlatformLogsSeverityDebug means debug logs and higher-severity logs will be written.
726+
PlatformLogsSeverityDebug
727+
// PlatformLogsSeverityInfo means info logs and higher-severity logs will be written.
728+
PlatformLogsSeverityInfo
729+
// PlatformLogsSeverityWarning means warning logs and higher-severity logs will be written.
730+
PlatformLogsSeverityWarning
731+
// PlatformLogsSeverityError means only error logs will be written.
732+
PlatformLogsSeverityError
733+
)
734+
697735
// Config returns the TopicConfig for the topic.
698736
func (t *Topic) Config(ctx context.Context) (TopicConfig, error) {
699737
pbt, err := t.c.pubc.GetTopic(ctx, &pb.GetTopicRequest{Topic: t.name})

pubsub/topic_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ func TestTopic_IngestionCloudStorage(t *testing.T) {
181181
MinimumObjectCreateTime: time.Now().Add(-time.Hour),
182182
MatchGlob: "**.txt",
183183
},
184+
PlatformLogsSettings: &PlatformLogsSettings{
185+
Severity: PlatformLogsSeverityDisabled,
186+
},
184187
},
185188
}
186189

@@ -204,6 +207,9 @@ func TestTopic_IngestionCloudStorage(t *testing.T) {
204207
MinimumObjectCreateTime: time.Now().Add(-2 * time.Hour),
205208
MatchGlob: "**.txt",
206209
},
210+
PlatformLogsSettings: &PlatformLogsSettings{
211+
Severity: PlatformLogsSeverityError,
212+
},
207213
}
208214
config2, err := topic.Update(ctx, TopicConfigToUpdate{IngestionDataSourceSettings: settings})
209215
if err != nil {

0 commit comments

Comments
 (0)