-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
obsservice: creating Insights Pipeline
Create basic structure for Insights Pipeline. Currently the Validator (always return that is valid) and Processor (just printing the value) are very simple. This commit is to introduce that structure so can be iterated on. Part Of CC-26215 Release note: None
- Loading branch information
Showing
12 changed files
with
155 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package process | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/obsservice/obspb" | ||
) | ||
|
||
// TODO: Delete this file once a proper Processor is created for Statement Insights. | ||
|
||
type InsightsStdoutProcessor struct{} | ||
|
||
func (t *InsightsStdoutProcessor) Process( | ||
_ context.Context, stmtInsight *obspb.StatementInsightsStatistics, | ||
) error { | ||
fmt.Println(stmtInsight) | ||
return nil | ||
} | ||
|
||
var _ EventProcessor[*obspb.StatementInsightsStatistics] = (*InsightsStdoutProcessor)(nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
pkg/obsservice/obslib/transform/stmt_insight_transformer.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package transform | ||
|
||
import ( | ||
"github.com/cockroachdb/cockroach/pkg/obsservice/obspb" | ||
"github.com/cockroachdb/cockroach/pkg/util/protoutil" | ||
) | ||
|
||
type StmtInsightTransformer struct { | ||
} | ||
|
||
var _ EventTransformer[*obspb.StatementInsightsStatistics] = (*StmtInsightTransformer)(nil) | ||
|
||
func (t *StmtInsightTransformer) Transform( | ||
event *obspb.Event, | ||
) (*obspb.StatementInsightsStatistics, error) { | ||
var insight obspb.StatementInsightsStatistics | ||
if err := protoutil.Unmarshal(event.LogRecord.Body.GetBytesValue(), &insight); err != nil { | ||
return nil, err | ||
} | ||
return &insight, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package validate | ||
|
||
import "github.com/cockroachdb/cockroach/pkg/obsservice/obspb" | ||
|
||
type StmtInsightValidator struct { | ||
} | ||
|
||
var _ Validator[*obspb.StatementInsightsStatistics] = (*StmtInsightValidator)(nil) | ||
|
||
func (t *StmtInsightValidator) Validate(_ *obspb.StatementInsightsStatistics) error { | ||
//TODO: Add proper validation | ||
return nil | ||
} |