diff --git a/docs/reference.md b/docs/reference.md index 3ed2741e0..3afb51b54 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -3754,7 +3754,9 @@ environment: `MAGPIE_OTEL_ENDPOINT=https://cloud.langfuse.com/api/public/otel` and `MAGPIE_OTEL_HEADERS=Authorization=Basic%20,x-langfuse-ingestion-version=4`. Traces include agent, provider, model, token counts (including cache and -reasoning), HTTP status, timing, and route ID. Attempts with the same route ID +reasoning), HTTP status, timing, route ID, and the name of the gateway key the +request came with (`magpie.gateway_key.name`, absent without a key; never the +key's ID or secret). Attempts with the same route ID share a trace ID. Chat, Responses, Anthropic and Gemini gateway requests also export a parent request span and child spans for every routing attempt, including unbilled failures, retries and fallbacks, so Langfuse can render a @@ -3863,7 +3865,10 @@ details. It reads this computer's local sessions, including calls made without Magpie as the proxy. Metrics group duration and input/output token histograms by agent, provider, -model, operation and error status. Prompt/reply text is exported only when +model, operation, error status and gateway key name. Each gateway key name +multiplies a metric's series (one set per name requests came with), which +matters to a collector that limits or bills by series; a name is not unique, +so keys sharing one are counted together. Prompt/reply text is exported only when **Include request and response bodies** is enabled (`MAGPIE_OTEL_BODIES=true`); secrets are masked and each body is limited to 256 KiB unless **Include the whole bodies** is enabled. Conversation IDs are exported only with diff --git a/docs/subsystems/plugin-runtime.md b/docs/subsystems/plugin-runtime.md index 08fd09ff5..6f7595a78 100644 --- a/docs/subsystems/plugin-runtime.md +++ b/docs/subsystems/plugin-runtime.md @@ -180,7 +180,7 @@ plugin off the gateway does no observing work. | --- | --- | --- | | `usage.Observer` | `Serve() (stop)`, `Bodies()`, `Begin(Request) Watch` and `Ledger(Record)`. An observer watches what the gateway serves and what the ledger is written, and never changes either. `Observe(o)` registers one until its remove; `Observers` lists them. It lives in `internal/usage`, not the gateway, because every row is a usage `Record` and the ledger's other writers reach it too. | [`observe.go`](../../internal/usage/observe.go) | | Serving | `ServeObservers()` starts every observer registered, and each one registered later, until the last of its stops (it is counted). Only the process serving the gateway calls it (`Server.ListenAndServe`), so a CLI that writes a usage row exports nothing. Remove stops a serving observer. | [`observe.go`](../../internal/usage/observe.go), [`gateway.go`](../../internal/gateway/gateway.go) | -| `Begin` and `Watch` | As a request starts the gateway asks each observer (`observeRequest`) with `usage.Request`: its header, agent, session (the native one when the agent names it), call kind (`auxiliary` for Claude's tool-less helper calls) and `Plain` (loopback, no gateway key, not passed on from another magpie). A `Watch` it returns gets `Attempt` for each routing attempt, unbilled failures and retries too, and `End` once. With no observer, or none watching, the request carries nothing. | [`observe.go`](../../internal/gateway/observe.go) | +| `Begin` and `Watch` | As a request starts the gateway asks each observer (`observeRequest`) with `usage.Request`: its header, agent, session (the native one when the agent names it), call kind (`auxiliary` for Claude's tool-less helper calls) and `Plain` (loopback, no gateway key, not passed on from another magpie). A `Watch` it returns gets `Attempt` for each routing attempt, unbilled failures and retries too, and `End` once. Both records carry `CallerKeyName`, captured from the authenticated caller when observing begins. The OTLP exporter sends this nonempty name as `magpie.gateway_key.name` on the root, attempts, ledger spans and metric points; it never sends the key's ID or secret (see [OTLP export](../reference.md#otlp-export)). With no observer, or none watching, the request carries nothing. | [`observe.go`](../../internal/gateway/observe.go) | | Bodies | `Bodies()` is `NoBodies`, `CapturedBodies` (the first 256 KiB, cut with `usage.BodyCut`) or `WholeBodies` (the reply spooled whole as it streams, #538). The gateway takes the most any observer wants now (`ObservedBodies`): it keeps the whole reply only when one asks for it, and puts bodies on an attempt's record only when one asks for any. | [`observe.go`](../../internal/gateway/observe.go), [`capture.go`](../../internal/gateway/capture.go) | | `Ledger` and `Watched` | Every row `Append` writes is passed to each observer. A row of a request some observer watched has `Watched` set (`appendUsage`), so an observer that sent the request's attempts doesn't send its row again. | [`usage.go`](../../internal/usage/usage.go), [`lan.go`](../../internal/gateway/lan.go) | | `internal/otlp` | The OTLP/HTTP exporter, moved whole out of `internal/usage`: `otlp.New()` is an `Exporter`, a `usage.Observer`. Its Begin leaves a local agent's own turn to the agent's transcript when session tracing reads it, and takes a W3C `traceparent` as the parent. Settings are read on each call, as before. Both signals' resource is `service.name=magpie` with `OTEL_RESOURCE_ATTRIBUTES` merged over it and `OTEL_SERVICE_NAME` over that (`otelResourceAttributes`, #5167); an invalid variable is discarded whole and logged once, by entry position only. Nothing about the host is collected. | [`otlp/`](../../internal/otlp) | diff --git a/internal/gateway/observe.go b/internal/gateway/observe.go index e445de29f..d6b5fd1d3 100644 --- a/internal/gateway/observe.go +++ b/internal/gateway/observe.go @@ -14,6 +14,10 @@ import ( type observed struct { watches []usage.Watch routeID int64 + // keyName is the gateway key the request came with, by the name the + // user gave it (access.Identity.KeyName), never its secret; "" without + // one. Each span carries it as the ledger's row does (CallerKeyName). + keyName string } type observedKey struct{} @@ -27,9 +31,10 @@ func observeRequest(r *http.Request, kind string, body []byte) (*http.Request, * } // the agent it is recorded as, another magpie's own (callerFrom) agent := callerOf(r).agent + who := access.Caller(r.Context()) q := usage.Request{Header: r.Header, Agent: agent, Session: observedSession(r.Header), Kind: observedKind(agent, kind, body), - Plain: local(r) && access.Caller(r.Context()).KeyID == "" && callerOf(r).via == ""} - o := &observed{} + Plain: local(r) && who.KeyID == "" && callerOf(r).via == ""} + o := &observed{keyName: who.KeyName} for _, ob := range observers { if w := ob.Begin(q); w != nil { o.watches = append(o.watches, w) @@ -63,7 +68,7 @@ func (o *observed) end(call Call, millis int64) { if o == nil { return } - rec := usage.Record{RouteID: o.routeID, Time: call.Time, Agent: call.Agent, Model: call.Model, Status: call.Status, Millis: millis} + rec := usage.Record{RouteID: o.routeID, Time: call.Time, Agent: call.Agent, Model: call.Model, Status: call.Status, Millis: millis, CallerKeyName: o.keyName} canceledAs(&rec, call.Status, call.Error) for _, w := range o.watches { w.End(rec) @@ -80,7 +85,7 @@ func (o *observed) attempt(call Call, attempt Try, providerID, effort string, he rec := usage.Record{RouteID: o.routeID, Time: attempt.Start, Agent: call.Agent, Provider: providerID, Model: attempt.Model, Requested: call.Model, Served: u.Served, Effort: effort, Input: u.Input, Output: u.Output, CacheRead: u.CacheRead, CacheWrite: u.CacheWrite, CacheUnknown: u.cacheNotCounted(), Reasoning: u.Reasoning, - Millis: time.Since(attempt.Start).Milliseconds(), Status: attempt.Status, TTFT: attempt.TTFT, FirstText: attempt.FirstText, FirstReasoning: attempt.FirstReasoning, ReasoningHidden: attempt.ReasoningHidden} + Millis: time.Since(attempt.Start).Milliseconds(), Status: attempt.Status, TTFT: attempt.TTFT, FirstText: attempt.FirstText, FirstReasoning: attempt.FirstReasoning, ReasoningHidden: attempt.ReasoningHidden, CallerKeyName: o.keyName} canceledAs(&rec, attempt.Status, attempt.Error) if wanted := usage.ObservedBodies(); wanted != usage.NoBodies { reply, cut := capture.body.text(), capture.body.truncated diff --git a/internal/gateway/otel_test.go b/internal/gateway/otel_test.go index 319eb8802..bd33ba4e2 100644 --- a/internal/gateway/otel_test.go +++ b/internal/gateway/otel_test.go @@ -327,6 +327,94 @@ func TestOTelExportsGatewayUsageWithoutContent(t *testing.T) { } } +// A request with a gateway key carries the key's name on its root span, +// each attempt span and their metrics (magpie.gateway_key.name), never the +// key's id or secret; one without a key carries no such attribute. +func TestOTelExportsGatewayKeyName(t *testing.T) { + for _, keyed := range []bool{true, false} { + t.Run(fmt.Sprint(keyed), func(t *testing.T) { + plan := &fake{ctype: "application/json", code: 429, reply: `{"error":{"message":"busy"}}`} + spare := &fake{ctype: "application/json", reply: `{"id":"ok","choices":[],"usage":{"prompt_tokens":10,"completion_tokens":5}}`} + twoProviders(t, plan, spare) + received := make(chan []byte, 64) + collector := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + b, _ := io.ReadAll(r.Body) + received <- b + io.WriteString(w, `{}`) + })) + defer collector.Close() + t.Setenv("MAGPIE_OTEL_ENABLED", "true") + t.Setenv("MAGPIE_OTEL_ENDPOINT", collector.URL) + t.Setenv("MAGPIE_OTEL_HEADERS", "") + t.Setenv("MAGPIE_OTEL_METRICS", "true") + t.Setenv("MAGPIE_OTEL_BODIES", "false") + fastOTel(t) + stop := startOTel() + t.Cleanup(stop) + req := httptest.NewRequest("POST", "/v1/chat/completions", strings.NewReader(chatReq)) + req.RemoteAddr = "192.168.1.5:1234" + if keyed { + req = req.WithContext(access.WithIdentity(req.Context(), access.Identity{KeyID: "PRIVATE-KEY-ID", KeyName: "alice-laptop"})) + } + response := httptest.NewRecorder() + New().Handler().ServeHTTP(response, req) + if response.Code != 200 { + t.Fatalf("gateway: %d %s", response.Code, response.Body.String()) + } + stop() + traces, metricExports := otelExports(received) + if len(metricExports) == 0 { + t.Fatal("no metrics exported") + } + type attr struct { + Key string + Value map[string]string + } + var spans [][]attr + for _, exported := range traces { + var wire struct { + ResourceSpans []struct { + ScopeSpans []struct{ Spans []struct{ Attributes []attr } } + } + } + if err := json.Unmarshal(exported, &wire); err != nil { + t.Fatal(err) + } + for _, rs := range wire.ResourceSpans { + for _, ss := range rs.ScopeSpans { + for _, s := range ss.Spans { + spans = append(spans, s.Attributes) + } + } + } + } + if len(spans) != 3 { + t.Fatalf("want two attempts and a root, got %d spans", len(spans)) + } + for i, attrs := range spans { + name, n := "", 0 + for _, a := range attrs { + if a.Key == "magpie.gateway_key.name" { + name, n = a.Value["stringValue"], n+1 + } + } + if keyed && (n != 1 || name != "alice-laptop") || !keyed && n != 0 { + t.Fatalf("span %d: gateway key name %q seen %d times, keyed=%v: %+v", i, name, n, keyed, attrs) + } + } + all := string(bytes.Join(append(traces, metricExports...), []byte("\n"))) + if strings.Contains(all, "PRIVATE-KEY-ID") { + t.Fatalf("gateway key id exported: %s", all) + } + points := strings.Count(all, `"key":"magpie.gateway_key.name","value":{"stringValue":"alice-laptop"}`) + if keyed && points < 5 || !keyed && points != 0 { + // 3 spans, plus the duration and token metrics' points + t.Fatalf("gateway key name in %d places, keyed=%v: %s", points, keyed, all) + } + }) + } +} + // with bodies on (#538) the span carries the request and the reply as // Langfuse's observation input and output — a stream's text put together, // a secret in the request still masked — and with it off neither diff --git a/internal/otlp/otel_test.go b/internal/otlp/otel_test.go index 56c2b84e0..5a3ce1fda 100644 --- a/internal/otlp/otel_test.go +++ b/internal/otlp/otel_test.go @@ -51,7 +51,8 @@ func TestOTelBatchWireAndPrivacy(t *testing.T) { stop := StartOTel() t.Cleanup(stop) r := Record{RouteID: 42, Time: time.Now(), Agent: "pi", Provider: "deepseek", Model: "deepseek-chat", Requested: "group/mine", Served: "deepseek-v4", Input: 10, CacheRead: 3, CacheWrite: 2, Output: 4, Reasoning: 1, Millis: 1200, TTFT: 200, Status: 200, - ProviderKeyName: "PRIVATE-ACCOUNT", ProviderKeyID: "PRIVATE-KEY", Session: "PRIVATE-SESSION", Via: "PRIVATE-HOST"} + ProviderKeyName: "PRIVATE-ACCOUNT", ProviderKeyID: "PRIVATE-KEY", Session: "PRIVATE-SESSION", Via: "PRIVATE-HOST", + CallerKeyID: "PRIVATE-CALLER-KEY", CallerKeyName: "team-ci"} usage.Append(r) r.Error, r.ErrType = "PRIVATE-ERROR", "PRIVATE-ERROR-TYPE" usage.Append(r) // an error in a stream whose HTTP status is already 200 @@ -119,7 +120,7 @@ func TestOTelBatchWireAndPrivacy(t *testing.T) { for _, a := range spans[0].Attributes { values[a.Key] = a.Value["stringValue"] + a.Value["intValue"] } - if values["gen_ai.usage.input_tokens"] != "15" || values["gen_ai.usage.output_tokens"] != "4" || values["magpie.route.id"] != "42" || values["magpie.ttft_ms"] != "200" { + if values["gen_ai.usage.input_tokens"] != "15" || values["gen_ai.usage.output_tokens"] != "4" || values["magpie.route.id"] != "42" || values["magpie.ttft_ms"] != "200" || values["magpie.gateway_key.name"] != "team-ci" { t.Fatalf("attributes: %v", values) } var metrics struct { @@ -157,12 +158,18 @@ func TestOTelBatchWireAndPrivacy(t *testing.T) { if p.Count != "1" || p.Sum != 1.2 || len(p.Buckets) != len(p.Bounds)+1 { t.Errorf("point: %+v", p) } - errType := "" + errType, keyName := "", "" for _, a := range p.Attributes { - if a.Key == "error.type" { + switch a.Key { + case "error.type": errType = a.Value["stringValue"] + case "magpie.gateway_key.name": + keyName = a.Value["stringValue"] } } + if keyName != "team-ci" { + t.Errorf("point's gateway key name: %q, want team-ci", keyName) + } categories[errType]++ } if len(categories) != 3 || categories[""] != 1 || categories["stream_error"] != 1 || categories["502"] != 1 { diff --git a/internal/otlp/otel_wire.go b/internal/otlp/otel_wire.go index 316cb0a5d..6a117d911 100644 --- a/internal/otlp/otel_wire.go +++ b/internal/otlp/otel_wire.go @@ -25,16 +25,19 @@ func otelInt(key string, value int64) otelAttribute { return otelAttribute{key, map[string]any{"intValue": strconv.FormatInt(value, 10)}} } -// Only this allowlist leaves the machine: never record JSON, account/key -// names, session titles, raw errors, prompts, completions or tool arguments. -// The one exception is traces' input and output, sent only when the user -// turned bodies on (#538). +// Only this allowlist leaves the machine: never record JSON, provider +// account/key names, session titles, raw errors, prompts, completions or +// tool arguments. The one exception is traces' input and output, sent only +// when the user turned bodies on (#538). The gateway key a call came with +// goes by the name the user gave it (gatewayKeyAttr), never its id or +// secret. func otelAttributes(r Record) []otelAttribute { op := r.Operation if op == "" { op = "chat" } a := []otelAttribute{otelString("gen_ai.operation.name", op), otelString("gen_ai.provider.name", r.Provider), otelString("gen_ai.request.model", r.Model), otelString("magpie.agent", r.Agent)} + a = gatewayKeyAttr(a, r) if r.Served != "" { a = append(a, otelString("gen_ai.response.model", r.Served)) } @@ -48,6 +51,16 @@ func otelAttributes(r Record) []otelAttribute { return a } +// gatewayKeyAttr adds the name of the gateway key a call came with +// (Record.CallerKeyName) as magpie.gateway_key.name; a call without one +// has no such attribute. +func gatewayKeyAttr(a []otelAttribute, r Record) []otelAttribute { + if r.CallerKeyName == "" { + return a + } + return append(a, otelString("magpie.gateway_key.name", r.CallerKeyName)) +} + func otelEnvelope(signal string, data any) map[string]any { return map[string]any{"resource" + signal: []any{map[string]any{ "resource": map[string]any{"attributes": otelResourceAttributes()}, @@ -130,6 +143,7 @@ func (e *otelExporter) traces(items []otelItem) any { if sp.Root { span["name"], span["kind"] = "gateway "+r.Model, 2 a = []otelAttribute{otelString("magpie.agent", r.Agent), otelString("magpie.requested_model", r.Model), otelInt("http.response.status_code", int64(r.Status))} + a = gatewayKeyAttr(a, r) if r.RouteID != 0 { a = append(a, otelInt("magpie.route.id", r.RouteID)) } diff --git a/site/public/docs/ja/privacy.html b/site/public/docs/ja/privacy.html index 87afd2d91..2edbac631 100644 --- a/site/public/docs/ja/privacy.html +++ b/site/public/docs/ja/privacy.html @@ -196,7 +196,7 @@

