Skip to content

Commit

Permalink
Merge pull request #6 from gonkunkun/send-metrics-to-datadog
Browse files Browse the repository at this point in the history
Send metrics to datadog
  • Loading branch information
gonkunkun committed Apr 7, 2024
2 parents d196f2b + 693f9a2 commit 79e8cb4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
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

0 comments on commit 79e8cb4

Please sign in to comment.