From 1d7cd13cdd20fc1612564b1db587e7a53b384b17 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Fri, 20 Nov 2026 15:58:28 -0800 Subject: [PATCH 1/4] Add opt-in native dev observability and cleanup regressions Signed-off-by: James Sturtevant --- cli/src/dev.rs | 14 +- cli/src/host.rs | 10 +- cli/src/main.rs | 6 +- cli/src/tools.rs | 18 +- cli/tests/dev.rs | 3 +- cli/tests/tools.rs | 40 +++ cmd/ly-dev/main.go | 2 +- docs/cli/dev.md | 27 ++ internal/fiberdintegration/local.go | 46 ++- .../fiberdintegration/local_observability.go | 274 ++++++++++++++++++ .../local_observability_test.go | 268 +++++++++++++++++ 11 files changed, 685 insertions(+), 23 deletions(-) create mode 100644 internal/fiberdintegration/local_observability.go create mode 100644 internal/fiberdintegration/local_observability_test.go diff --git a/cli/src/dev.rs b/cli/src/dev.rs index bfa51d6..a02be52 100644 --- a/cli/src/dev.rs +++ b/cli/src/dev.rs @@ -3,6 +3,7 @@ use std::collections::BTreeSet; use std::path::Path; +use std::time::Duration; use anyhow::{Context, Result, ensure}; use serde_json::json; @@ -14,6 +15,7 @@ pub fn run( root: Option<&Path>, port: i32, metrics: bool, + observability: bool, host: &Host, ) -> Result<()> { ensure!( @@ -80,7 +82,7 @@ pub fn run( .capture(host.command(&helper)?.arg("--protocol-version")) .context("local supervisor is outdated; install or rebuild matching ly and ly-dev")?; ensure!( - protocol == "3", + protocol == "4", "local supervisor is outdated; install or rebuild matching ly and ly-dev" ); let build = directory.join(".lampyr/dev"); @@ -128,12 +130,18 @@ pub fn run( serde_json::to_vec(&json!({ "binary": binary, "listen": format!("127.0.0.1:{port}"), - "schemaVersion": 3, + "schemaVersion": 4, "exposedServices": exposed, "metrics": metrics, + "observability": observability, "services": services, }))?, )?; println!("native dev: CPU quotas, signed Grants and durable event delivery are not emulated"); - host.interactive(host.command(helper)?.arg(&plan)) + if observability { + // Allow request draining, bounded trace flushing, then backend removal. + host.interactive_with_grace(host.command(helper)?.arg(&plan), Duration::from_secs(30)) + } else { + host.interactive(host.command(helper)?.arg(&plan)) + } } diff --git a/cli/src/host.rs b/cli/src/host.rs index a7339b4..1503c86 100644 --- a/cli/src/host.rs +++ b/cli/src/host.rs @@ -193,10 +193,18 @@ impl Host { } pub fn interactive(&self, command: &mut Command) -> Result<()> { + self.interactive_with_grace(command, Duration::from_secs(7)) + } + + pub fn interactive_with_grace( + &self, + command: &mut Command, + shutdown_grace: Duration, + ) -> Result<()> { command.stdin(Stdio::inherit()); let output = tools::execute( command, - Output::Interactive, + Output::InteractiveWithGrace(shutdown_grace), 8 * 1024 * 1024, None, &self.cancellation, diff --git a/cli/src/main.rs b/cli/src/main.rs index 59e3d60..ba7f262 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -170,6 +170,9 @@ enum Command { /// Print one line per completed request and a summary on exit. #[arg(long)] metrics: bool, + /// Start local Prometheus and Jaeger with links on the local service index. + #[arg(long)] + observability: bool, }, /// Build the service snapshot and local OCI image. Build { @@ -473,8 +476,9 @@ fn run(cli: Cli) -> Result<()> { directory, port, metrics, + observability, } => { - lampyr_cli::dev::run(&directory, None, port, metrics, &host)?; + lampyr_cli::dev::run(&directory, None, port, metrics, observability, &host)?; } Command::Build { directory, diff --git a/cli/src/tools.rs b/cli/src/tools.rs index 9da3dcc..55e0524 100644 --- a/cli/src/tools.rs +++ b/cli/src/tools.rs @@ -31,6 +31,7 @@ pub enum Output { Capture, File(std::fs::File), Interactive, + InteractiveWithGrace(std::time::Duration), } pub fn run( @@ -110,7 +111,11 @@ mod unix { deadline: Option, cancellation: &Cancellation, ) -> Result { - let interactive = matches!(&output, Output::Interactive); + let shutdown_grace = match &output { + Output::Interactive => Some(Duration::from_secs(7)), + Output::InteractiveWithGrace(grace) => Some(*grace), + _ => None, + }; match output { Output::Capture => { command.stdout(Stdio::piped()).stderr(Stdio::piped()); @@ -118,7 +123,7 @@ mod unix { Output::File(file) => { command.stdout(file).stderr(Stdio::piped()); } - Output::Interactive => { + Output::Interactive | Output::InteractiveWithGrace(_) => { command.stdout(Stdio::inherit()).stderr(Stdio::inherit()); } } @@ -141,8 +146,8 @@ mod unix { .map(|pipe| scope.spawn(move || capture(pipe, limit, deadline, cancellation))); let status = loop { if cancellation.is_cancelled() { - if interactive { - terminate_gracefully(&mut child)?; + if let Some(grace) = shutdown_grace { + terminate_gracefully(&mut child, grace)?; } else { terminate(&mut child)?; } @@ -254,12 +259,11 @@ mod unix { Ok(()) } - fn terminate_gracefully(child: &mut Child) -> Result<()> { + fn terminate_gracefully(child: &mut Child, grace: Duration) -> Result<()> { let pid = i32::try_from(child.id()).context("local tool PID is out of range")?; ensure!(pid > 0, "invalid local tool process group"); signal_process(pid, libc::SIGTERM)?; - // ly-dev gets five seconds to drain requests; leave time for cleanup and summary output. - let deadline = Instant::now() + Duration::from_secs(7); + let deadline = Instant::now() + grace; let mut reaped = false; loop { reaped |= child diff --git a/cli/tests/dev.rs b/cli/tests/dev.rs index ee87be9..6c0a266 100644 --- a/cli/tests/dev.rs +++ b/cli/tests/dev.rs @@ -10,13 +10,14 @@ fn fixture() -> std::path::PathBuf { } #[test] -fn dev_help_offers_request_metrics() { +fn dev_help_offers_independent_request_metrics_and_observability() { let output = Command::new(env!("CARGO_BIN_EXE_ly")) .args(["dev", "--help"]) .output() .unwrap(); assert!(output.status.success()); assert!(String::from_utf8_lossy(&output.stdout).contains("--metrics")); + assert!(String::from_utf8_lossy(&output.stdout).contains("--observability")); } #[test] diff --git a/cli/tests/tools.rs b/cli/tests/tools.rs index 9a6b062..2b035c6 100644 --- a/cli/tests/tools.rs +++ b/cli/tests/tools.rs @@ -112,6 +112,46 @@ fn interactive_cancellation_allows_graceful_sigterm_cleanup() { } #[cfg(unix)] +#[test] +fn observability_cancellation_allows_drain_then_backend_cleanup() { + let directory = tempfile::tempdir().unwrap(); + let started = directory.path().join("started"); + let stopped = directory.path().join("stopped"); + let mut command = std::process::Command::new("/bin/sh"); + command + .env("STARTED", &started) + .env("STOPPED", &stopped) + .args([ + "-c", + "trap 'sleep 8; printf stopped > \"$STOPPED\"; exit 0' TERM; printf started > \"$STARTED\"; while :; do :; done", + ]); + let cancellation = Cancellation::default(); + let cancel = cancellation.clone(); + std::thread::scope(|scope| { + scope.spawn(move || { + let deadline = Instant::now() + Duration::from_secs(5); + while !started.exists() && Instant::now() < deadline { + std::thread::sleep(Duration::from_millis(5)); + } + cancel.cancel(); + }); + assert!( + tools::execute( + &mut command, + tools::Output::InteractiveWithGrace(Duration::from_secs(30)), + 1024, + None, + &cancellation, + ) + .is_err() + ); + }); + assert_eq!( + std::fs::read_to_string(stopped).expect("backend cleanup did not finish"), + "stopped" + ); +} + #[test] fn interactive_cancellation_kills_descendants_after_grace_period() { let directory = tempfile::tempdir().unwrap(); diff --git a/cmd/ly-dev/main.go b/cmd/ly-dev/main.go index 5e82806..97bfb39 100644 --- a/cmd/ly-dev/main.go +++ b/cmd/ly-dev/main.go @@ -23,7 +23,7 @@ func main() { func run() error { if len(os.Args) == 2 && os.Args[1] == "--protocol-version" { - fmt.Println("3") + fmt.Println("4") return nil } if len(os.Args) != 2 { diff --git a/docs/cli/dev.md b/docs/cli/dev.md index a07ce87..5eb0af1 100644 --- a/docs/cli/dev.md +++ b/docs/cli/dev.md @@ -40,6 +40,7 @@ upgrade process. |---|---:|---| | `--port` | `8080` | Local HTTP port. | | `--metrics` | `false` | Print one line per completed request and an aggregate summary when dev exits. | +| `--observability` | `false` | Start local Prometheus and Jaeger. Show links on the local service index. | Metrics include service, method, path, status, total duration, Fiber clone duration, Fiber ID, and whether the Fiber was created or attached for reuse: @@ -49,6 +50,32 @@ metric service=worker-api method=GET path="/invoke" status=200 duration_ms=128 c metrics summary requests=3 errors=0 create=2 attach=1 avg_duration_ms=54 avg_clone_ms=39 ``` +## Local observability + +```bash +ly dev demos/local-worker-workspace --observability +``` + +Open `http://localhost:8080/`. The service index includes an **Observability** +section with links to Prometheus and Jaeger. Send requests to an exposed +service. In Prometheus, query `lampyr_router_request_duration_seconds_count`. +In Jaeger, select `lampyr-local`, then **Find Traces**. Telemetry includes +internal services reached through bindings. + +This option needs Docker, not Kubernetes. The first run downloads pinned +Prometheus and Jaeger images. Their browser endpoints use free loopback ports, +so multiple dev sessions can run with different `--port` values. +Prometheus scrapes a separate host listener with a random session token. +Docker uses `host.docker.internal` to reach it, with `host-gateway` on Linux. +The host firewall must allow this container-to-host connection. +Application routes, including `/metrics`, do not change. + +Data is temporary. On exit, the supervisor flushes traces, removes its two +containers, and deletes their configuration. Prometheus retains up to one hour +of metrics in memory-backed storage; Jaeger retains up to 10,000 traces. +Use `--metrics` as well if you want request text in the terminal. +Without `--observability`, no telemetry containers or scrape listener start. + ## Workspace development Service and workspace development both use native snapshots and the diff --git a/internal/fiberdintegration/local.go b/internal/fiberdintegration/local.go index e1c0575..c4d1c42 100644 --- a/internal/fiberdintegration/local.go +++ b/internal/fiberdintegration/local.go @@ -44,6 +44,7 @@ type LocalConfig struct { ExposedServices []string `json:"exposedServices"` Services []LocalService `json:"services"` Metrics bool `json:"metrics"` + Observability bool `json:"observability"` } type localMetrics struct { @@ -431,7 +432,7 @@ func (home *localHome) Release(_ context.Context, id string, _ bool) error { func RunLocal(ctx context.Context, config LocalConfig) (returnErr error) { ctx, cancel := context.WithCancel(ctx) defer cancel() - if config.SchemaVersion != 3 { + if config.SchemaVersion != 4 { return fmt.Errorf("unsupported local plan schema; install or rebuild the matching ly and ly-dev") } if config.Binary == "" || len(config.Services) == 0 { @@ -513,6 +514,15 @@ func RunLocal(ctx context.Context, config LocalConfig) (returnErr error) { return err } } + var observability *localObservability + if config.Observability { + fmt.Println("starting local Prometheus and Jaeger (first use can download images)") + observability, err = startLocalObservability(ctx, filepath.Dir(config.Services[0].Snapshot), localDockerCommand) + if err != nil { + return err + } + defer func() { returnErr = errors.Join(returnErr, observability.Close()) }() + } router, err := NewRouter(homes, routesDir) if err != nil { return err @@ -528,12 +538,16 @@ func RunLocal(ctx context.Context, config LocalConfig) (returnErr error) { router.Observe(metrics.Observe) defer metrics.Summary() } - if len(exposed) > 0 { + if len(exposed) > 0 || observability != nil { ingress, err := net.Listen("tcp4", config.Listen) if err != nil { return err } listeners = append(listeners, ingress) + if observability != nil { + _, port, _ := net.SplitHostPort(ingress.Addr().String()) + fmt.Printf("observability: http://localhost:%s/\n", port) + } for _, name := range config.ExposedServices { _, port, _ := net.SplitHostPort(ingress.Addr().String()) fmt.Printf("running %s at http://%s.default.localhost:%s\n", name, name, port) @@ -544,7 +558,7 @@ func RunLocal(ctx context.Context, config LocalConfig) (returnErr error) { failures := make(chan error, len(listeners)) for index, listener := range listeners { _, port, _ := net.SplitHostPort(listener.Addr().String()) - handler := localIngressHandler(router, exposed, port) + handler := localIngressHandler(router, exposed, port, observability) if index < len(config.Services) { name := config.Services[index].Name handler = localHandler(router, name, tokens[name]) @@ -676,7 +690,7 @@ func (writer *localBindingResponseWriter) rewriteLocation() { writer.Header().Set("Location", writer.capability+resolved.String()) } -func localIngressHandler(router *Router, exposed map[string]string, port string) http.Handler { +func localIngressHandler(router *Router, exposed map[string]string, port string, observability ...*localObservability) http.Handler { type serviceLink struct { Name string URL string @@ -694,7 +708,14 @@ func localIngressHandler(router *Router, exposed map[string]string, port string) }) } var page strings.Builder - pageErr := localIndexTemplate.Execute(&page, links) + var telemetry *localObservability + if len(observability) > 0 { + telemetry = observability[0] + } + pageErr := localIndexTemplate.Execute(&page, struct { + Services []serviceLink + Observability *localObservability + }{links, telemetry}) return http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) { host := request.Host if strings.Contains(host, ":") { @@ -710,15 +731,15 @@ func localIngressHandler(router *Router, exposed map[string]string, port string) host = strings.ToLower(strings.TrimSuffix(host, ".")) name, ok := exposed[host] if !ok { + landingHost := host == "localhost" || host == "127.0.0.1" || host == "::1" + readPage := request.Method == http.MethodGet || request.Method == http.MethodHead if pageErr != nil { log.Printf("render local service index: %v", pageErr) http.Error(w, "could not render local service index", http.StatusInternalServerError) return } status := http.StatusNotFound - if (host == "localhost" || host == "127.0.0.1" || host == "::1") && - request.URL.Path == "/" && - (request.Method == http.MethodGet || request.Method == http.MethodHead) { + if landingHost && request.URL.Path == "/" && readPage { status = http.StatusOK } w.Header().Set("Content-Type", "text/html; charset=utf-8") @@ -734,7 +755,14 @@ func localIngressHandler(router *Router, exposed map[string]string, port string) var localIndexTemplate = template.Must(template.New("services").Parse(` Lampyr local services

Lampyr local services

Choose an exposed service:

-
    {{range .}}
  • {{.Name}}
  • {{else}}
  • No services are exposed.
  • {{end}}
+
    {{range .Services}}
  • {{.Name}}
  • {{else}}
  • No services are exposed.
  • {{end}}
+{{with .Observability}}

Observability

+

Metrics and traces for all services, including calls through bindings.

+ +

Session data is removed when ly dev exits.

{{end}} `)) diff --git a/internal/fiberdintegration/local_observability.go b/internal/fiberdintegration/local_observability.go new file mode 100644 index 0000000..86271b9 --- /dev/null +++ b/internal/fiberdintegration/local_observability.go @@ -0,0 +1,274 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2026 The Hyperlight Authors. + +package fiberdintegration + +import ( + "context" + "crypto/rand" + "crypto/subtle" + "errors" + "fmt" + "net" + "net/http" + "os" + "os/exec" + "path/filepath" + "runtime" + "strconv" + "strings" + "time" + + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" + "go.opentelemetry.io/otel/propagation" + "go.opentelemetry.io/otel/sdk/resource" + sdktrace "go.opentelemetry.io/otel/sdk/trace" + semconv "go.opentelemetry.io/otel/semconv/v1.37.0" + "go.opentelemetry.io/otel/trace" +) + +const localPrometheusImage = "prom/prometheus:v3.16.0@sha256:e04987641b57704f408e31f6373ba4138ecf27cb4a165d24aabb6c38fddd0f06" +const localJaegerImage = "jaegertracing/jaeger:2.23.0@sha256:3823829974ccfc2485d2e48b165579091f32295022ae80ca49704e2f4834116e" + +type localObservability struct { + Prometheus string + Jaeger string + directory string + containers []string + docker func(context.Context, ...string) (string, error) + metrics *http.Server + tracer *sdktrace.TracerProvider + previous trace.TracerProvider + propagator propagation.TextMapPropagator + platform string +} + +func localDockerCommand(ctx context.Context, args ...string) (string, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Minute) + defer cancel() + output, err := exec.CommandContext(ctx, "docker", args...).CombinedOutput() + if err != nil { + return "", fmt.Errorf("docker %s: %w: %s", args[0], err, strings.TrimSpace(string(output))) + } + return strings.TrimSpace(string(output)), nil +} + +func startLocalObservability(ctx context.Context, parent string, docker func(context.Context, ...string) (string, error)) (_ *localObservability, returnErr error) { + session := &localObservability{docker: docker, platform: runtime.GOOS} + defer func() { + if returnErr != nil { + returnErr = errors.Join(returnErr, session.Close()) + } + }() + directory, err := os.MkdirTemp(parent, "observability-") + if err != nil { + return nil, err + } + session.directory, err = filepath.Abs(directory) + if err != nil { + return nil, err + } + // Docker Desktop reaches the host through host.docker.internal; Linux gets + // the same name through host-gateway. This listener never serves app routes. + listener, err := net.Listen("tcp4", "0.0.0.0:0") + if err != nil { + return nil, err + } + token := rand.Text() + session.metrics = &http.Server{ + Handler: localScrapeHandler(token), ReadHeaderTimeout: 5 * time.Second, + } + go func() { _ = session.metrics.Serve(listener) }() + metricsPort := listener.Addr().(*net.TCPAddr).Port + prometheusConfig := fmt.Sprintf(`global: + scrape_interval: 1s +scrape_configs: + - job_name: lampyr-local + authorization: + credentials: %s + static_configs: + - targets: ["host.docker.internal:%d"] +`, token, metricsPort) + for name, contents := range map[string]string{"prometheus.yml": prometheusConfig, "jaeger.yaml": localJaegerConfig} { + path := filepath.Join(session.directory, name) + if err := os.WriteFile(path, []byte(contents), 0o644); err != nil { + return nil, err + } + if err := os.Chmod(path, 0o644); err != nil { + return nil, err + } + } + jaeger, err := session.container(ctx, "jaeger", localJaegerImage, "jaeger.yaml", + []string{"16686", "4317", "13133"}, "--config=/etc/lampyr/config") + if err != nil { + return nil, err + } + session.Jaeger = "http://" + jaeger["16686"] + prometheus, err := session.container(ctx, "prometheus", localPrometheusImage, "prometheus.yml", + []string{"9090"}, "--config.file=/etc/lampyr/config", "--storage.tsdb.path=/prometheus", + "--storage.tsdb.retention.time=1h", "--storage.tsdb.retention.size=96MB") + if err != nil { + return nil, err + } + session.Prometheus = "http://" + prometheus["9090"] + for _, endpoint := range []string{"http://" + jaeger["13133"] + "/status", session.Prometheus + "/-/ready"} { + if err := localWaitHTTP(ctx, endpoint); err != nil { + return nil, err + } + } + exporter, err := otlptracegrpc.New(ctx, + otlptracegrpc.WithEndpoint(jaeger["4317"]), otlptracegrpc.WithInsecure()) + if err != nil { + return nil, err + } + session.tracer = sdktrace.NewTracerProvider( + sdktrace.WithBatcher(exporter), + sdktrace.WithResource(resource.NewWithAttributes(semconv.SchemaURL, semconv.ServiceName("lampyr-local"))), + ) + session.previous = otel.GetTracerProvider() + session.propagator = otel.GetTextMapPropagator() + otel.SetTracerProvider(session.tracer) + otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})) + return session, nil +} + +func (session *localObservability) container(ctx context.Context, kind, image, config string, ports []string, command ...string) (map[string]string, error) { + name := "lampyr-dev-" + kind + "-" + strings.ToLower(rand.Text()) + session.containers = append(session.containers, name) + args := []string{"create", "--name", name, "--pull=missing", + "--label", "lampyr.dev/local-observability=true", + "--read-only", "--cap-drop=ALL", "--security-opt=no-new-privileges", + "--user=10001:10001", "--memory=512m", "--pids-limit=128", + "--log-opt=max-size=1m", "--log-opt=max-file=1", + "--mount", "type=bind,source=" + filepath.Join(session.directory, config) + ",target=/etc/lampyr/config,readonly"} + for _, port := range ports { + args = append(args, "--publish", "127.0.0.1::"+port) + } + if kind == "prometheus" { + if session.platform == "linux" { + args = append(args, "--add-host=host.docker.internal:host-gateway") + } + args = append(args, "--tmpfs=/prometheus:rw,noexec,nosuid,size=128m,uid=10001,gid=10001") + } + args = append(args, image) + args = append(args, command...) + if _, err := session.docker(ctx, args...); err != nil { + return nil, err + } + if _, err := session.docker(ctx, "start", name); err != nil { + return nil, err + } + endpoints := map[string]string{} + for _, port := range ports { + address, err := session.docker(ctx, "port", name, port+"/tcp") + if err != nil { + return nil, err + } + host, number, err := net.SplitHostPort(address) + value, parseErr := strconv.ParseUint(number, 10, 16) + if err != nil || parseErr != nil || value == 0 || host != "127.0.0.1" { + return nil, fmt.Errorf("docker returned a non-loopback local %s endpoint", kind) + } + endpoints[port] = address + } + return endpoints, nil +} + +func localScrapeHandler(token string) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) { + if subtle.ConstantTimeCompare([]byte(request.Header.Get("Authorization")), []byte("Bearer "+token)) != 1 { + http.Error(w, "unauthorized", http.StatusUnauthorized) + return + } + if request.URL.Path != "/metrics" { + http.NotFound(w, request) + return + } + MetricsHandler().ServeHTTP(w, request) + }) +} + +func localWaitHTTP(ctx context.Context, endpoint string) error { + ctx, cancel := context.WithTimeout(ctx, 45*time.Second) + defer cancel() + client := &http.Client{Timeout: time.Second} + ticker := time.NewTicker(100 * time.Millisecond) + defer ticker.Stop() + for { + request, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil) + if err != nil { + return err + } + response, err := client.Do(request) + if err == nil { + response.Body.Close() + if response.StatusCode == http.StatusOK { + return nil + } + } + select { + case <-ctx.Done(): + return fmt.Errorf("local observability did not become ready: %w", ctx.Err()) + case <-ticker.C: + } + } +} + +func (session *localObservability) Close() error { + var result error + // Flush after requests drain and before stopping the trace backend. + if session.tracer != nil { + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) + result = errors.Join(result, session.tracer.Shutdown(ctx)) + cancel() + if otel.GetTracerProvider() == session.tracer { + otel.SetTracerProvider(session.previous) + otel.SetTextMapPropagator(session.propagator) + } + } + if session.metrics != nil { + result = errors.Join(result, session.metrics.Close()) + } + for index := len(session.containers) - 1; index >= 0; index-- { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + _, err := session.docker(ctx, "rm", "--force", session.containers[index]) + cancel() + if err != nil && !strings.Contains(err.Error(), "No such container") { + result = errors.Join(result, err) + } + } + return errors.Join(result, os.RemoveAll(session.directory)) +} + +const localJaegerConfig = `extensions: + healthcheckv2: + use_v2: true + http: + endpoint: 0.0.0.0:13133 + jaeger_query: + storage: + traces: memory + jaeger_storage: + backends: + memory: + memory: + max_traces: 10000 +receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 +processors: + batch: {} +exporters: + jaeger_storage_exporter: + trace_storage: memory +service: + extensions: [healthcheckv2, jaeger_query, jaeger_storage] + pipelines: + traces: + receivers: [otlp] + processors: [batch] + exporters: [jaeger_storage_exporter] +` diff --git a/internal/fiberdintegration/local_observability_test.go b/internal/fiberdintegration/local_observability_test.go new file mode 100644 index 0000000..c218f68 --- /dev/null +++ b/internal/fiberdintegration/local_observability_test.go @@ -0,0 +1,268 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2026 The Hyperlight Authors. + +package fiberdintegration + +import ( + "context" + "errors" + "net" + "net/http" + "net/http/httptest" + "os" + "os/exec" + "path/filepath" + "slices" + "strings" + "testing" + "time" + + "github.com/hyperlight-dev/lampyr/internal/project" + "go.opentelemetry.io/otel" + sdktrace "go.opentelemetry.io/otel/sdk/trace" +) + +func TestLocalObservabilityLinksStayInServiceIndex(t *testing.T) { + router, client, route := routerFixture(t, project.ExecutionFresh) + requests := 0 + for _, enabled := range []bool{false, true} { + var telemetry *localObservability + if enabled { + telemetry = &localObservability{Prometheus: "http://127.0.0.1:19090", Jaeger: "http://127.0.0.1:16686"} + } + handler := localIngressHandler(router, map[string]string{"app.default.localhost": route.Revision}, "8080", telemetry) + for _, test := range []struct { + url string + status int + }{ + {"http://localhost:8080/", 200}, + {"http://127.0.0.1:8080/", 200}, + {"http://localhost:8080/metrics", 404}, + {"http://unknown.default.localhost:8080/", 404}, + } { + response := httptest.NewRecorder() + handler.ServeHTTP(response, httptest.NewRequest("GET", test.url, nil)) + body := response.Body.String() + if response.Code != test.status || !strings.Contains(body, "http://app.default.localhost:8080/") { + t.Fatalf("enabled=%v URL=%s status=%d body=%s", enabled, test.url, response.Code, body) + } + for _, link := range []string{"http://127.0.0.1:19090/query", "http://127.0.0.1:16686/search?service=lampyr-local"} { + if strings.Contains(body, link) != enabled { + t.Fatalf("enabled=%v, unexpected observability link %s: %s", enabled, link, body) + } + } + } + if client.next != requests { + t.Fatal("index or unknown path acquired a fiber") + } + response := httptest.NewRecorder() + handler.ServeHTTP(response, httptest.NewRequest("GET", "http://app.default.localhost:8080/metrics", nil)) + if response.Code != 200 || strings.Contains(response.Body.String(), "Observability") { + t.Fatalf("application /metrics was intercepted: %d %s", response.Code, response.Body.String()) + } + requests++ + } +} + +func TestLocalScrapeListenerRequiresSessionToken(t *testing.T) { + handler := localScrapeHandler("session-secret") + for _, test := range []struct { + path string + auth string + status int + }{ + {"/metrics", "", 401}, + {"/metrics", "Bearer wrong", 401}, + {"/metrics", "Bearer session-secret", 200}, + {"/", "Bearer session-secret", 404}, + } { + request := httptest.NewRequest("GET", test.path, nil) + request.Header.Set("Authorization", test.auth) + response := httptest.NewRecorder() + handler.ServeHTTP(response, request) + if response.Code != test.status { + t.Fatalf("%s %q = %d", test.path, test.auth, response.Code) + } + if test.status == 200 && (!strings.Contains(response.Body.String(), "go_goroutines") || + strings.Contains(response.Header().Get("Content-Type"), "text/html")) { + t.Fatalf("scrape did not return Prometheus exposition: %s", response.Body.String()) + } + } +} + +func TestLocalObservabilityOwnsOnlyItsContainersAndCleansStartupFailures(t *testing.T) { + ready := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + })) + defer ready.Close() + address := strings.TrimPrefix(ready.URL, "http://") + for _, fail := range []string{"", "create", "start", "port"} { + t.Run("fail-"+fail, func(t *testing.T) { + parent := t.TempDir() + var created, removed []string + var scrapeAddress string + previous := otel.GetTracerProvider() + docker := func(_ context.Context, args ...string) (string, error) { + if args[0] == "create" { + configs, err := filepath.Glob(filepath.Join(parent, "observability-*", "*")) + if err != nil { + t.Fatal(err) + } + for _, config := range configs { + info, err := os.Stat(config) + if err != nil || info.Mode().Perm()&0o004 == 0 { + t.Fatalf("container user cannot read configuration %s: %v", config, err) + } + } + name := args[slices.Index(args, "--name")+1] + created = append(created, name) + for index, arg := range args { + if arg == "--publish" && !strings.HasPrefix(args[index+1], "127.0.0.1::") { + t.Fatalf("public container port: %v", args) + } + } + if !slices.Contains(args, "--read-only") || !slices.Contains(args, "--cap-drop=ALL") { + t.Fatalf("missing container restrictions: %v", args) + } + if strings.Contains(name, "-prometheus-") { + configs, err := filepath.Glob(filepath.Join(parent, "observability-*", "prometheus.yml")) + if err != nil || len(configs) != 1 { + t.Fatalf("missing Prometheus config: %v %v", configs, err) + } + config, err := os.ReadFile(configs[0]) + if err != nil { + t.Fatal(err) + } + for _, line := range strings.Split(string(config), "\n") { + if strings.Contains(line, "host.docker.internal:") { + port := strings.Split(strings.Split(line, ":")[1], "\"")[0] + scrapeAddress = net.JoinHostPort("127.0.0.1", port) + } + } + } + } + if args[0] == fail { + return "", errors.New("injected " + fail + " failure") + } + if args[0] == "rm" { + if len(args) != 3 || args[1] != "--force" || !slices.Contains(created, args[2]) { + t.Fatalf("cleanup touched an unowned container: %v", args) + } + removed = append(removed, args[2]) + } + return address, nil + } + session, err := startLocalObservability(context.Background(), parent, docker) + if fail == "" { + if err != nil { + t.Fatal(err) + } + if session.Prometheus != ready.URL || session.Jaeger != ready.URL || otel.GetTracerProvider() == previous { + t.Fatal("local endpoints or tracer were not configured") + } + if err := session.Close(); err != nil { + t.Fatal(err) + } + if otel.GetTracerProvider() != previous { + t.Fatal("tracer provider was not restored") + } + } else if err == nil || !strings.Contains(err.Error(), "injected "+fail) { + t.Fatalf("missing startup failure: %v", err) + } + if len(created) == 0 || len(removed) != len(created) { + t.Fatalf("created=%v removed=%v", created, removed) + } + files, err := os.ReadDir(parent) + if err != nil || len(files) != 0 { + t.Fatalf("startup left configuration behind: %v %v", files, err) + } + if scrapeAddress != "" { + connection, err := net.Dial("tcp", scrapeAddress) + if err == nil { + connection.Close() + t.Fatal("cleanup left the scrape listener running") + } + } + }) + } +} + +func TestLocalObservabilityContainerConfigsReadableWithPrivateUmask(t *testing.T) { + if os.Getenv("LAMPYR_TEST_PRIVATE_UMASK") == "1" { + TestLocalObservabilityOwnsOnlyItsContainersAndCleansStartupFailures(t) + return + } + command := exec.Command("/bin/sh", "-c", `umask 077; exec "$@"`, "sh", + os.Args[0], "-test.run=^TestLocalObservabilityContainerConfigsReadableWithPrivateUmask$") + command.Env = append(os.Environ(), "LAMPYR_TEST_PRIVATE_UMASK=1") + if output, err := command.CombinedOutput(); err != nil { + t.Fatalf("restrictive umask: %v\n%s", err, output) + } +} + +type stalledLocalTraceExporter struct{} + +func (stalledLocalTraceExporter) ExportSpans(context.Context, []sdktrace.ReadOnlySpan) error { + return nil +} + +func (stalledLocalTraceExporter) Shutdown(ctx context.Context) error { + <-ctx.Done() + return ctx.Err() +} + +func TestLocalObservabilityTraceFlushTimeoutStillRemovesContainers(t *testing.T) { + var removed []string + session := &localObservability{ + directory: t.TempDir(), containers: []string{"owned-jaeger", "owned-prometheus"}, + tracer: sdktrace.NewTracerProvider(sdktrace.WithSyncer(stalledLocalTraceExporter{})), + previous: otel.GetTracerProvider(), propagator: otel.GetTextMapPropagator(), + docker: func(ctx context.Context, args ...string) (string, error) { + if err := ctx.Err(); err != nil { + return "", err + } + removed = append(removed, args[2]) + return "", nil + }, + } + started := time.Now() + if err := session.Close(); !errors.Is(err, context.DeadlineExceeded) { + t.Fatalf("trace flush error was lost: %v", err) + } + if len(removed) != 2 { + t.Fatalf("trace flush timeout prevented container cleanup: %v (after %s)", removed, time.Since(started)) + } +} + +func TestLocalObservabilityReadinessRespectsCancellation(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + cancel() + if err := localWaitHTTP(ctx, "http://127.0.0.1:1/status"); !errors.Is(err, context.Canceled) { + t.Fatalf("readiness did not stop with the session: %v", err) + } +} + +func TestLocalObservabilityKeepsDockerDesktopHostDNS(t *testing.T) { + for _, platform := range []string{"linux", "darwin"} { + t.Run(platform, func(t *testing.T) { + var createArgs []string + session := &localObservability{ + directory: t.TempDir(), platform: platform, + docker: func(_ context.Context, args ...string) (string, error) { + if args[0] == "create" { + createArgs = args + } + return "127.0.0.1:19090", nil + }, + } + if _, err := session.container(context.Background(), "prometheus", localPrometheusImage, + "prometheus.yml", []string{"9090"}); err != nil { + t.Fatal(err) + } + hostGateway := slices.Contains(createArgs, "--add-host=host.docker.internal:host-gateway") + if hostGateway != (platform == "linux") { + t.Fatalf("%s host routing overrides Docker Desktop's host DNS: %v", platform, createArgs) + } + }) + } +} From f373faaeada4771bced301f37cf70b78ede26fcc Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Tue, 24 Nov 2026 18:45:00 -0800 Subject: [PATCH 2/4] fixup! Add opt-in native dev observability and cleanup regressions Reproduce local observability tracing and container regressions Signed-off-by: James Sturtevant --- .../local_observability_test.go | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) diff --git a/internal/fiberdintegration/local_observability_test.go b/internal/fiberdintegration/local_observability_test.go index c218f68..809c6c9 100644 --- a/internal/fiberdintegration/local_observability_test.go +++ b/internal/fiberdintegration/local_observability_test.go @@ -5,7 +5,10 @@ package fiberdintegration import ( "context" + "encoding/csv" "errors" + "fmt" + "io" "net" "net/http" "net/http/httptest" @@ -13,15 +16,173 @@ import ( "os/exec" "path/filepath" "slices" + "strconv" "strings" "testing" "time" "github.com/hyperlight-dev/lampyr/internal/project" "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/propagation" sdktrace "go.opentelemetry.io/otel/sdk/trace" + "go.opentelemetry.io/otel/sdk/trace/tracetest" + "go.opentelemetry.io/otel/trace" ) +func TestLocalObservabilityPreservesIncomingTraceAcrossBinding(t *testing.T) { + previous, propagator := otel.GetTracerProvider(), otel.GetTextMapPropagator() + spans := tracetest.NewSpanRecorder() + provider := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(spans)) + otel.SetTracerProvider(provider) + otel.SetTextMapPropagator(propagation.TraceContext{}) + t.Cleanup(func() { + otel.SetTracerProvider(previous) + otel.SetTextMapPropagator(propagator) + _ = provider.Shutdown(context.Background()) + }) + backend, backClient, backRoute := routerFixture(t, project.ExecutionFresh) + backClient.handler = http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) { + fmt.Fprint(w, request.Header.Get("Traceparent")) + }) + binding := httptest.NewServer(localHandler(backend, backRoute.Revision, "/_lampyr/private")) + defer binding.Close() + frontend, frontClient, frontRoute := routerFixture(t, project.ExecutionFresh) + frontClient.handler = http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) { + call, err := http.NewRequestWithContext(request.Context(), http.MethodGet, binding.URL+"/_lampyr/private/", nil) + if err != nil { + t.Error(err) + w.WriteHeader(http.StatusInternalServerError) + return + } + call.Header.Set("Traceparent", request.Header.Get("Traceparent")) + response, err := http.DefaultClient.Do(call) + if err != nil { + t.Error(err) + w.WriteHeader(http.StatusBadGateway) + return + } + defer response.Body.Close() + w.WriteHeader(response.StatusCode) + _, _ = io.Copy(w, response.Body) + }) + handler := localIngressHandler(frontend, map[string]string{"app.default.localhost": frontRoute.Revision}, + "8080", &localObservability{}) + request := httptest.NewRequest(http.MethodGet, "http://app.default.localhost:8080/", nil) + const incomingID = "0123456789abcdef0123456789abcdef" + request.Header.Set("Traceparent", "00-"+incomingID+"-0123456789abcdef-01") + response := httptest.NewRecorder() + handler.ServeHTTP(response, request) + if response.Code != http.StatusOK || !strings.Contains(response.Body.String(), incomingID) { + t.Errorf("binding lost incoming trace: status=%d body=%s", response.Code, response.Body.String()) + } + acquisitions, servers := 0, 0 + for _, span := range spans.Ended() { + if span.SpanContext().TraceID().String() != incomingID { + t.Errorf("%s started a separate trace: %s", span.Name(), span.SpanContext().TraceID()) + } + if span.Name() == "lampyr.fiber.acquire" { + acquisitions++ + } + if span.SpanKind() == trace.SpanKindServer { + servers++ + } + } + if acquisitions != 2 || servers != 2 { + t.Errorf("missing ingress or binding spans: acquisitions=%d servers=%d", acquisitions, servers) + } +} + +func TestLocalObservabilityMountSourceUsesDockerCSV(t *testing.T) { + for _, directory := range []string{"/work/team,inc", `/work/team"quoted`, `/work/team,"quoted"`} { + t.Run(directory, func(t *testing.T) { + session := &localObservability{ + directory: directory, + docker: func(_ context.Context, args ...string) (string, error) { + if args[0] == "create" { + mount := args[slices.Index(args, "--mount")+1] + fields, err := csv.NewReader(strings.NewReader(mount)).Read() + if err != nil { + return "", fmt.Errorf("Docker mount CSV: %w", err) + } + want := "source=" + filepath.Join(directory, "jaeger.yaml") + if len(fields) != 4 || !slices.Contains(fields, want) { + return "", fmt.Errorf("Docker mount source split: %q, want %q", fields, want) + } + } + return "127.0.0.1:16686", nil + }, + } + if _, err := session.container(context.Background(), "jaeger", localJaegerImage, + "jaeger.yaml", []string{"16686"}); err != nil { + t.Fatal(err) + } + }) + } +} + +func TestLocalObservabilityRotationDoesNotInheritDaemonDriver(t *testing.T) { + for _, kind := range []string{"jaeger", "prometheus"} { + t.Run(kind, func(t *testing.T) { + session := &localObservability{ + directory: "/workspace", + docker: func(_ context.Context, args ...string) (string, error) { + if args[0] == "create" { + driver := "journald" + for index, arg := range args { + if arg == "--log-driver" && index+1 < len(args) { + driver = args[index+1] + } else if value, ok := strings.CutPrefix(arg, "--log-driver="); ok { + driver = value + } + } + if driver != "json-file" && driver != "local" { + return "", fmt.Errorf("logging driver %s does not support max-size/max-file", driver) + } + } + return "127.0.0.1:19090", nil + }, + } + if _, err := session.container(context.Background(), kind, "test-image", "config", []string{"9090"}); err != nil { + t.Fatal(err) + } + }) + } +} + +func TestLocalObservabilityPrometheusCompactionFitsTmpfs(t *testing.T) { + ready := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + })) + defer ready.Close() + docker := func(_ context.Context, args ...string) (string, error) { + if args[0] == "create" && slices.Contains(args, localPrometheusImage) { + // Prometheus preallocates a 512 MiB block chunk segment by default. + segmentBytes := int64(512 * 1024 * 1024) + for _, arg := range args { + if value, ok := strings.CutPrefix(arg, "--storage.tsdb.max-block-chunk-segment-size="); ok { + var err error + segmentBytes, err = strconv.ParseInt(strings.TrimSuffix(value, "MB"), 10, 64) + if err != nil { + return "", err + } + segmentBytes *= 1000 * 1000 + } + } + if segmentBytes > 128*1024*1024-96*1000*1000 { + return "", fmt.Errorf("compaction segment preallocation %d exceeds tmpfs space after retained data", segmentBytes) + } + } + return strings.TrimPrefix(ready.URL, "http://"), nil + } + session, err := startLocalObservability(context.Background(), t.TempDir(), docker) + if err != nil { + t.Fatal(err) + } + if err := session.Close(); err != nil { + t.Fatal(err) + } +} + func TestLocalObservabilityLinksStayInServiceIndex(t *testing.T) { router, client, route := routerFixture(t, project.ExecutionFresh) requests := 0 From dd7f6461a175068fd51e9077d32e68c040e70be8 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Tue, 24 Nov 2026 18:52:04 -0800 Subject: [PATCH 3/4] fixup! Add opt-in native dev observability and cleanup regressions Preserve inbound traces and bound local telemetry container behavior Signed-off-by: James Sturtevant --- docs/cli/dev.md | 4 +++- internal/fiberdintegration/local.go | 13 ++++++++----- internal/fiberdintegration/local_observability.go | 7 ++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/docs/cli/dev.md b/docs/cli/dev.md index 5eb0af1..bac4786 100644 --- a/docs/cli/dev.md +++ b/docs/cli/dev.md @@ -60,7 +60,8 @@ Open `http://localhost:8080/`. The service index includes an **Observability** section with links to Prometheus and Jaeger. Send requests to an exposed service. In Prometheus, query `lampyr_router_request_duration_seconds_count`. In Jaeger, select `lampyr-local`, then **Find Traces**. Telemetry includes -internal services reached through bindings. +internal services reached through bindings. Incoming trace IDs stay the same +across ingress and binding calls. This option needs Docker, not Kubernetes. The first run downloads pinned Prometheus and Jaeger images. Their browser endpoints use free loopback ports, @@ -73,6 +74,7 @@ Application routes, including `/metrics`, do not change. Data is temporary. On exit, the supervisor flushes traces, removes its two containers, and deletes their configuration. Prometheus retains up to one hour of metrics in memory-backed storage; Jaeger retains up to 10,000 traces. +Prometheus uses 16 MB chunk segments to keep compaction within its 128 MiB volume. Use `--metrics` as well if you want request text in the terminal. Without `--observability`, no telemetry containers or scrape listener start. diff --git a/internal/fiberdintegration/local.go b/internal/fiberdintegration/local.go index c4d1c42..5210b51 100644 --- a/internal/fiberdintegration/local.go +++ b/internal/fiberdintegration/local.go @@ -27,6 +27,7 @@ import ( consumer "github.com/Azure/fiberd/sdk/go/client" "github.com/hyperlight-dev/lampyr/internal/project" + "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ) type LocalService struct { @@ -605,6 +606,7 @@ func RunLocal(ctx context.Context, config LocalConfig) (returnErr error) { } func localHandler(router *Router, name, capability string) http.Handler { + dispatch := otelhttp.NewHandler(router, "lampyr.local") return http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) { if capability != "" { switch { @@ -630,10 +632,10 @@ func localHandler(router *Router, name, capability string) http.Handler { // Host headers cannot select another service through this endpoint. request.Host = name if capability == "" { - localForward(router, name, w, request) + localForward(dispatch, name, w, request) return } - localForward(router, name, &localBindingResponseWriter{ + localForward(dispatch, name, &localBindingResponseWriter{ ResponseWriter: w, capability: capability, requestURL: url.URL{ @@ -691,6 +693,7 @@ func (writer *localBindingResponseWriter) rewriteLocation() { } func localIngressHandler(router *Router, exposed map[string]string, port string, observability ...*localObservability) http.Handler { + dispatch := otelhttp.NewHandler(router, "lampyr.local") type serviceLink struct { Name string URL string @@ -748,7 +751,7 @@ func localIngressHandler(router *Router, exposed map[string]string, port string, fmt.Fprint(w, page.String()) return } - localForward(router, name, w, request) + localForward(dispatch, name, w, request) }) } @@ -766,11 +769,11 @@ var localIndexTemplate = template.Must(template.New("services").Parse(` `)) -func localForward(router *Router, name string, w http.ResponseWriter, request *http.Request) { +func localForward(dispatch http.Handler, name string, w http.ResponseWriter, request *http.Request) { request.Header.Del("K-Original-Host") request.Header.Set("Knative-Serving-Namespace", "default") request.Header.Set("Knative-Serving-Revision", name) - router.ServeHTTP(w, request) + dispatch.ServeHTTP(w, request) } func localBindingHost() (string, error) { diff --git a/internal/fiberdintegration/local_observability.go b/internal/fiberdintegration/local_observability.go index 86271b9..d96254b 100644 --- a/internal/fiberdintegration/local_observability.go +++ b/internal/fiberdintegration/local_observability.go @@ -107,7 +107,8 @@ scrape_configs: session.Jaeger = "http://" + jaeger["16686"] prometheus, err := session.container(ctx, "prometheus", localPrometheusImage, "prometheus.yml", []string{"9090"}, "--config.file=/etc/lampyr/config", "--storage.tsdb.path=/prometheus", - "--storage.tsdb.retention.time=1h", "--storage.tsdb.retention.size=96MB") + "--storage.tsdb.retention.time=1h", "--storage.tsdb.retention.size=96MB", + "--storage.tsdb.max-block-chunk-segment-size=16MB") if err != nil { return nil, err } @@ -140,8 +141,8 @@ func (session *localObservability) container(ctx context.Context, kind, image, c "--label", "lampyr.dev/local-observability=true", "--read-only", "--cap-drop=ALL", "--security-opt=no-new-privileges", "--user=10001:10001", "--memory=512m", "--pids-limit=128", - "--log-opt=max-size=1m", "--log-opt=max-file=1", - "--mount", "type=bind,source=" + filepath.Join(session.directory, config) + ",target=/etc/lampyr/config,readonly"} + "--log-driver=json-file", "--log-opt=max-size=1m", "--log-opt=max-file=1", + "--mount", `type=bind,"source=` + strings.ReplaceAll(filepath.Join(session.directory, config), `"`, `""`) + `",target=/etc/lampyr/config,readonly`} for _, port := range ports { args = append(args, "--publish", "127.0.0.1::"+port) } From 1ec37877a82de56ccc8caaa71e8ed5ff592e4c4f Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Tue, 24 Nov 2026 19:14:14 -0800 Subject: [PATCH 4/4] fixup! Add opt-in native dev observability and cleanup regressions Qualify cross-service trace propagation requirements in native dev docs Signed-off-by: James Sturtevant --- docs/cli/dev.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/cli/dev.md b/docs/cli/dev.md index bac4786..305a394 100644 --- a/docs/cli/dev.md +++ b/docs/cli/dev.md @@ -60,8 +60,10 @@ Open `http://localhost:8080/`. The service index includes an **Observability** section with links to Prometheus and Jaeger. Send requests to an exposed service. In Prometheus, query `lampyr_router_request_duration_seconds_count`. In Jaeger, select `lampyr-local`, then **Find Traces**. Telemetry includes -internal services reached through bindings. Incoming trace IDs stay the same -across ingress and binding calls. +internal services reached through bindings. The router preserves incoming trace +IDs. Applications must propagate trace context, such as the `traceparent` header, +on outgoing binding requests to keep calls in the same trace. This example +workspace does not forward trace context. This option needs Docker, not Kubernetes. The first run downloads pinned Prometheus and Jaeger images. Their browser endpoints use free loopback ports,