モデルの価格と名前のために models.dev のカタログ(models.dev/api.json)を、あなたの通貨で価格を表示するために open.er-api.com から米ドルの為替レート(12 時間保持)を取得します。プラグインとその更新は npm レジストリから、ライブラリの項目は GitHub から取得します。どれも公開データの単なるダウンロードで、あなた、あなたのプロバイダー、使用量については何も送りません。ただし、どのリクエストとも同じく、これらのホストにはあなた(またはプロキシ)の IP アドレスが見えます。magpie は各プロバイダーにも、あなた自身のキーやサインインで残量とモデル一覧を尋ねます。設定 → 利用枠 → 利用枠の読み込み → 手動のみ で、頼んだときに限れます。

OTLP エクスポート

-

magpie はゲートウェイの各リクエストを、あなたの OpenTelemetry コレクター(Langfuse など)へエクスポートできます。既定ではオフで、送り先はあなたが設定したエンドポイントだけです。私たちには送りません。オンにすると、リクエストごとのスパン(エージェント、プロバイダー、モデル、トークン数、ステータス、時間、推定コスト)を送ります。別のスイッチで、メトリクス、ローカルのエージェント会話、リクエストと返答の本文(シークレットはマスク)を加えられます。設定 → オブザーバビリティ でオンにするか、magpie serve では MAGPIE_OTEL_ENABLED、MAGPIE_OTEL_ENDPOINT、MAGPIE_OTEL_HEADERS、MAGPIE_OTEL_METRICS、MAGPIE_OTEL_SESSIONS、MAGPIE_OTEL_BODIES、MAGPIE_OTEL_BODIES_WHOLE を使います。エンドポイントだけではオンになりません。Langfuse なら、そこで Langfuse を選び、ホストとプロジェクトの 2 つのキーを入力すると、magpie がエンドポイントと認証を作ります。各エクスポートの resource は service.name=magpie と、あなたが OTEL_RESOURCE_ATTRIBUTES と OTEL_SERVICE_NAME に自分で設定した値(サーバー名など)だけです。マシンの情報は調べません。詳しくはリファレンスを。

