- Add static/otel-rum.js: a framework-free browser script that captures
uncaught errors, unhandled promise rejections and failed resource loads,
translating them into OTLP log records POSTed to the existing /v1/logs
endpoint (source: frontend attribute) so they flow through the same
history/search/issue pipeline as backend telemetry.
- Add correlation-id support: traceHeaders() (manual) and same-origin
fetch auto-instrumentation inject a W3C traceparent header, so a
frontend error and the backend spans it triggered share a trace id and
can be found together via GET /api/traces/{traceId}.
- Add CORS handling (withCORS in cmd/server/main.go) on the OTLP HTTP
endpoints, required for any browser-origin POST.
- Add an optional shared ingest key (OTEL_INGEST_KEY, via '?key=' or
X-Otel-Ingest-Key) and a per-IP rate limit (20 rps/burst 50) on OTLP
HTTP ingestion, to scope/protect a public endpoint fed by a browser
script. Verified end-to-end (CORS preflight, cross-origin POST, ingest
key enforcement, rate limiting) against a running server.
- Serve static/otel-rum.js and agents_example.md as static HTTP routes so
both the script and the agent instructions doc are fetchable directly
from the base URL.
- Ignore the separately-cloned otel-ui/ frontend repo (has its own .git;
not meant to be nested into this repo's history).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
51 lines
945 B
Docker
51 lines
945 B
Docker
# UI build stage
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
FROM node:alpine AS ui-builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY otel-ui/ .
|
|
|
|
RUN npm install && npm run build
|
|
|
|
# Go build stage
|
|
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS go-builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY cmd/ ./cmd
|
|
COPY internal/ ./internal
|
|
|
|
# Copy built UI dist
|
|
COPY --from=ui-builder /app/dist ./otel-ui/dist
|
|
|
|
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -installsuffix cgo -o /go-otel ./cmd/server
|
|
|
|
# Final stage
|
|
FROM alpine:latest
|
|
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
# Create non-root user
|
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
|
|
WORKDIR /home/appuser/
|
|
|
|
COPY --from=go-builder /go-otel .
|
|
COPY --from=go-builder /app/otel-ui/dist ./dist
|
|
COPY static/ ./static
|
|
COPY agents_example.md .
|
|
|
|
# Ensure the appuser owns the files
|
|
RUN chown -R appuser:appgroup /home/appuser/
|
|
|
|
USER appuser
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["./go-otel"]
|