Skip to content

Commit

Permalink
opentelemetry (plz dont break prod)
Browse files Browse the repository at this point in the history
  • Loading branch information
dromzeh committed May 27, 2024
1 parent 5a179f0 commit e973363
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"private": true,
"dependencies": {
"@microlabs/otel-cf-workers": "1.0.0-rc.38",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"itty-router": "^4.0.27",
"prettier": "^3.2.5",
Expand Down
224 changes: 224 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { router } from "@/handler";
import { instrument, ResolveConfigFn } from "@microlabs/otel-cf-workers";

export default {
const handler = {
fetch: router.handle,
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const config: ResolveConfigFn = (env: Env, _trigger) => {
return {
exporter: {
url: "https://otel.baselime.io/v1",
headers: { "x-api-key": env.BASELIME_API_KEY },
},
service: { name: env.SERVICE_NAME },
};
};

export default instrument(handler, config);
2 changes: 2 additions & 0 deletions src/worker-configuration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ interface Env {
bucket: R2Bucket;
database: D1Database;
DISCORD_LOG_WEBHOOK_URL: string;
BASELIME_API_KEY: string;
SERVICE_NAME: string;
}
6 changes: 4 additions & 2 deletions wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ compatibility_date = "2023-04-24"

account_id = "ba4e8f7f9ffbc23dba6acd0d9bd3ef46"
workers_dev = true
compatibility_flags = [ "nodejs_compat" ]

[vars]
SERVICE_NAME = "api-wanderer-moe"

[[r2_buckets]]
binding = 'bucket'
Expand All @@ -14,5 +18,3 @@ preview_bucket_name = 'wanderer-moe'
binding = 'database'
database_name = 'wanderer-moe-requests'
database_id = '9c180d14-7f79-45c6-b2f5-809b4e75941b'

[vars]

0 comments on commit e973363

Please sign in to comment.