+

magpie はゲートウェイの各リクエストを、あなたの OpenTelemetry コレクター(Langfuse など)へエクスポートできます。既定ではオフで、送り先はあなたが設定したエンドポイントだけです。私たちには送りません。オンにすると、リクエストごとのスパン(エージェント、プロバイダー、モデル、リクエストに使われたゲートウェイキーの名前(あなたが付けた名前で、キーそのものは送りません)、トークン数、ステータス、時間、推定コスト)を送ります。別のスイッチで、メトリクス、ローカルのエージェント会話、リクエストと返答の本文(シークレットはマスク)を加えられます。設定 → オブザーバビリティ でオンにするか、magpie serve では MAGPIE_OTEL_ENABLED、MAGPIE_OTEL_ENDPOINT、MAGPIE_OTEL_HEADERS、MAGPIE_OTEL_METRICS、MAGPIE_OTEL_SESSIONS、MAGPIE_OTEL_BODIES、MAGPIE_OTEL_BODIES_WHOLE を使います。エンドポイントだけではオンになりません。Langfuse なら、そこで Langfuse を選び、ホストとプロジェクトの 2 つのキーを入力すると、magpie がエンドポイントと認証を作ります。各エクスポートの resource は service.name=magpie と、あなたが OTEL_RESOURCE_ATTRIBUTES と OTEL_SERVICE_NAME に自分で設定した値(サーバー名など)だけです。マシンの情報は調べません。詳しくはリファレンスを。

