zuplo 7.15.0 → 7.15.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt CHANGED
@@ -1,80 +1,7 @@
1
- # End User License Agreement (EULA)
1
+ Copyright (c) Zuplo, Inc. All rights reserved.
2
2
 
3
- This End User License Agreement ("Agreement") is a legal agreement between you
4
- ("User") and **Zuplo, Inc.**, a Delaware corporation ("Zuplo"), governing the
5
- use of Zuplo’s proprietary software tool designed for local development (the
6
- "Software").
3
+ Use of this software is governed by the Zuplo Terms of Service at
4
+ https://zuplo.com/legal/terms, or by a separate agreement your company has
5
+ signed with Zuplo.
7
6
 
8
- By installing, copying, or otherwise using the Software, you agree to be bound
9
- by the terms of this Agreement. If you do not agree, do not install or use the
10
- Software.
11
-
12
- ## 1. License Grant
13
-
14
- Subject to the terms of this Agreement, Zuplo grants you a limited,
15
- non-exclusive, non-transferable, non-sublicensable license to use the Software
16
- **solely for internal local development purposes** and **only if you are an
17
- active customer of Zuplo**.
18
-
19
- ## 2. Restrictions
20
-
21
- You may **not**:
22
-
23
- - Distribute, sublicense, lease, rent, or otherwise make the Software available
24
- to any third party;
25
- - Use the Software for any commercial purpose other than in connection with your
26
- authorized use of Zuplo services;
27
- - Reverse engineer, decompile, disassemble, or attempt to derive the source code
28
- of the Software;
29
- - Use the Software if you are not a current customer of Zuplo.
30
-
31
- ## 3. Intellectual Property Ownership
32
-
33
- All intellectual property rights in and to the Software — including but not
34
- limited to all code, documentation, interfaces, design, and trademarks — are and
35
- shall remain the exclusive property of Zuplo and its licensors.
36
- This Agreement does not grant you any rights, title, or interest in or to any
37
- trademarks, trade secrets, copyrights, patents, or other intellectual property
38
- owned by Zuplo, except for the limited license expressly set forth in Section 1.
39
-
40
- Any feedback, suggestions, or improvements you provide regarding the Software
41
- may be freely used by Zuplo without any obligation to you.
42
-
43
- ## 4. Open Source Software Notice
44
-
45
- The Software may include or rely on components that are subject to separate open
46
- source licenses. These components are not governed by this Agreement but instead
47
- by their respective licenses.
48
-
49
- Copies of the applicable open source licenses are provided in the distribution
50
- of the Software.
51
-
52
- ## 5. Termination
53
-
54
- This license is effective until terminated. It will automatically terminate
55
- without notice if you cease to be a customer of Zuplo or fail to comply with any
56
- term of this Agreement. Upon termination, you must immediately cease all use of
57
- the Software and destroy all copies.
58
-
59
- ## 6. No Warranty
60
-
61
- The Software is provided "**as is**," without warranty of any kind, express or
62
- implied, including but not limited to the implied warranties of merchantability
63
- or fitness for a particular purpose.
64
-
65
- ## 7. Limitation of Liability
66
-
67
- In no event shall Zuplo be liable for any indirect, incidental, special, or
68
- consequential damages, or damages for loss of profits, revenue, data, or use,
69
- incurred by you or any third party, whether in an action in contract or tort,
70
- arising from your use of the Software.
71
-
72
- ## 8. Governing Law
73
-
74
- This Agreement is governed by and construed in accordance with the laws of the
75
- State of Delaware, without regard to its conflict of law principles.
76
-
77
- ## 9. Entire Agreement
78
-
79
- This Agreement constitutes the entire agreement between the parties with respect
80
- to the Software and supersedes all prior or contemporaneous understandings.
7
+ See https://zuplo.com/legal/eula for more information.
package/README.md CHANGED
@@ -20,3 +20,20 @@ This package includes offline documentation and policy reference content in the
20
20
  ```
21
21
  node_modules/zuplo/docs/
22
22
  ```
