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

feat: Hook up datadog logger #25

Merged
merged 2 commits into from
Feb 17, 2022
Merged

feat: Hook up datadog logger #25

merged 2 commits into from
Feb 17, 2022

Conversation

arv
Copy link
Contributor

@arv arv commented Feb 16, 2022

No description provided.

@arv arv requested a review from aboodman February 16, 2022 22:41
@vercel
Copy link

vercel bot commented Feb 16, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/rocicorp/replidraw-do/9UJZaujSgPYhosgnYW1mPFaXFUkg
✅ Preview: https://replidraw-do-git-fork-arv-datadog-rocicorp.vercel.app

@@ -33,7 +33,7 @@ export default function Home() {

const workerHost =
process.env.NEXT_PUBLIC_WORKER_HOST ??
"wss://reps.replicache.workers.dev";
"wss://replidraw-do.replicache.workers.dev";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aboodman Please confirm that this is correct

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current prod is using reps but I agree that doesn't make sense. I'm going to change it to just replidraw since replidraw-do is superfluous.

constructor(state: DurableObjectState, env: TODO) {
const abortController = new AbortController();
const logger = new DatadogLogger({
apiKey: env.DATADOG_API_KEY,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to come from env :'(

@arv arv marked this pull request as draft February 16, 2022 23:08
@arv
Copy link
Contributor Author

arv commented Feb 16, 2022

Converting to draft since I cannot get the CF secrets to work... Will try again tomorrow

@@ -33,7 +33,7 @@ export default function Home() {

const workerHost =
process.env.NEXT_PUBLIC_WORKER_HOST ??
"wss://reps.replicache.workers.dev";
"wss://replidraw-do.replicache.workers.dev";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current prod is using reps but I agree that doesn't make sense. I'm going to change it to just replidraw since replidraw-do is superfluous.

@@ -36,3 +36,5 @@ yarn-error.log*
$ CloudFlare worker
.mf/
tsconfig.tsbuildinfo
.env
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must define the env var in here for miniflare to work. See: https://miniflare.dev/core/variables-secrets

worker/index.ts Outdated
@@ -19,10 +19,6 @@ export class Server extends BaseServer<M> {
mutators,
state,
logger,
async onClose() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onClose gets fired when each connection gets torn down, not when the entire worker gets closed down. Thus it's not correct to abort the logger at this time -- it stops the logger from working after the first client disconnects.

I'm not sure if there is a way to know when the worker is getting shut down.

The relevant code in reps-do should also be removed.

@@ -1,7 +1,7 @@
name = "replidraw-do"
name = "replidraw"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm moving to this name.

type = "javascript"

account_id = "84dd7a44a4da314095315fb89b24251c"
account_id = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave this empty and login via wrangler instead. This makes it a bit easier for customers to reuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that is correct:

👀  You have multiple accounts.
🕵️  You can copy your account_id below
+--------------------------+----------------------------------+
| Account Name             | Account ID                       |
+--------------------------+----------------------------------+
| Arv@roci.dev's Account   | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+--------------------------+----------------------------------+
| Hello@roci.dev's Account | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+--------------------------+----------------------------------+
Error: field `account_id` is required

...but you can use environment variables instead:

CF_ACCOUNT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx wrangler dev

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wfm but I only have one account.

@aboodman aboodman marked this pull request as ready for review February 17, 2022 03:30
@aboodman aboodman merged commit 8a64086 into rocicorp:main Feb 17, 2022
@arv arv deleted the datadog branch February 17, 2022 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants