-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic plugin system to customize telemetry.
This PR introduces a very basic plugin system that allows developers to customize how `weaver-kube` manages logs, metrics, and traces. For example, consider the following `foo/main.go`: ``` // This is file foo/main.go. package main import ... func main() { plugins := tool.Plugins{ HandleLogEntry: func(context.Context, *protos.LogEntry) error { ... }, HandleTraceSpans: func(context.Context, []trace.ReadOnlySpan) error { ... }, HandleMetrics: func(context.Context, []*metrics.MetricSnapshot) error { ... }, } tool.Run("foo", plugins) } ``` We can build this file into an executable `foo` that behaves the same as `weaver-kube`, but uses the provided plugins: ```shell $ foo --help Deploy and manage Service Weaver programs. Usage: foo <command> ... Available Commands: deploy Deploy a Service Weaver app help Print help for a sub-command version Show foo version Flags: -h, --help Print this help message. Use "foo help <command>" for more information about a command. ``` See https://github.com/mwhittaker/jeagar for a complete example. In the long term, we'll replace this basic plugin mechanism with something more general. This PR allows customers to onboard to Service Weaver in the short term.
- Loading branch information
1 parent
024f4ad
commit dec2d7f
Showing
8 changed files
with
184 additions
and
87 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,30 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// 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 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package tool | ||
|
||
import ( | ||
"github.com/ServiceWeaver/weaver-kube/internal/impl" | ||
"github.com/ServiceWeaver/weaver/runtime/tool" | ||
) | ||
|
||
func Commands(opts impl.BabysitterOptions) map[string]*tool.Command { | ||
return map[string]*tool.Command{ | ||
"version": &versionCmd, | ||
"deploy": &deployCmd, | ||
|
||
// Hidden commands. | ||
"babysitter": babysitterCmd(opts), | ||
} | ||
} |
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
Oops, something went wrong.