A SvelteKit demo full-stack observability with Datadog integration Featuring both server-side and client-side logging.
PS: Readme down below & boiler plate implementation AI generated.
# Install from AUR
yay -S datadog-agent
# or
paru -S datadog-agent
NOTE: Official script with curl doesnt work on Arch
git clone https://github.com/yourusername/svelte-dog.git
cd svelte-dog
pnpm install
Create a .env file in the project root:
# Datadog Server-Side Configuration
DATADOG_API_KEY=your_api_key_here
DATADOG_SITE=datadoghq.eu
DD_ENV=dev
DD_SERVICE=svelte-dog
# Datadog Client-Side Configuration (get from Datadog UI)
PUBLIC_DATADOG_CLIENT_TOKEN=your_client_token_here
PUBLIC_DATADOG_SITE=datadoghq.eu
PUBLIC_DD_ENV=dev
PUBLIC_DD_SERVICE=svelte-dog
Getting Your Keys:
Edit the Datadog agent configuration:
sudo nano /etc/datadog-agent/datadog.yaml
Add:
api_key: your_api_key_here
site: datadoghq.eu
env: dev
logs_enabled: true
apm_config:
enabled: true
instrumentation:
enabled: host
data_streams:
enabled: true
profiling:
enabled: auto
Start the Datadog agent:
sudo systemctl start datadog-agent
sudo systemctl enable datadog-agent
sudo systemctl status datadog-agent
pnpm dev
Open http://localhost:5173 in your browser.
svelte-dog/
├── src/
│ ├── hooks.server.js # Global request/response logging
│ ├── routes/
│ │ ├── +layout.svelte # Initializes client logger
│ │ ├── +page.svelte # Cat facts UI component
│ │ └── api/
│ │ └── cat-fact/
│ │ └── +server.js # Cat facts API endpoint
│ └── lib/
│ ├── monitoring/
│ │ ├── server/
│ │ │ └── logger.js # Server-side Winston logger
│ │ └── client/
│ │ └── logger.js # Client-side Datadog logger
│ └── components/
│ └── ui/ # shadcn-svelte components
├── .env # Environment variables (not in git)
├── .env.example # Example environment variables
└── package.json
Global Request Logging (src/hooks.server.js):
API Endpoint Logging (src/routes/api/cat-fact/+server.js):
src/routes/+page.svelte):When a user clicks "Fetch Cat Fact":
/api/cat-factAll logs appear in Datadog with full context and correlation!
service:svelte-dog or env:dev