Files
magpie/plugins/otel/otel.go
T
yetone 3ccbe6bc15 plugins: a runtime for built-in plugins, and Plugins › Built-in to switch them (P0)
Lxxyx on X (https://x.com/Lxxyx_/status/2109506752656150974): magpie has
too much in it. This is P0 of making magpie's parts plugins, as DeepSeek
Harness does: a runtime, plugins.yml, and the first five built-in plugins
the user can switch off.

- internal/pluginrt: a registry (Register from init), a manifest (API
  caret range, Requires/Provides, Essential, InUse, Apply, Parts,
  Defaults) and Reconcile: the plugins no longer wanted, with whatever
  needs a service they provided, are disposed newest first; the wanted
  ones are applied once their services are there. A plugin that fails or
  panics is failed and the rest run. TestPluginsImportOnlyCore keeps the
  boundary: nothing outside plugins/ imports one, none imports another.
- plugins.yml (appdir.Config()): default → preset (essentials | all) →
  the user's rows → in use. A new install is written Essentials, a magpie
  that ran here before (settings.RanBefore) All, so existing users keep
  everything. Writes are locked, whole and keep a .bak; a file that
  doesn't parse is an error, never empty, and is never written over.
- plugins/groups, library, otel, sessions, warmups. In P0 a plugin off
  is the window's alone: its page, sections and rows (data-feature) leave
  the window; the gateway, TUI and CLI serve the same, nothing is
  deleted. One in use stays on.
- The window: Plugins › Built-in, the first tab, a switch per plugin;
  GET/POST /api/plugins/builtin; boot.js says which are off before the
  first paint. CLI: magpie plugin builtin [on|off <id>], plugin preset,
  plugin dump [--json].
- docs/subsystems/plugin-runtime.md, gui-shell.md.

Run: go test ./internal/pluginrt/ ./internal/settings/ ./internal/gui/;
gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows
go vet ./.... GUI: builtins.test.cjs in Chromium and WebKit, 5 languages,
1100/800/420; list-sort, mobile-web, routing-keys-fold, routing-sessions
pass. By hand under a sandbox HOME: a new install gets essentials, an
existing one all, a broken plugins.yml is refused and kept, dump works.
Full suite results after the rebase are in the push notes.
2026-10-13 16:19:13 +08:00

29 lines
839 B
Go

// Package otel is Settings' Observability: each request's traces and
// metrics sent to an OpenTelemetry collector, such as Langfuse. While it
// sends, it stays on.
package otel
import (
"github.com/yetone/magpie/internal/pluginrt"
"github.com/yetone/magpie/internal/settings"
)
func init() {
pluginrt.Register(pluginrt.Manifest{
ID: "otel", API: "^1", Requires: []string{"window", "settings"},
Name: "Observability", Sub: "Send each request's traces and metrics to an OpenTelemetry collector, such as Langfuse",
One: "Sending to a collector", Many: "Sending to a collector",
InUse: func() (int, error) {
s, err := settings.LoadChecked()
if err != nil {
return 0, err
}
if s.OTel.Enabled {
return 1, nil
}
return 0, nil
},
Parts: []pluginrt.Part{{Slot: "settings.section", Key: "otel"}},
})
}