Files
magpie/plugins/otel/otel.go
T
yetone ff7d84b9b2 gui: a built-in's switch, settings and page lead to each other (netube99 on X)
netube99 (X, 2119721422918742222): masking is switched on in Plugins ›
Built-in, set in Settings › Privacy and seen in Insights › Masking, and
none of the three leads to the others. Web search had the same split.
One pattern for every built-in whose switch, settings and page are apart:

- pluginrt.Manifest.SetAt ("privacy #redactList") says where Settings has
  its settings: redact, search, gateway and otel set one. builtins.go
  sends setAt and page (its nav.page Part).
- Its Built-in row (featGo): "Settings › <tab>" and, while on, its page
  ("Masking"). No settings link while off when those settings hide with
  the plugin (Observability).
- Its settings, while off (featOff): a first row "Off in Plugins ›
  Built-in", what being off means, and Turn on. Privacy and Web search
  use it; search's own off row went.
- Insights › Masking's head: "Settings › Privacy", unless Turn off
  already goes there. At 600px and under its buttons wrap below the title.
- docs/subsystems/plugin-runtime.md documents SetAt.

Proposal for the owner, not built: give each feature one home with its
switch, settings and page together. This commit only links the three.

Core budget: no raise. +~1.9KB of code is paid for by shortening six
app.js comments (logo mask shelf, copy, sidebar, account models,
fitSend, the hold room).

Run on mote at fe672ce69's tree (origin/main 2b22425b4 + these two):
- go vet ./internal/gui ./internal/pluginrt ./plugins/...;
  GOOS=linux -tags nogui and GOOS=windows vet of gui and plugins: clean.
  gofmt -l: clean.
- go test -run 'TestBuiltin|TestCoreScriptBudget|Translated'
  ./internal/gui ./internal/pluginrt: ok (budget passes after the cuts).
- node --test builtin-places, websearch-places, builtins, i18n-keys,
  i18n-en-no-cjk: 235 pass, 1 fail. The fail is i18n-keys "a plugin's
  words are its own" on plugins/usage "View routing", red on origin/main
  too (#5332, #5426, #5482).
  builtin-places and websearch-places cover en, zh, zh-TW, ja and de in
  Chromium and WebKit, at 1100 and 420 wide, nothing past the edge.
Broken by hand: featGo and featOff made to return at once, and 40
builtin-places subtests went red (42 fails with their parents). Round 1's
files reverted made websearch-places 102 of 142 red.

Queued, not waited for (owner: push each verified fix at once): the full
`go test -timeout 45m ./...` then `make test-ui` on mote behind
~/suite.lock; log at
~/workspace/projects/magpie-wt/websearch-surfaces-scratch/full.log. Any
red gets an issue.
Not tried: the real app on Linux/Windows; warm-ups have no SetAt (their
settings moved into the provider editor).
2026-11-09 17:58:11 +08:00

47 lines
1.5 KiB
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.
//
// It is the first consumer of the gateway's observer point (P3 of
// docs/subsystems/plugin-runtime.md): Apply registers internal/otlp's
// exporter as a usage.Observer, and off, the gateway exports nothing and
// keeps no reply whole for it.
package otel
import (
"github.com/yetone/magpie/internal/otlp"
"github.com/yetone/magpie/internal/pluginrt"
"github.com/yetone/magpie/internal/settings"
"github.com/yetone/magpie/internal/usage"
)
func init() {
pluginrt.Register(pluginrt.Manifest{
ID: "otel", API: "^1", Requires: []string{"window", "settings", "gateway"},
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",
// on while settings.json or MAGPIE_OTEL_ENABLED says to send: off,
// nothing would
InUse: func() (int, error) {
if _, err := settings.LoadChecked(); err != nil {
return 0, err
}
config, err := settings.OTelExport()
if err != nil {
return 0, err
}
if config.Enabled {
return 1, nil
}
return 0, nil
},
SetAt: "otel #otelList",
Parts: []pluginrt.Part{{Slot: "settings.section", Key: "otel"}},
Client: []string{"i18n.js", "page.js"},
Apply: func(c *pluginrt.Ctx) error {
c.OnDispose(usage.Observe(otlp.New()))
return nil
},
})
}