Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send metrics to datadog #6

Merged
merged 2 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,14 @@ Listening on port 3005
curl -XGET http://localhost:3005 add-mock-server ✱ ◼
{"message":"This is mock endpoint"}%
```

## Use datadog agent and Redis for docker compose

```
export DD_API_KEY=xxx
export DD_SITE=ap1.datadoghq.com
```

```
docker compose up
```
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.8'

services:
datadog:
image: datadog/agent:latest
container_name: datadog
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /proc/:/host/proc/:ro
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
environment:
- DD_SITE=${DD_SITE}
- DD_API_KEY=${DD_API_KEY}
- DD_DOGSTATSD_NON_LOCAL_TRAFFIC=1
ports:
- '8125:8125/udp'

redis:
image: redis:latest
ports:
- '6379:6379'
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"lint:eslint": "npx eslint --ext .ts src",
"lint:prettier": "prettier --check src",
"format": "prettier --write 'src/**/*.ts' && npx eslint --fix --ext .ts src",
"smoke:sample-product": "XK6_TS=false ./k6 run ./dist/loadTest.js -e CONFIG_PATH=../src/sample-product/configs/smoke.json",
"smoke-debug:sample-product": "XK6_TS=false ./k6 run ./dist/loadTest.js -e CONFIG_PATH=../src/sample-product/configs/smoke.json --http-debug=full"
"smoke:sample-product": "K6_STATSD_ENABLE_TAGS=true XK6_TS=false ./k6 run ./dist/loadTest.js --out output-statsd -e CONFIG_PATH=../src/sample-product/configs/smoke.json",
"smoke-debug:sample-product": "K6_STATSD_ENABLE_TAGS=true XK6_TS=false ./k6 run ./dist/loadTest.js --out output-statsd -e CONFIG_PATH=../src/sample-product/configs/smoke.json --http-debug=full"
},
"dependencies": {
"find-up": "^7.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/sample-product/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function debugOrLog(textToLog: string): void {
}
}

function formatDate(time: Date): string {
export function formatDate(time: Date): string {
const jstOffset: number = 9 * 60
const jstTime: number = time.getTime() + jstOffset * 60 * 1000

Expand Down
5 changes: 5 additions & 0 deletions src/sample-product/configs/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import * as env from '../common/env'
import { formatDate } from '../common/common'

export const OPTIONS_CONFIG = (): Record<string, unknown> => {
const defaultConfigs = {
blockHostnames: ['*.hogehoge.com'],
insecureSkipTLSVerify: true,
tags: {
env: 'local',
datetime: formatDate(new Date()),
},
}

const configs = JSON.parse(open(env.CONFIG_PATH))
Expand Down
Loading