Skip to content

Commit

Permalink
fix: remove logtail logging (#106)
Browse files Browse the repository at this point in the history
Currently pushing 8GB of logs per day. The contents of which are available in Cloudflare already (we do not log any further info). Errors are pushed to Sentry.

Also adds `multiformats` to the client dependencies which was resolved in #103 but was not mergable because it did not also update the lockfile.

---------

Co-authored-by: Duncan <[email protected]>
  • Loading branch information
alanshaw and legowerewolf authored Dec 17, 2024
1 parent 2c8557d commit eca3704
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 357 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,5 @@ jobs:
node-version: 16
- uses: bahmutov/npm-install@v1
- run: npm run typedoc --workspace packages/client
- uses: web3-storage/add-to-web3@v2
id: web3
with:
web3_token: ${{ secrets.WEB3_STORAGE_KEY }}
path_to_add: 'packages/client/generated-docs'
- run: echo added typedoc output to web3.storage. cid -- ${{ steps.web3.outputs.cid }}
- run: echo typedoc URL -- https://${{ steps.web3.outputs.cid }}.ipfs.nftstorage.link
- uses: Sibz/github-status-action@v1
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: 'API docs'
description: 'Preview of generated client API docs'
state: 'success'
sha: ${{github.event.pull_request.head.sha || github.sha}}
target_url: "https://${{ steps.web3.outputs.cid }}.ipfs.nftstorage.link"
- run: gh-pages -d generated-docs
if: ${{ steps.tag-release.outputs.releases_created }}
17 changes: 11 additions & 6 deletions package-lock.json

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

16 changes: 0 additions & 16 deletions packages/api/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Toucan from 'toucan-js'
import pkg from '../package.json'
import { Logging } from './utils/logs'

export interface Env {
NAME_ROOM: DurableObjectNamespace
Expand All @@ -13,8 +12,6 @@ export interface Env {
DEBUG?: string
SENTRY_RELEASE: string
ENV: string
log: Logging
LOGTAIL_TOKEN?: string
VERSION: string
BRANCH: string
COMMITHASH: string
Expand All @@ -41,17 +38,4 @@ export function envAll (req: Request, env: Env, ctx: ExecutionContext) {
pkg
})
: undefined

// Attach a `Logging` instance, which provides methods for logging and writes
// the logs to LogTail. This must be a new instance per request.
// Note that we pass `ctx` as the `event` param here, because it's kind of both:
// https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#syntax-module-worker
env.log = new Logging(req, ctx, {
token: env.LOGTAIL_TOKEN,
debug: env.DEBUG === 'true',
sentry: env.sentry,
version: VERSION,
branch: BRANCH,
commithash: COMMITHASH
})
}
13 changes: 7 additions & 6 deletions packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { Env, envAll } from './env'

declare global {
// These must be defined as parameters to esbuild.build() in buildworkermodule.js
var BRANCH: string
var COMMITHASH: string
var SENTRY_RELEASE: string
var VERSION: string
const BRANCH: string
const COMMITHASH: string
const SENTRY_RELEASE: string
const VERSION: string
}

const router = Router()
Expand Down Expand Up @@ -45,7 +45,9 @@ export default {
env = { ...env } // new env object for every request (it is shared otherwise)!
response = await router.handle(request, env, ctx)
} catch (error: any) {
env.log.error(error, ctx)
// eslint-disable-next-line no-console
console.error(error)
env.sentry?.captureException(error)

if (error instanceof HTTPError) {
response = addCorsHeaders(
Expand All @@ -59,7 +61,6 @@ export default {
)
}
}
await env.log.end(response)
return response
}
}
Expand Down
Loading

0 comments on commit eca3704

Please sign in to comment.