プロバイダに送る内容のマスク

ここまでの節は magpie が自分で送るものです。エージェントが送る内容は選んだプロバイダに届きますが、プライバシーマスクはその中の秘密をこのコンピュータに留めます。既定ではオフで、設定 → プライバシー でオンにします。

diff --git a/site/public/docs/privacy.html b/site/public/docs/privacy.html index fddb196d6..c4e38e82d 100644 --- a/site/public/docs/privacy.html +++ b/site/public/docs/privacy.html @@ -196,7 +196,7 @@

To price and name models magpie fetches the models.dev catalog (models.dev/api.json), and for prices in your currency the USD exchange rate from open.er-api.com (kept 12 hours). Plugins and their updates come from the npm registry, and the library’s items from GitHub. These are plain downloads of public data: nothing about you, your providers or your usage is sent, though, as with any request, those hosts see your IP address (or your proxy’s). magpie also asks each of your providers for your allowance and model list, with your own key or sign-in; Settings → Allowances → Allowance reads → When I ask limits those to when you ask.

OTLP export

-

magpie can export each gateway request to an OpenTelemetry collector of yours (Langfuse, for example). It is off by default, and goes only to the endpoint you set, never to us. When on, it sends per-request spans: agent, provider, model, token counts, status, timing and estimated cost. Optional switches add metrics, local agent conversations, and the request and reply bodies (secrets masked). Turn it on in Settings → Observability, or for magpie serve with MAGPIE_OTEL_ENABLED, MAGPIE_OTEL_ENDPOINT, MAGPIE_OTEL_HEADERS, MAGPIE_OTEL_METRICS, MAGPIE_OTEL_SESSIONS, MAGPIE_OTEL_BODIES and MAGPIE_OTEL_BODIES_WHOLE. An endpoint alone doesn’t turn it on. For Langfuse, pick Langfuse there and give its host and your project’s two keys; magpie makes the endpoint and sign-in from them. Each export’s resource is service.name=magpie, plus only what you set yourself in OTEL_RESOURCE_ATTRIBUTES and OTEL_SERVICE_NAME (a server name, for example); nothing about your machine is looked up. The reference has the details.

