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

Not getting individual messages from the Vercel serverless functions #68

Open
emirotin opened this issue Sep 19, 2023 · 0 comments
Open

Comments

@emirotin
Copy link

Hi there!

I have a project that is a simple web service developed with Vercel api directory—note, it's not the Next.js project, just a couple of individual functions.

Now, some background: one of my functions is doing a lot of web requests. It runs reasonably fast locally (14s), but times out in Vercel (there's a hard limit of 60s). So, the function logs a lot of intermediary messages, and I want to monitor them as it runs.

Now, with Vercel itself, I can only see the short tail, and only after the HTTP request completes.

So, I have set up Vercel integration, created the Logflare source, set up logs drain, converted all console logs in my app to pino, and set up pino with this lib like this:

import pino from "pino";
import { logflarePinoVercel } from "pino-logflare";

const { stream } =
	process.env.LOGFLARE_API_KEY && process.env.LOGFLARE_SOURCE_ID
		? logflarePinoVercel({
				apiKey: process.env.LOGFLARE_API_KEY,
				sourceToken: process.env.LOGFLARE_SOURCE_ID,
		  })
		: { stream: process.stdout };

const logger = pino(
	{
		level: "debug",
		base: {
			env: process.env.NODE_ENV,
			revision: process.env.VERCEL_GITHUB_COMMIT_SHA,
		},
	},
	stream,
);

export default logger;

Unfortunately, I don't get the individual logs in my logflare stream. Is this the reasonable thing to expect?

I get the build logs and the lambda calls logs. Inside that are unparsed pino messages. Trimmed the same way Vercel does it:

image

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

No branches or pull requests

1 participant