23
+
24
+ ## Usage data
25
+
26
+ The Zuplo CLI included in this package sends usage data and error reports to
27
+ Zuplo. Usage data includes the command you run, your Zuplo user ID (or, when you
28
+ aren't logged in, an identifier derived from your machine), the account and
29
+ project names you pass, whether it runs in CI, and your Node.js version,
30
+ operating system, CPU architecture, and package manager. To turn this off, set
31
+ `ZUPLO_DO_NOT_TRACK=1`. For how Zuplo handles this data, see the
32
+ [Zuplo Privacy Policy](https://zuplo.com/legal/privacy-policy).
33
+
34
+ ## License
35
+
36
+ Copyright (c) Zuplo, Inc. All rights reserved. Use of this package is governed
37
+ by the [Zuplo Terms of Service](https://zuplo.com/legal/terms), or by a separate
38
+ agreement your company has signed with Zuplo. See `LICENSE.txt` and
39
+ [zuplo.com/legal/eula](https://zuplo.com/legal/eula).
@@ -53,16 +53,16 @@ bodies. How long Zuplo keeps them depends on your plan. See
53
53
  These features handle prompt or completion text when you turn them on. Each one
54
54
  is off until you add it.
55
55
 
56
- | Feature | Content it handles | Where the content goes |
57
- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
58
- | [Semantic Cache](../../policies/ai-gateway-semantic-cache-inbound.mdx) | The system prompt and the most recent messages, which form the match key, and the provider's response. | Zuplo's semantic cache, which keeps each app's entries apart. Entries expire after `expirationSecondsTtl` seconds: one hour by default, up to 30 days. |
59
- | [Comet Opik Tracing](../../policies/ai-gateway-opik-tracing-inbound.mdx) | Prompt messages or input, completion text, model, token counts, temperature and maximum tokens, request ID, and route. | Your Comet Opik workspace and project. |
60
- | [Galileo Tracing](../../policies/ai-gateway-galileo-tracing-inbound.mdx) | Prompt and completion text, model parameters, finish reasons, token counts, duration, request ID, and route. | Your Galileo project and log stream. |
61
- | [Akamai AI Firewall](../../policies/ai-gateway-akamai-firewall-inbound.mdx) | Prompts and completions, for inspection. | Akamai Firewall for AI. |
62
- | [Prompt Injection Protection](../../policies/ai-gateway-prompt-injection.mdx) | The newest message of each request, for classification. | The classifier you configure: an OpenAI-compatible API, or another app on the same gateway and its provider. |
63
- | [Smart Router](../../policies/ai-gateway-smart-router-inbound.mdx) | The last user prompt, for classification. | The classifier you configure, such as another app on the same gateway and its provider. |
64
- | [Log plugins](../../articles/logging.mdx#log-integrations) | The request logs described earlier and messages that policies write with `context.log`. Content appears only if a custom policy logs it. | Your logging service, such as Datadog, Splunk, or AWS CloudWatch. |
65
- | [OpenTelemetry plugin](./tracing.mdx) | Span timings, HTTP method, URL, status code, and request ID. No prompt or completion text. | Zuplo's trace storage or your OpenTelemetry backend. |
56
+ | Feature | Content it handles | Where the content goes |
57
+ | ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
58
+ | [Semantic Cache](../../policies/ai-gateway-semantic-cache-inbound.mdx) | The system prompt and the most recent messages, which form the match key, and the provider's response. | Zuplo's semantic cache, which keeps each app's entries apart. Entries expire after `expirationSecondsTtl` seconds: one hour by default, up to 30 days. |
59
+ | [Comet Opik Tracing](../../policies/ai-gateway-opik-tracing-inbound.mdx) | Prompt messages or input, completion text, model, token counts, temperature and maximum tokens, request ID, and route. | Your Comet Opik workspace and project. |
60
+ | [Galileo Tracing](../../policies/ai-gateway-galileo-tracing-inbound.mdx) | Prompt and completion text, model parameters, finish reasons, token counts, duration, request ID, and route. | Your Galileo project and log stream. |
61
+ | [Akamai AI Firewall](../../policies/ai-gateway-akamai-firewall-inbound.mdx) | Prompts and completions, for inspection. | Akamai Firewall for AI. |
62
+ | [Prompt Injection Protection](../../policies/ai-gateway-prompt-injection.mdx) | The newest message of each request, for classification. | The classifier you configure: an OpenAI-compatible API, or another app on the same gateway and its provider. |
63
+ | [Smart Router](../../policies/ai-gateway-smart-router-inbound.mdx) | The last user prompt, for classification. | The classifier you configure, such as another app on the same gateway and its provider. |
64
+ | [Log plugins](../../articles/logging.mdx#log-integrations) | The request logs described earlier and messages that policies write with `context.log`. Content appears only if a custom policy logs it. | Your logging service, such as Datadog, Splunk, or AWS CloudWatch. |
65
+ | [OpenTelemetry plugin](./tracing.mdx) | Span timings, HTTP method, URL, status code, request ID, model, token usage, and cost. Prompt and completion text only when you turn on content capture. | Zuplo's trace storage or your OpenTelemetry backend. |
66
66
 
67
67
  The [Data Loss Prevention](../../policies/ai-gateway-dlp-inbound.mdx) policy
68
68
  scans content inside the gateway and doesn't send it to another service.
@@ -1,10 +1,10 @@
1
1
  ---
2
- title: AI Gateway Tracing
2
+ title: AI Gateway OpenTelemetry Tracing
3
3
  sidebar_label: Tracing
4
4
  description:
5
- Add the OpenTelemetry plugin to an AI Gateway to trace each request through
6
- its policies and provider call, and join model calls and tool calls in a
7
- trace.
5
+ Trace AI Gateway requests with OpenTelemetry GenAI spans that record model,
6
+ provider, token usage, cost, fallbacks, and optional prompt and completion
7
+ content.
8
8
  applies_to:
9
9
  product: gateway
10
10
  hosting: all
@@ -13,10 +13,11 @@ applies_to:
13
13
  An AI Gateway runs the same
14
14
  [OpenTelemetry plugin](../../articles/opentelemetry.mdx) as any Zuplo project.
15
15
  With the plugin on, each request to an app becomes a trace with a span for every
16
- policy in the app's chain, the AI Gateway handler, and the call to the LLM
17
- provider. The gateway reads W3C trace context (`traceparent`) from the caller
18
- and sends it on to the provider, so an agent's model calls join the agent's own
19
- trace.
16
+ policy in the app's chain, the AI Gateway handler, and every call to an LLM
17
+ provider. Provider calls are recorded as OpenTelemetry GenAI spans that carry
18
+ the model, token usage, cost, and outcome of each attempt. The gateway reads W3C
19
+ trace context (`traceparent`) from the caller and sends it on to the provider,
20
+ so an agent's model calls join the agent's own trace.
20
21
 
21
22
  <Diagram height="h-64">
22
23
  <DiagramNode id="agent">Agent</DiagramNode>
@@ -108,11 +109,12 @@ to change it.
108
109
  ## What a trace contains
109
110
 
110
111
  A request to an app produces a trace like the following. The app's policy chain
111
- appears inside the Configuration Executor span, one span per entry, and the call
112
- to the provider is a client span named after the provider's host:
112
+ appears inside the Configuration Executor span, one span per entry. Each call to
113
+ an LLM provider gets a GenAI inference span, with the HTTP call to the
114
+ provider's host nested under it:
113
115
 
114
116
  ```text
115
- POST <route>
117
+ POST <route> gen_ai.request.model, zuplo.ai_gateway.*
116
118
  ├── policies:inbound
117
119
  │ ├── policy:ai-gateway-configuration-loader-inbound
118
120
  │ └── policy:ai-gateway-configuration-executor-inbound
@@ -121,16 +123,203 @@ POST <route>
121
123
  │ ├── policy:ai-gateway-metering-inbound
122
124
  │ └── policy:ai-gateway-semantic-cache-inbound
123
125
  └── handler:aiGatewayHandlerV2
124
- └── POST: api.openai.com
126
+ └── chat gpt-5 gen_ai.*, zuplo.ai_gateway.cost.*
127
+ └── POST: api.openai.com
125
128
  ```
126
129
 
127
- Spans carry timings, the HTTP method, URL, and status code, and the request ID
128
- (`zp-rid`) that also appears in the gateway's logs. They don't carry prompt or
129
- completion text. To record content for evaluation, see
130
+ Every span carries timings and the request ID (`zp-rid`) that also appears in
131
+ the gateway's logs. HTTP spans add the method, URL, and status code. Prompt and
132
+ completion text is recorded only when you
133
+ [turn on content capture](#capture-prompts-and-completions).
134
+
135
+ ## GenAI inference spans
136
+
137
+ The gateway records one inference span for each attempt to call a provider: the
138
+ primary call, each [fallback](../fallback.mdx), a
139
+ [quota fallback](../usage-limits.mdx#when-a-limit-is-exceeded) after a usage
140
+ limit is exceeded, and each retry after a provider returns `429`. The spans
141
+ follow the
142
+ [OpenTelemetry semantic conventions for generative AI](https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/),
143
+ so backends that understand GenAI telemetry, such as Langfuse, Datadog LLM
144
+ Observability, Honeycomb, and Grafana, show model, token, and cost views without
145
+ any mapping.
146
+
147
+ There's nothing extra to enable. With the OpenTelemetry plugin registered,
148
+ inference spans appear for every sampled request. All of them use the
149
+ instrumentation scope `ai-gateway`.
150
+
151
+ ### Span names and kinds
152
+
153
+ Each inference span is a `CLIENT` span named `{operation} {model}`, for example
154
+ `chat gpt-5` or `embeddings text-embedding-3-small`. The operation comes from
155
+ the endpoint the client called:
156
+
157
+ | Endpoint | `gen_ai.operation.name` |
158
+ | ------------------------------------------------- | ----------------------- |
159
+ | `/v1/chat/completions`, `/v1/messages` | `chat` |
160
+ | `POST /v1/responses` | `chat` |
161
+ | `GET /v1/responses/{id}` | `fetch_response` |
162
+ | `DELETE /v1/responses/{id}` | `delete_response` |
163
+ | `/v1/messages/count_tokens` | `count_tokens` |
164
+ | `/v1/embeddings` | `embeddings` |
165
+ | Bedrock Runtime `converse` and `invoke` endpoints | `chat` |
166
+
167
+ A request that never reaches a provider, such as one a policy rejects or one
168
+ that fails validation, has no inference span. A semantic cache hit has none
169
+ either, because the gateway answers from the cache.
170
+
171
+ ### Inference span attributes
172
+
173
+ | Attribute | Description |
174
+ | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
175
+ | `gen_ai.operation.name` | The operation, from the table above. |
176
+ | `gen_ai.provider.name` | The provider, for example `openai`, `anthropic`, `gcp.vertex_ai`, `aws.bedrock`, or `azure.ai.openai`. |
177
+ | `zuplo.ai_gateway.provider.label` | The name of the provider in your gateway's **AI Providers** settings. |
178
+ | `gen_ai.request.model` | The model sent to the provider. |
179
+ | `gen_ai.request.stream` | `true` for a streamed request, otherwise `false`. |
180
+ | `gen_ai.request.max_tokens`, `temperature`, `top_p`, `top_k`, `seed`, and others | Sampling parameters, when the request sets them. |
181
+ | `gen_ai.response.id` | The provider's response ID. |
182
+ | `gen_ai.response.model` | The model that answered, as the provider reported it. |
183
+ | `gen_ai.response.finish_reasons` | The provider's own finish reasons, for example `["stop"]` or `["end_turn"]`. |
184
+ | `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens` | Token usage. Matches the usage that [AI Gateway analytics](./analytics.mdx) and usage limits record. |
185
+ | `gen_ai.usage.cache_read.input_tokens`, `gen_ai.usage.cache_write.input_tokens` | Prompt cache tokens, when the provider reports them. |
186
+ | `gen_ai.usage.reasoning.output_tokens` | Reasoning tokens, when the provider reports them. |
187
+ | `zuplo.ai_gateway.cost.usd` | The cost of the attempt in US dollars. |
188
+ | `zuplo.ai_gateway.cost.source` | Where the cost came from: `provider`, `catalog`, or `unpriced`. |
189
+ | `zuplo.ai_gateway.cost.accuracy` | `exact`, `estimated`, or `unpriced`. |
190
+ | `zuplo.ai_gateway.attempt` | `primary`, `fallback`, `quota_fallback`, or `retry` (a retry after a `429`). |
191
+ | `server.address`, `server.port` | The provider host. |
192
+ | `error.type` | Set on a failed attempt. See [Errors and fallbacks](#errors-and-fallbacks). |
193
+
194
+ Cost uses the same prices as budgets and spend analytics, including any
195
+ [custom pricing](../custom-pricing.mdx) you set.
196
+
197
+ ### Request span attributes
198
+
199
+ The request's root `SERVER` span summarizes what the gateway did with the
200
+ request:
201
+
202
+ | Attribute | Description |
203
+ | --------------------------------- | -------------------------------------------------------------------------------------------------------------- |
204
+ | `gen_ai.request.model` | The model the client asked for, before any routing or fallback policy changed it. |
205
+ | `zuplo.ai_gateway.cache.status` | `hit` or `miss`, when the app uses the [semantic cache](../../policies/ai-gateway-semantic-cache-inbound.mdx). |
206
+ | `zuplo.ai_gateway.refused_by` | The name of the policy that rejected the request, or `handler` when the gateway's handler rejected it. |
207
+ | `zuplo.ai_gateway.quota_fallback` | `true` when a usage limit sent the request to its quota fallback model. |
208
+
209
+ ### Errors and fallbacks
210
+
211
+ A failed attempt sets the span status to error and records a low-cardinality
212
+ `error.type`:
213
+
214
+ - The provider's HTTP status code, for example `503` or `429`.
215
+ - `timeout` when the attempt hit the fallback timeout.
216
+ - The error name, for example `TypeError`, when the call threw before a response
217
+ arrived.
218
+
219
+ The provider's error message isn't recorded, because it can quote the request.
220
+
221
+ Attempts for one request are siblings under the handler span. A request whose
222
+ primary model returns `503` and whose fallback succeeds looks like this:
223
+
224
+ ```text
225
+ handler:aiGatewayHandlerV2
226
+ ├── chat gpt-5 error.type=503, zuplo.ai_gateway.attempt=primary
227
+ │ └── POST: api.openai.com
228
+ └── chat claude-sonnet-4-5 zuplo.ai_gateway.attempt=fallback, usage, cost
229
+ └── POST: api.anthropic.com
230
+ ```
231
+
232
+ ### Streaming responses
233
+
234
+ For a streamed response, the HTTP span ends when the provider starts streaming,
235
+ and the inference span stays open until the stream finishes. The inference span
236
+ records:
237
+
238
+ - `gen_ai.response.time_to_first_chunk`: seconds from sending the request to the
239
+ first chunk of the stream.
240
+ - `zuplo.ai_gateway.stream.end`: `complete`, `error` (including an error event
241
+ inside the stream), or `client_cancelled` when the client disconnected first.
242
+ - Token usage and cost, read from the finished stream.
243
+
244
+ The plugin waits for an open inference span before it exports the trace, up to
245
+ five minutes after the response starts, so long streams export complete.
246
+
247
+ ## Capture prompts and completions
248
+
249
+ Inference spans don't record prompt or completion text by default. To record it,
250
+ set `instrumentation.genAi.captureContent` to `true`:
251
+
252
+ ```ts title="modules/zuplo.runtime.ts"
253
+ runtime.addPlugin(
254
+ new OpenTelemetryPlugin({
255
+ exporter: {
256
+ url: environment.OTEL_TRACES_URL,
257
+ headers: { "api-key": environment.OTEL_API_KEY },
258
+ },
259
+ instrumentation: {
260
+ genAi: { captureContent: true },
261
+ },
262
+ }),
263
+ );
264
+ ```
265
+
266
+ With capture on, each inference span records these attributes as JSON in the
267
+ OpenTelemetry GenAI message format:
268
+
269
+ - `gen_ai.system_instructions`: the system prompt.
270
+ - `gen_ai.input.messages`: the messages sent to the provider. Embeddings
271
+ requests don't record input.
272
+ - `gen_ai.output.messages`: the response the client received, including a
273
+ streamed response.
274
+
275
+ Each attribute is capped at 8 KiB and stays valid JSON when it's truncated. The
276
+ plugin turns capture on only for the boolean `true`.
277
+
278
+ Input is recorded as sent to the provider, after policies such as
279
+ [Data Loss Prevention](../../policies/ai-gateway-dlp-inbound.mdx) changed it.
280
+ Output is recorded as returned to the client, after every policy and hook that
281
+ changes the response. Well-known credential formats, such as API keys, bearer
282
+ tokens, JWTs, private keys, and cloud and GitHub tokens, are replaced with
283
+ placeholders such as `[REDACTED:api_key]`.
284
+
285
+ :::warning
286
+
287
+ Prompts and completions often contain personal or otherwise sensitive data.
288
+ Turning on content capture sends that content to Zuplo's trace storage and to
289
+ any backend you export to. Content capture doesn't remove personal data, so mask
290
+ it with the Data Loss Prevention policy, which runs before the content is
291
+ recorded.
292
+
293
+ :::
294
+
295
+ To capture content for a single app instead of the whole gateway, use a tracing
296
+ policy. See
130
297
  [AI Gateway data handling](./data-handling.mdx#capture-prompts-and-completions-for-an-app).
131
298
 
132
- For a streaming response, the provider span ends when the provider starts
133
- streaming, so it shows the provider's time to first byte.
299
+ ## Query GenAI spans in your backend
300
+
301
+ Because the attributes follow the semantic conventions, you can query model
302
+ activity directly in your backend. For example:
303
+
304
+ - Compare models by latency: filter on `gen_ai.operation.name = chat` and group
305
+ span duration by `gen_ai.response.model`.
306
+ - Find spend by provider: sum `zuplo.ai_gateway.cost.usd` grouped by
307
+ `zuplo.ai_gateway.provider.label`.
308
+ - Find failing providers: filter on `error.type` and group by
309
+ `gen_ai.provider.name`.
310
+ - See how often fallbacks serve traffic: count spans where
311
+ `zuplo.ai_gateway.attempt` is `fallback` or `quota_fallback`.
312
+ - Measure time to first token: chart `gen_ai.response.time_to_first_chunk` for
313
+ streamed requests.
314
+ - Find rejected requests: filter request spans on `zuplo.ai_gateway.refused_by`.
315
+
316
+ :::note
317
+
318
+ The OpenTelemetry plugin exports traces and logs, not metrics. Use span
319
+ durations and attributes to measure latency and usage, or see
320
+ [AI Gateway analytics](./analytics.mdx) for built-in dashboards.
321
+
322
+ :::
134
323
 
135
324
  ## Follow an agent run across gateways
136
325
 
@@ -90,4 +90,3 @@ builds and deploys the reverted branch like any other change.
90
90
  - [Environments](./environments.mdx)
91
91
  - [Branch-Based Deployments](./branch-based-deployments.mdx)
92
92
  - [Source Control and Deployment](../concepts/source-control-and-deployment.mdx)
93
- - [Blue-Green Deployments for Your Backend](../guides/blue-green-deployments.mdx)
@@ -40,6 +40,9 @@ By default, when the OpenTelemetry plugin is enabled, the following is traced:
40
40
  [MCP Gateway](../mcp-gateway/overview.mdx) handles gets a span that follows
41
41
  the OpenTelemetry semantic conventions for MCP. See
42
42
  [MCP tracing](#mcp-tracing).
43
+ - AI Gateway calls: Every call the AI Gateway makes to an LLM provider gets a
44
+ GenAI inference span with the model, token usage, and cost. See
45
+ [AI Gateway tracing](../ai-gateway/observability/tracing.mdx).
43
46
 
44
47
  ### Limitations
45
48
 
@@ -105,7 +105,7 @@ deployment type.
105
105
  ```json
106
106
  {
107
107
  "version": 1,
108
- "compatibilityDate": "2025-02-06",
108
+ "compatibilityDate": "2026-11-06",
109
109
  "projectType": "managed-edge"
110
110
  }
111
111
  ```
@@ -112,6 +112,5 @@ hides it from your users. See
112
112
 
113
113
  ## Next steps
114
114
 
115
- - [Blue-Green Deployments for Your Backend](./blue-green-deployments.mdx)
116
115
  - [Route to Different Backends Based on Geolocation](./geolocation-backend-routing.mdx)
117
116
  - [Securing your backend](../articles/securing-your-backend.mdx)
@@ -109,6 +109,37 @@ as Entra tenant admin consent. If connections start requiring frequent
109
109
  reauthorization after setting `prompt: false`, remove the option so the consent
110
110
  grant is requested again.
111
111
 
112
+ ## Extra Authorization Parameters
113
+
114
+ `authorizationParams` adds query parameters to the upstream authorization
115
+ request, for providers that need a parameter the MCP authorization flow does not
116
+ send. A configured value replaces any parameter of the same name. It supports
117
+ `user-oauth` and `shared-oauth`.
118
+
119
+ Google is the common case. Google issues a refresh token only when the
120
+ authorization request carries `access_type=offline`, and it does not advertise
121
+ the `offline_access` scope, so the MCP SDK never asks for one on its own.
122
+ Without it, every Google connection lasts only as long as its one-hour access
123
+ token and then needs a new sign-in. Set `access_type` to `offline` and `prompt`
124
+ to `consent`: Google returns a refresh token only on a fresh consent, so users
125
+ who approved the app before would otherwise still get none.
126
+
127
+ ```json
128
+ {
129
+ "authMode": "user-oauth",
130
+ "scopes": ["https://www.googleapis.com/auth/gmail.modify"],
131
+ "prompt": "consent",
132
+ "authorizationParams": {
133
+ "access_type": "offline"
134
+ }
135
+ }
136
+ ```
137
+
138
+ `authorizationParams` cannot set parameters the gateway manages:
139
+ `response_type`, `response_mode`, `client_id`, `redirect_uri`, `scope`, `state`,
140
+ `code_challenge`, `code_challenge_method`, and `resource`. Use the `scopes`
141
+ option for scopes and the `prompt` option for `prompt`.
142
+
112
143
  ## OAuth Metadata Validation
113
144
 
114
145
  The gateway checks OAuth metadata before connecting to an upstream. If a
@@ -197,9 +228,9 @@ Use this mode in enterprise deployments where the gateway and the upstream trust
197
228
  the same identity provider (for example, Okta Cross-App Access), so upstream
198
229
  access follows the caller's identity without a per-user upstream consent flow.
199
230
  The `user-oauth`/`shared-oauth` options — `scopes`, `scopeDelimiter`, `prompt`,
200
- `skipIssuerMetadataValidation`, `skipResourceIndicatorValidation`, and
201
- `clientRegistration` — do not apply; the `id-jag` mode is configured entirely
202
- through the `idJag` option.
231
+ `authorizationParams`, `skipIssuerMetadataValidation`,
232
+ `skipResourceIndicatorValidation`, and `clientRegistration` — do not apply; the
233
+ `id-jag` mode is configured entirely through the `idJag` option.
203
234
 
204
235
  ```json
205
236
  {
@@ -56,6 +56,9 @@
56
56
  {
57
57
  "required": ["prompt"]
58
58
  },
59
+ {
60
+ "required": ["authorizationParams"]
61
+ },
59
62
  {
60
63
  "required": ["skipIssuerMetadataValidation"]
61
64
  },
@@ -126,6 +129,31 @@
126
129
  }
127
130
  ]
128
131
  },
132
+ "authorizationParams": {
133
+ "type": "object",
134
+ "x-advanced": true,
135
+ "description": "Extra query parameters added to upstream authorization requests, for providers that need a parameter the MCP authorization flow does not send. For example, Google issues a refresh token only when the request carries `access_type=offline`, so Google upstreams set `{ \"access_type\": \"offline\" }`, usually with `prompt: \"consent\"`. A value replaces any parameter of the same name. Parameters the gateway manages cannot be set here: `response_type`, `response_mode`, `client_id`, `redirect_uri`, `scope`, `state`, `code_challenge`, `code_challenge_method`, `resource`, and `prompt` (use the `prompt` option). Available only with `user-oauth` and `shared-oauth`.",
136
+ "propertyNames": {
137
+ "minLength": 1,
138
+ "not": {
139
+ "enum": [
140
+ "response_type",
141
+ "response_mode",
142
+ "client_id",
143
+ "redirect_uri",
144
+ "scope",
145
+ "state",
146
+ "code_challenge",
147
+ "code_challenge_method",
148
+ "resource",
149
+ "prompt"
150
+ ]
151
+ }
152
+ },
153
+ "additionalProperties": {
154
+ "type": "string"
155
+ }
156
+ },
129
157
  "skipIssuerMetadataValidation": {
130
158
  "type": "boolean",
131
159
  "x-advanced": true,
@@ -19,7 +19,8 @@ file, see the [Zuplo Project Configuration](./zuplo-json.mdx) documentation.
19
19
 
20
20
  :::note
21
21
 
22
- New projects don't use this compatibility date by default. To adopt it, set
22
+ This compatibility date is the default for new projects. Existing projects keep
23
+ the date set in their `zuplo.jsonc`. To adopt it in an existing project, set
23
24
  `"compatibilityDate": "2026-11-06"` in `zuplo.jsonc`, then test the change in a
24
25
  preview environment before you deploy to production. For examples and migration
25
26
  steps for each change, see the
@@ -277,9 +278,9 @@ operation's `operationId`.
277
278
 
278
279
  :::note
279
280
 
280
- This compatibility date is the default for projects created after March
281
- 1st, 2026. Existing projects should update their `zuplo.jsonc` to take advantage
282
- of this change.
281
+ This compatibility date was the default for projects created after March 1st,
282
+ 2026, until `2026-11-06` became the default. Existing projects should update
283
+ their `zuplo.jsonc` to take advantage of this change.
283
284
 
284
285
  :::
285
286
 
@@ -184,6 +184,9 @@ context.log.info("User login", {
184
184
  });
185
185
  ```
186
186
 
187
+ To redact sensitive values from every log entry, including logs your code
188
+ doesn't control, register a [telemetry redactor](./telemetry-redaction.mdx).
189
+
187
190
  ### 4. Use Structured Data for Better Querying
188
191
 
189
192
  ```ts
@@ -322,6 +322,20 @@ export function runtimeInit(runtime: RuntimeExtensions) {
322
322
  }
323
323
  ```
324
324
 
325
+ ## Telemetry Redaction
326
+
327
+ Use `runtime.addTelemetryRedactor` to remove sensitive data from logs, traces,
328
+ analytics, and audit events before Zuplo records them. See
329
+ [Redact sensitive data from telemetry](./telemetry-redaction.mdx).
330
+
331
+ ```ts
332
+ import { RuntimeExtensions, createRedactor } from "@zuplo/runtime";
333
+
334
+ export function runtimeInit(runtime: RuntimeExtensions) {
335
+ runtime.addTelemetryRedactor(createRedactor({ entities: ["pii", "secret"] }));
336
+ }
337
+ ```
338
+
325
339
  ## Plugin and Handler Extensions
326
340
 
327
341
  Built-in and custom plugins and handlers can expose their own extensibility. For
@@ -0,0 +1,308 @@
1
+ ---
2
+ title: Redact Sensitive Data from Telemetry
3
+ sidebar_label: Telemetry Redaction
4
+ applies_to:
5
+ product: gateway
6
+ hosting: all
7
+ ---
8
+
9
+ Requests that pass through your gateway can carry sensitive data such as card
10
+ numbers, government IDs, and health data. Zuplo records values from each request
11
+ in logs, traces, analytics, and audit events. A telemetry redactor removes
12
+ sensitive data from those values before Zuplo records them.
13
+
14
+ Register a redactor once in `zuplo.runtime.ts`, and every log entry, span,
15
+ analytics record, request logger entry, and audit event passes through it.
16
+ Redaction applies only to what Zuplo records. The request, the response, and the
17
+ values your code reads stay unchanged.
18
+
19
+ ```ts title="modules/zuplo.runtime.ts"
20
+ import { RuntimeExtensions, createRedactor } from "@zuplo/runtime";
21
+
22
+ export function runtimeInit(runtime: RuntimeExtensions) {
23
+ runtime.addTelemetryRedactor(
24
+ createRedactor({
25
+ entities: ["pii", "secret"],
26
+ queryParameters: ["iban"],
27
+ fieldNames: ["dob"],
28
+ }),
29
+ );
30
+ }
31
+ ```
32
+
33
+ With this redactor, a request to `/accounts?iban=DE89370400440532013000&page=2`
34
+ whose handler calls
35
+ `context.log.info("charging", { card: "4111 1111 1111 1111", dob: "1990-01-01" })`
36
+ is recorded like this:
37
+
38
+ ```diff
39
+ - "url": "https://api.example.com/accounts?iban=DE89370400440532013000&page=2"
40
+ + "url": "https://api.example.com/accounts?iban=%5BREDACTED%5D&page=2"
41
+ - "messages": ["charging", { "card": "4111 1111 1111 1111", "dob": "1990-01-01" }]
42
+ + "messages": ["charging", { "card": "[REDACTED]", "dob": "[REDACTED]" }]
43
+ ```
44
+
45
+ The response to the client is the same with or without the redactor.
46
+
47
+ ## Register a redactor
48
+
49
+ Call `runtime.addTelemetryRedactor` inside `runtimeInit` in
50
+ [`zuplo.runtime.ts`](./runtime-extensions.mdx). A redactor is either the result
51
+ of [`createRedactor`](#use-the-built-in-redactor) or your own
52
+ [function](#write-a-custom-redactor).
53
+
54
+ - Register redactors only in `runtimeInit`. Calling `addTelemetryRedactor` after
55
+ the gateway starts, for example inside a request hook, throws an error and
56
+ doesn't add the redactor.
57
+ - You can register up to 16 redactors. Registering a 17th throws an error.
58
+ - Passing anything other than a function throws an error.
59
+
60
+ An error thrown in `runtimeInit` stops the gateway from starting, so a
61
+ misconfigured redactor never lets data through unredacted.
62
+
63
+ ### Combine several redactors
64
+
65
+ Redactors run in the order you register them. Each redactor receives the output
66
+ of the previous one for the same value.
67
+
68
+ ```ts title="modules/zuplo.runtime.ts"
69
+ import { RuntimeExtensions, createRedactor } from "@zuplo/runtime";
70
+
71
+ export function runtimeInit(runtime: RuntimeExtensions) {
72
+ // Runs first: built-in patterns
73
+ runtime.addTelemetryRedactor(
74
+ createRedactor({ entities: ["finance-credit-card", "id-us-ssn"] }),
75
+ );
76
+ // Runs second: receives the output of the first redactor
77
+ runtime.addTelemetryRedactor((value, { key }) =>
78
+ key === "accountNumber" ? "[REDACTED]" : value,
79
+ );
80
+ }
81
+ ```
82
+
83
+ ## Use the built-in redactor
84
+
85
+ `createRedactor(options)` returns a redactor that applies only the options you
86
+ set. It detects sensitive values with the same built-in data types and groups as
87
+ the [Data Loss Prevention policy](../policies/ai-gateway-dlp-inbound.mdx), so
88
+ `entities: ["pii", "secret"]` selects the same data types in both places.
89
+
90
+ | Option | What it redacts |
91
+ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
92
+ | `entities` | Matches of built-in data types by ID (`finance-credit-card`, `id-us-ssn`), group (`pii`, `secret`, `region-eu`), or ID prefix (`id-us`, `secret-aws`). When omitted, no built-in data type runs. |
93
+ | `customPatterns` | Matches of your own regular expressions. Each entry is `{ name, pattern, confidence?, context? }`. |
94
+ | `minConfidence` | The confidence, from 0 to 1, a match from `entities` or `customPatterns` needs to be redacted. Defaults to `0.5`. |
95
+ | `allowValues` | Matched text that's never redacted, compared exactly, for example a test card number. |
96
+ | `queryParameters` | The value of each named query parameter wherever a query string appears: request URLs, span attributes such as `url.full`, and URLs inside log messages. Names match case-insensitively, after URL decoding. |
97
+ | `fieldNames` | The whole value of any property whose name is in the list, for example `["password", "dob"]`. Names match case-insensitively. |
98
+ | `replacement` | The text recorded in place of a match. It's used literally. Defaults to `[REDACTED]`. In query parameter values, it's URL-encoded, so `[REDACTED]` is recorded as `%5BREDACTED%5D` and the URL stays valid. |
99
+
100
+ `createRedactor` throws an error in `runtimeInit` for an unknown entity, a
101
+ custom pattern that isn't a valid regular expression, or a `minConfidence`
102
+ outside 0 to 1. A typo stops the gateway from starting instead of silently
103
+ turning redaction off.
104
+
105
+ `fieldNames` redacts a value only when it sits directly under the matching
106
+ property name. In `{ dob: "1990-01-01" }` the value is redacted, but in
107
+ `{ dob: ["1990-01-01"] }` or `{ card: { number: "..." } }` the nested values are
108
+ checked only by the other options. Property names themselves are recorded as
109
+ written.
110
+
111
+ ### Custom patterns
112
+
113
+ A custom pattern has a `name`, a regular expression `pattern`, an optional base
114
+ `confidence` (defaults to `0.85`), and optional `context` words. Context words
115
+ that appear near a match in the same value raise its confidence. Use a low
116
+ `confidence` with `context` for values that are sensitive only in context.
117
+
118
+ ```ts title="modules/zuplo.runtime.ts"
119
+ import { RuntimeExtensions, createRedactor } from "@zuplo/runtime";
120
+
121
+ export function runtimeInit(runtime: RuntimeExtensions) {
122
+ runtime.addTelemetryRedactor(
123
+ createRedactor({
124
+ entities: ["pii"],
125
+ customPatterns: [
126
+ // Always redacted: confidence 0.85 is above the 0.5 default
127
+ { name: "member-id", pattern: "MBR-\\d{8}" },
128
+ // Redacted only when "patient" or "mrn" appears nearby
129
+ {
130
+ name: "medical-record-number",
131
+ pattern: "\\b\\d{7}\\b",
132
+ confidence: 0.3,
133
+ context: ["patient", "mrn"],
134
+ },
135
+ ],
136
+ allowValues: ["4111 1111 1111 1111"],
137
+ }),
138
+ );
139
+ }
140
+ ```
141
+
142
+ :::note
143
+
144
+ Pattern matching can't find every form sensitive data takes. Add a
145
+ [custom redactor](#write-a-custom-redactor) for data that's specific to your
146
+ API.
147
+
148
+ :::
149
+
150
+ ## Write a custom redactor
151
+
152
+ A redactor is a synchronous function that takes a string and a context and
153
+ returns the string to record: the input unchanged, or a redacted copy.
154
+
155
+ ```ts
156
+ interface TelemetryRedactor {
157
+ (value: string, context: RedactionContext): string;
158
+ }
159
+
160
+ interface RedactionContext {
161
+ readonly kind: "log" | "span" | "analytics" | "request-log" | "audit-log";
162
+ readonly field: string;
163
+ readonly key: string | undefined;
164
+ }
165
+ ```
166
+
167
+ | Property | Description |
168
+ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
169
+ | `kind` | The kind of record the value is written to. See [What's redacted](#whats-redacted). |
170
+ | `field` | The path of the value in the record, for example `message[0]`, `message[1].user.email`, `properties.customerId`, `attributes.url.full`, or `url`. |
171
+ | `key` | The last property name in `field`, for example `email` or `url.full`. `undefined` when the value isn't an object property, such as a log message string or array element. |
172
+
173
+ For example, `context.log.info("charging", { card: "4111 1111 1111 1111" })`
174
+ calls the redactor twice:
175
+
176
+ | `value` | `kind` | `field` | `key` |
177
+ | ----------------------- | ------ | ----------------- | ----------- |
178
+ | `"charging"` | `log` | `message[0]` | `undefined` |
179
+ | `"4111 1111 1111 1111"` | `log` | `message[1].card` | `card` |
180
+
181
+ The `url.full` attribute on a span is passed with `kind: "span"`,
182
+ `field: "attributes.url.full"`, and `key: "url.full"`.
183
+
184
+ Use the context to apply a rule to one kind of record or one property:
185
+
186
+ ```ts title="modules/zuplo.runtime.ts"
187
+ import { RuntimeExtensions } from "@zuplo/runtime";
188
+
189
+ export function runtimeInit(runtime: RuntimeExtensions) {
190
+ runtime.addTelemetryRedactor((value, { kind, key }) => {
191
+ if (key === "ssn") {
192
+ return "[REDACTED]";
193
+ }
194
+ if (kind === "audit-log" && key === "email") {
195
+ return value.replace(/^[^@]+/, "***");
196
+ }
197
+ return value;
198
+ });
199
+ }
200
+ ```
201
+
202
+ ### How values are passed
203
+
204
+ - Objects, arrays, and errors are walked the way the log serializers write them,
205
+ and each string inside is passed to the redactor separately. For an error,
206
+ that includes its message, stack, cause, and custom properties. A `Map` or
207
+ `Set` is recorded the way the serializers print it, usually `{}`.
208
+ - Numbers are passed as their decimal string. If the redactor returns the same
209
+ string, the record keeps the number. If it returns a different string, the
210
+ record holds that string. Dates work the same way, using their serialized
211
+ string.
212
+ - A span attribute array must hold a single type. If the redactor changes any
213
+ number in such an array, every element is recorded as text.
214
+ - When the redacted request URL given to log transports is no longer a valid
215
+ URL, transports receive the original origin followed by `/[REDACTED]`.
216
+ - In audit events, the IP address is left out of the event when the redactor
217
+ changes it.
218
+
219
+ ### Keep redactors pure and fast
220
+
221
+ A redactor runs on the request path for every value Zuplo records, so keep it
222
+ fast. It must also be pure: the same value and context must always return the
223
+ same output. Zuplo caches results for values of 256 characters or fewer and can
224
+ reuse an earlier result instead of calling the redactor again.
225
+
226
+ Anything a redactor logs is dropped, so a redactor can't write sensitive values
227
+ into the logs it's meant to protect.
228
+
229
+ ## Failures
230
+
231
+ Redaction fails closed. When a redactor throws an error, returns anything other
232
+ than a string, or is `async` (returns a promise), Zuplo records the value as
233
+ `[REDACTION_FAILED]`. Later redactors don't run for that value, and the original
234
+ value is never recorded. The `REDACTION_FAILED_PLACEHOLDER` constant exported
235
+ from `@zuplo/runtime` holds this text.
236
+
237
+ Each failure writes a warning to your gateway's logs, at most once a minute for
238
+ each kind of record:
239
+
240
+ ```txt
241
+ A redactor registered with runtime.addTelemetryRedactor threw or did not return a string while redacting a log record. The value was recorded as [REDACTION_FAILED]. Further failures are reported at most once a minute.
242
+ ```
243
+
244
+ The warning never contains the value or the redactor's error message.
245
+
246
+ ## Limits
247
+
248
+ | Limit | Value |
249
+ | ------------------ | -------------------------------------------------------------------------------------------------------------- |
250
+ | Redactors | 16, registered only in `runtimeInit` |
251
+ | Value length | 32,768 characters. Longer values, and longer redactor output, are cut to that length and marked `[Truncated]`. |
252
+ | Values per record | 10,000, shared by every field of the record. Values past the limit are recorded as `[Truncated]`. |
253
+ | Nesting depth | 20 levels. Deeper values are recorded as `[Truncated]`. |
254
+ | Values that repeat | A value that contains itself is recorded as `[Circular]` where it repeats. |
255
+
256
+ ## What's redacted
257
+
258
+ When a redactor is registered, these values pass through it before any log
259
+ transport, tracing exporter, plugin, or Zuplo service receives the record. Every
260
+ destination receives the same redacted record. With no redactor registered,
261
+ records are unchanged.
262
+
263
+ | `kind` | Record | Values passed to the redactor |
264
+ | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
265
+ | `log` | [Logs](./logger.mdx) from Zuplo and from your code | Every message argument, log properties, custom log fields, and the request URL given to log transports |
266
+ | `span` | [OpenTelemetry](../articles/opentelemetry.mdx) spans | The span name, every attribute, every event name and event attribute, every link attribute, and the status message |
267
+ | `analytics` | [Analytics](../analytics/overview.md) request records and events | The request URL (path and query string), properties your code sets with `setLogProperties`, and the resource URI on analytics events |
268
+ | `request-log` | Request logger plugins: [Azure Blob](../articles/plugin-azure-blob.mdx), [Azure Event Hubs](../articles/plugin-azure-event-hubs.mdx), and [Hydrolix](../articles/plugin-hydrolix-traffic-peak.mdx) | Every value of each entry |
269
+ | `audit-log` | Events from the [Audit Logs policy](../policies/audit-log-inbound.mdx) | Every field except the fields listed in the next section |
270
+
271
+ ### Values that aren't redacted
272
+
273
+ Zuplo computes usage, analytics, and billing from some recorded values, and
274
+ generates others itself. These values are always recorded as measured, even when
275
+ a redactor is registered:
276
+
277
+ | Record | Values recorded as measured |
278
+ | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
279
+ | Analytics request record | Route pattern, method, status code, sizes, timings, user, client IP, geographic fields, ray ID, request IDs, and properties Zuplo sets |
280
+ | Analytics events | Every field except the resource URI, including the model, provider, app, team, and consumer that AI Gateway usage is metered by |
281
+ | Audit events | `specversion`, `id`, `time`, `datacontenttype`, `bucketid`, `actortype`, `requestid`, `success`, `httpmethod`, and `httpstatus` |
282
+
283
+ Keep sensitive data out of route paths and user identifiers, because a redactor
284
+ can't remove it from these fields.
285
+
286
+ ### Data that redactors don't cover
287
+
288
+ Redactors apply only to records the gateway writes through the paths listed
289
+ earlier. They don't cover:
290
+
291
+ - Data that metering and analytics policies send to their services, such as
292
+ Moesif, ReadMe, Amberflo, and OpenMeter. Those services receive the raw
293
+ values.
294
+ - Request and response bodies sent to Akamai API Security.
295
+ - Output written directly to the console instead of through `context.log`, and
296
+ uncaught errors captured by the hosting platform.
297
+ - Logs written before `runtimeInit` runs.
298
+ - OpenTelemetry resource attributes and other static configuration.
299
+ - Data the gateway stores to serve requests, such as cache entries and rate
300
+ limit keys.
301
+ - Records after they leave the gateway.
302
+
303
+ ## Related
304
+
305
+ - [Runtime extensions](./runtime-extensions.mdx)
306
+ - [Logger](./logger.mdx)
307
+ - [OpenTelemetry](../articles/opentelemetry.mdx)
308
+ - [Data Loss Prevention policy](../policies/ai-gateway-dlp-inbound.mdx)
@@ -19,7 +19,7 @@ of the file is `1`.
19
19
  ```jsonc
20
20
  {
21
21
  "version": 1,
22
- "compatibilityDate": "2025-02-06",
22
+ "compatibilityDate": "2026-11-06",
23
23
  "projectType": "managed-edge",
24
24
  }
25
25
  ```
@@ -46,7 +46,7 @@ and their changes.
46
46
  ```jsonc
47
47
  {
48
48
  "version": 1,
49
- "compatibilityDate": "2025-02-06",
49
+ "compatibilityDate": "2026-11-06",
50
50
  }
51
51
  ```
52
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zuplo",
3
- "version": "7.15.0",
3
+ "version": "7.15.3",
4
4
  "type": "module",
5
5
  "description": "The official Zuplo CLI for local development and platform management",
6
6
  "homepage": "https://zuplo.com/docs/cli/overview",
@@ -17,7 +17,7 @@
17
17
  "mcp-gateway"
18
18
  ],
19
19
  "author": "Zuplo, Inc.",
20
- "license": "See LICENSE in LICENSE.txt",
20
+ "license": "SEE LICENSE IN LICENSE.txt",
21
21
  "files": [
22
22
  "README.md",
23
23
  "LICENSE.txt",
@@ -32,9 +32,9 @@
32
32
  "zuplo": "zuplo.js"
33
33
  },
34
34
  "dependencies": {
35
- "@zuplo/cli": "7.15.0",
36
- "@zuplo/core": "7.15.0",
37
- "@zuplo/runtime": "7.15.0",
38
- "@zuplo/test": "7.15.0"
35
+ "@zuplo/cli": "7.15.3",
36
+ "@zuplo/core": "7.15.3",
37
+ "@zuplo/runtime": "7.15.3",
38
+ "@zuplo/test": "7.15.3"
39
39
  }
40
40
  }
@@ -1,199 +0,0 @@
1
- ---
2
- title: Blue-Green Deployments for Your Backend
3
- sidebar_label: Blue-Green Deployments
4
- description:
5
- Run blue and green backend stacks behind Zuplo, test the idle stack through a
6
- staging gateway with the same policies, then switch traffic and roll back
7
- safely.
8
- tags:
9
- - backends
10
- - deployment
11
- - testing
12
- applies_to:
13
- product: gateway
14
- hosting: all
15
- ---
16
-
17
- A blue-green deployment runs two copies of your backend, called blue and green.
18
- One copy serves live traffic while you deploy and test the next release on the
19
- other. When the new release passes its tests, you switch traffic to it, and the
20
- old copy stays ready as a fallback.
21
-
22
- This guide shows how to run a blue-green release behind a Zuplo gateway: a
23
- staging gateway environment sends test traffic to the idle backend with the same
24
- routes and policies as production, and production keeps serving the live backend
25
- until you switch.
26
-
27
- :::tip
28
-
29
- Zuplo already deploys changes to the gateway itself without downtime, and you
30
- can roll back to any earlier build. You don't need two gateways to change your
31
- gateway safely. See
32
- [Deployments and Rollbacks](../articles/deployments-and-rollbacks.mdx). This
33
- guide is about releasing your backend.
34
-
35
- :::
36
-
37
- ## How it works
38
-
39
- Each backend copy has its own URL, for example its own load balancer or its own
40
- hostname. Two Zuplo environments run the same project:
41
-
42
- - **Production** is deployed from your default branch and forwards requests to
43
- the live backend.
44
- - **Staging** is a preview environment deployed from a separate branch. It
45
- forwards requests to the idle backend, so you can test a release through the
46
- same routes and policies that production uses.
47
-
48
- <Diagram height="h-72">
49
- <DiagramNode id="clients">API clients</DiagramNode>
50
- <DiagramNode id="testers">Testers</DiagramNode>
51
- <DiagramNode id="prod" variant="zuplo">
52
- Production environment
53
- </DiagramNode>
54
- <DiagramNode id="staging" variant="zuplo">
55
- Staging environment
56
- </DiagramNode>
57
- <DiagramNode id="blue" variant="blue">
58
- Blue backend (live)
59
- </DiagramNode>
60
- <DiagramNode id="green" variant="green">
61
- Green backend (idle)
62
- </DiagramNode>
63
- <DiagramEdge from="clients" to="prod" />
64
- <DiagramEdge from="testers" to="staging" />
65
- <DiagramEdge from="prod" to="blue" label="BACKEND_URL" />
66
- <DiagramEdge from="staging" to="green" label="BACKEND_URL" />
67
- </Diagram>
68
-
69
- ## Prerequisites
70
-
71
- - A Zuplo project connected to [source control](../articles/source-control.mdx),
72
- so that branches deploy as environments
73
- - Two copies of your backend, each reachable at its own URL
74
-
75
- ## 1/ Read the backend URL from an environment variable
76
-
77
- Set each route's backend URL from an
78
- [environment variable](../articles/environment-variables.mdx), so the production
79
- and staging environments can forward to different backends with the same code.
80
- With the [URL Forward handler](../handlers/url-forward.mdx):
81
-
82
- ```json title="config/routes.oas.json"
83
- {
84
- "handler": {
85
- "export": "urlForwardHandler",
86
- "module": "$import(@zuplo/runtime)",
87
- "options": {
88
- "baseUrl": "${env.BACKEND_URL}"
89
- }
90
- }
91
- }
92
- ```
93
-
94
- In the Zuplo Portal, open
95
- [**Settings**](https://portal.zuplo.com/+/account/project/settings/general) and
96
- select **Environment Variables**. Add `BACKEND_URL` for the **Production**
97
- environment, set to the URL of the live backend, for example
98
- `https://blue.api.example.com`.
99
-
100
- ## 2/ Create the staging environment
101
-
102
- Create a branch, for example `staging`, and push it. Zuplo deploys it as a
103
- preview environment with its own URL. See
104
- [Branch-Based Deployments](../articles/branch-based-deployments.mdx).
105
-
106
- Then set up the staging environment:
107
-
108
- - **Backend URL:** add `BACKEND_URL` for the `staging` preview environment, set
109
- to the idle backend, for example `https://green.api.example.com`. A variable
110
- can apply to one named preview environment, so it doesn't affect other
111
- branches.
112
- - **Secrets:** give every secret your policies read, such as a shared secret
113
- from your CDN, a value for the staging environment.
114
- - **API keys:** preview environments use a separate
115
- [API key bucket](../articles/api-key-buckets.mdx) from production, so
116
- production keys don't work there. Create test consumers in the preview bucket,
117
- or see
118
- [Custom bucket configuration](../articles/api-key-buckets.mdx#custom-bucket-configuration).
119
- - **mTLS client certificates:** if your backend requires a
120
- [client certificate](../articles/securing-backend-mtls.mdx), enable the
121
- certificate for the preview environment type.
122
- - **Custom domain (optional):** give the staging environment its own hostname,
123
- such as `staging-api.example.com`. See
124
- [Custom Domains](../articles/custom-domains.mdx).
125
-
126
- Redeploy the staging environment after you change its variables, because
127
- variable changes take effect on the next deployment.
128
-
129
- ## 3/ Release a new backend version
130
-
131
- 1. Deploy the new version of your backend to the idle copy (green).
132
- 2. Test it through the staging environment's URL. Requests pass through the same
133
- routes and policies as production, so the test covers authentication, rate
134
- limits, and request validation, not only the backend.
135
- 3. When the release passes, switch production traffic to green (see the next
136
- section).
137
- 4. Point the staging environment at the copy that's now idle (blue), ready for
138
- the next release.
139
-
140
- ## 4/ Switch production traffic
141
-
142
- Choose where the switch happens:
143
-
144
- | Switch at | How | Zuplo deployment needed |
145
- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------------------- |
146
- | Your load balancer or DNS | Point the hostname that production's `BACKEND_URL` uses at green, for example by changing a load balancer rule or DNS record | No |
147
- | The production `BACKEND_URL` | Change the variable to green's URL, then redeploy the production environment | Yes |
148
-
149
- Switching at the load balancer is the fastest option, in both directions,
150
- because it doesn't wait for a gateway deployment. Changing `BACKEND_URL` keeps
151
- the switch in Zuplo, and the redeploy rolls out without downtime.
152
-
153
- ## Roll back
154
-
155
- Switch back the same way you switched forward. Blue is still running the
156
- previous release, so rolling back only changes where traffic goes:
157
-
158
- - If you switched at the load balancer or DNS, point it back at blue.
159
- - If you switched with `BACKEND_URL`, set it back to blue's URL and redeploy
160
- production.
161
-
162
- :::caution
163
-
164
- Redeploying an earlier build of the production environment doesn't restore an
165
- earlier value of `BACKEND_URL`, because a redeploy uses current settings. Change
166
- the variable itself to roll back a `BACKEND_URL` switch.
167
-
168
- :::
169
-
170
- ## Test through production instead of a staging environment
171
-
172
- If the gateway configuration doesn't change between releases, testers can reach
173
- the idle backend through the production environment itself. A routing policy
174
- sends requests with a header such as `x-stage: canary`, or from users on an
175
- allow list, to the idle backend, and everyone else to the live one. You don't
176
- need a staging environment or a second hostname. The trade-off is that both
177
- backends share one gateway deployment. See
178
- [Route Employees to Canary or Staging Backends](./canary-routing-for-employees.mdx).
179
-
180
- ## When to run blue and green gateway environments
181
-
182
- Most releases only need the pattern above. If a release also changes the gateway
183
- configuration in a risky way, such as new authentication policies, you can run
184
- two long-lived environments from `blue` and `green` branches and switch traffic
185
- in front of Zuplo, for example by changing your CDN's origin.
186
-
187
- Both environments are preview environments, which serve traffic the same way as
188
- production. Production-scoped settings don't apply to them, so set their
189
- [environment variables](../articles/environment-variables.mdx) for each named
190
- environment and choose which [API key bucket](../articles/api-key-buckets.mdx)
191
- they use. See
192
- [Preview vs Production Environments](../articles/environments.mdx#preview-vs-production-environments-or-multiple-production-environments).
193
-
194
- ## Next steps
195
-
196
- - [Deployments and Rollbacks](../articles/deployments-and-rollbacks.mdx)
197
- - [Testing Preview Environments](../articles/testing-preview-environments.mdx)
198
- - [Fail Over Between Backends](./backend-failover.mdx)
199
- - [Connect to an AWS ALB with mTLS](../articles/connect-to-aws-alb-with-mtls.mdx)