+

magpie can export each gateway request to an OpenTelemetry collector of yours (Langfuse, for example). It is off by default, and goes only to the endpoint you set, never to us. When on, it sends per-request spans: agent, provider, model, the name you gave the gateway key it came with (never the key itself), token counts, status, timing and estimated cost. Optional switches add metrics, local agent conversations, and the request and reply bodies (secrets masked). Turn it on in Settings → Observability, or for magpie serve with MAGPIE_OTEL_ENABLED, MAGPIE_OTEL_ENDPOINT, MAGPIE_OTEL_HEADERS, MAGPIE_OTEL_METRICS, MAGPIE_OTEL_SESSIONS, MAGPIE_OTEL_BODIES and MAGPIE_OTEL_BODIES_WHOLE. An endpoint alone doesn’t turn it on. For Langfuse, pick Langfuse there and give its host and your project’s two keys; magpie makes the endpoint and sign-in from them. Each export’s resource is service.name=magpie, plus only what you set yourself in OTEL_RESOURCE_ATTRIBUTES and OTEL_SERVICE_NAME (a server name, for example); nothing about your machine is looked up. The reference has the details.

Masking what goes to providers

The sections above are what magpie sends by itself. What your agents send goes to the providers you chose, and privacy masking keeps the secrets in it on this computer. It is off by default; turn it on in Settings → Privacy.

