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

[feature request]: Support for Cloudflare Pages #96

Open
vanstinator opened this issue Mar 23, 2024 · 11 comments · May be fixed by #129
Open

[feature request]: Support for Cloudflare Pages #96

vanstinator opened this issue Mar 23, 2024 · 11 comments · May be fixed by #129

Comments

@vanstinator
Copy link

We're starting to use Cloudflare Pages at Plex for a new layer in our API. We're also heavy users of Datadog, and would like to be able to auto-instrument our Pages codebase so we have e2e traces across our backend stack.

I've been hacking on some support for this, and we have it working internally. Would you be interested in a taking a PR that adds support for CF Pages auto-instrumentation?

I have an in-progress hacked together branch on my fork main...vanstinator:otel-cf-workers:feat/cf-pages

The code ended up being almost identical to the fetch instrumentation. I think it will be relatively trivial to clean up my exploration work and land on a solution that extends the fetch functionality with a few additional lines of code and another function export.

If this sounds good I can probably schedule work to productionize the patch in the next month or two.

@jahands
Copy link
Collaborator

jahands commented Mar 23, 2024

Hey @vanstinator! Your branch looks like a pretty good start to me. Definitely welcome to PRs to add Pages support!

@dustinsmith1024
Copy link

@vanstinator - does Datadog provide a public trace endpoint or do you run your own public agent to send the data to?

@vanstinator
Copy link
Author

For the time being we're going to be running an agent. I'm not sure how we'll expose it yet, those discussions are still happening internally.

@jfsiii
Copy link

jfsiii commented Apr 13, 2024

I'd love to see this! We're running Remix on Workers Sites for now, but we won't be able to for long. The latest Remix (using Vite vs esbuild) doesn't support Workers Sites any longer because they're deprecated for full-stack apps

Screenshot 2024-04-13 at 4 04 55 PM

I'm working on the replacement now, and would be happy to help test this out

@jfsiii
Copy link

jfsiii commented Apr 15, 2024

@vanstinator are you opposed to opening the PR now so this can be merged and allow others to debug/contribute?

As I mentioned we'll soon need to use Pages for our Remix app and I'd love to have this (or be able to debug/fix any issues I find while testing)

@vanstinator
Copy link
Author

Hey @jfsiii I think I can make that happen. I'll lightly clean up my branch today and get a PR open!

@vanstinator vanstinator linked a pull request Apr 17, 2024 that will close this issue
@vanstinator
Copy link
Author

The PR is up!

@Pelps12
Copy link

Pelps12 commented Sep 3, 2024

Any progress on this issue?

@evanderkoogh
Copy link
Owner

Unfortunately not. I was forced to step back from maintaining this for the better part of a year and @jahands and co have done an amazing job at keeping the lights on, but didn't have a lot of time to work on adding new features.

I am back, so will spend some time over the next week or so to get my bearing and work on it again.

My first priority is to ship a 1.0 and get any breaking changes out of the way as much as I can. My next priority is to go through some of the PRs that implement new features and incorporate those too. That includes this one.

@vanstinator
Copy link
Author

I left the job that was building this out, and I don't have any personal projects on CF-workers where I'd need this unfortunately.

@n3oney
Copy link

n3oney commented Sep 11, 2024

fwiw this seems to work for Next.js:

// instrumentation.ts

import { OTLPExporter } from "@microlabs/otel-cf-workers";
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node";
import { registerOTel } from "@vercel/otel";

export function register() {
  registerOTel({
    serviceName: "nextjs-app",
    spanProcessors: [
      // @ts-expect-error  for some reason the type doesn't match but it actually works
      new SimpleSpanProcessor(
        new OTLPExporter({
          url: "yourURL",
          headers: {
            // req headers
          },
        }),
      ),
    ],
  });
}

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 a pull request may close this issue.

7 participants