-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added basic plugin system to customize telemetry. #86
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
internal/impl/babysitter.go
Outdated
return fmt.Errorf("Babysitter.Serve: listen on port %d: %w", prometheusPort, err) | ||
group, ctx := errgroup.WithContext(b.ctx) | ||
|
||
if b.opts.HandleMetrics == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logs: we print them with pretty printer if there is no custom way to manipulate them
Traces: we don't do anything if no custom way to manipulate them
Metrics: if no custom way to manipulate them, we export them to an http server that we will be running (in prometheus format)
Could we:
- Create an examples or plugins directory under weaver-kube and add the jaeger example?
- Also add an example for metrics integration with Prometheus in the same directory? The http server code that is here can go there. I think we shouldn't do anything by default (same as for traces).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to not export metrics by default. I'll add examples in a future PR!
"github.com/ServiceWeaver/weaver-kube/internal/impl" | ||
"github.com/ServiceWeaver/weaver/runtime/tool" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a comment here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
024f4ad
to
4027b71
Compare
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Robert!
"github.com/ServiceWeaver/weaver-kube/internal/impl" | ||
"github.com/ServiceWeaver/weaver/runtime/tool" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
internal/impl/babysitter.go
Outdated
return fmt.Errorf("Babysitter.Serve: listen on port %d: %w", prometheusPort, err) | ||
group, ctx := errgroup.WithContext(b.ctx) | ||
|
||
if b.opts.HandleMetrics == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to not export metrics by default. I'll add examples in a future PR!
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 followingfoo/main.go
:We can build this file into an executable
foo
that behaves the same asweaver-kube
, but uses the provided plugins: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.