diff --git a/site/public/docs/zh/privacy.html b/site/public/docs/zh/privacy.html index f782e15b3..bde31451e 100644 --- a/site/public/docs/zh/privacy.html +++ b/site/public/docs/zh/privacy.html @@ -196,7 +196,7 @@

为了给模型定价和命名,magpie 会拉取 models.dev 的模型目录(models.dev/api.json);为了用你的货币显示价格,会从 open.er-api.com 拉取美元汇率(缓存 12 小时)。插件及其更新来自 npm 仓库,库里的内容来自 GitHub。这些都是公开数据的普通下载,不发送任何关于你、你的供应商或用量的信息;和任何请求一样,这些主机能看到你的 IP(或代理的 IP)。magpie 还会用你自己的密钥或登录向各个供应商读取额度和模型列表;设置 → 额度 → 额度刷新 → 仅手动 可以只在你要求时才读。

OTLP 导出

-

magpie 可以把每个网关请求导出到你自己的 OpenTelemetry 收集器(比如 Langfuse)。它默认关闭,只发到你设置的地址,从不发给我们。开启后发送每个请求的 span:agent、供应商、模型、token 数、状态、耗时和估算费用。另有开关可以加上指标、本地 agent 对话,以及请求和回复正文(密钥已遮盖)。在 设置 → 可观测性 里开启,magpie serve 也可以用 MAGPIE_OTEL_ENABLED、MAGPIE_OTEL_ENDPOINT、MAGPIE_OTEL_HEADERS、MAGPIE_OTEL_METRICS、MAGPIE_OTEL_SESSIONS、MAGPIE_OTEL_BODIES 和 MAGPIE_OTEL_BODIES_WHOLE。只设地址不会开启导出。用 Langfuse 的话,在那里选 Langfuse,填上地址和项目的两个密钥,magpie 会据此生成地址和认证头。每次导出的 resource 是 service.name=magpie,再加上你自己在 OTEL_RESOURCE_ATTRIBUTES 和 OTEL_SERVICE_NAME 里设置的值(比如服务器名),不会读取你机器上的任何信息。细节见参考文档。

+

magpie 可以把每个网关请求导出到你自己的 OpenTelemetry 收集器(比如 Langfuse)。它默认关闭,只发到你设置的地址,从不发给我们。开启后发送每个请求的 span:agent、供应商、模型、请求所用网关密钥的名称(你起的名字,从不发送密钥本身)、token 数、状态、耗时和估算费用。另有开关可以加上指标、本地 agent 对话,以及请求和回复正文(密钥已遮盖)。在 设置 → 可观测性 里开启,magpie serve 也可以用 MAGPIE_OTEL_ENABLED、MAGPIE_OTEL_ENDPOINT、MAGPIE_OTEL_HEADERS、MAGPIE_OTEL_METRICS、MAGPIE_OTEL_SESSIONS、MAGPIE_OTEL_BODIES 和 MAGPIE_OTEL_BODIES_WHOLE。只设地址不会开启导出。用 Langfuse 的话,在那里选 Langfuse,填上地址和项目的两个密钥,magpie 会据此生成地址和认证头。每次导出的 resource 是 service.name=magpie,再加上你自己在 OTEL_RESOURCE_ATTRIBUTES 和 OTEL_SERVICE_NAME 里设置的值(比如服务器名),不会读取你机器上的任何信息。细节见参考文档。

发给供应商的内容脱敏

上面几节讲的是 magpie 自己发出的东西。你的 Agent 发出的内容会去往你选的供应商,隐私脱敏让其中的密钥留在这台电脑上。它默认关闭,在 设置 → 隐私 里打开。