Replies: 10 comments 30 replies
-
|
I Don't think they support it :/ |
Beta Was this translation helpful? Give feedback.
-
|
As per RFC, |
Beta Was this translation helpful? Give feedback.
-
|
Any update on this issue? |
Beta Was this translation helpful? Give feedback.
-
|
bump, I am hoping that in the roadmap there are plans for a few integrations: the next cli is so nice, and it would be a shame to have to do custom server for these common things. |
Beta Was this translation helpful? Give feedback.
-
|
Not sure if you've tried this yet but we are temporarily using this workaround until we can come up with a better solution or support is added. This way, we can keep all of the NextJS goodies and not bother with a custom server. https://jake.tl/notes/2021-04-04-nextjs-preload-hack So with our setup, we're running this as our start script: |
Beta Was this translation helpful? Give feedback.
-
|
I've come to this discussion as I need similar support for New Relic. A closed github issue here newrelic/node-newrelic#295 gives a few pointers on how to do this without going down the custom server route but I'm not sure if it's working for everyone. I've managed to get it working as suggested where you alter the package.json scripts to pre load something before running Next --> I think I may have achieved the same thing by simply requiring the newrelic module at the top of |
Beta Was this translation helpful? Give feedback.
-
|
Maybe this is possibile now with _middleware? 🤔 |
Beta Was this translation helpful? Give feedback.
-
|
Something that I have done was to use the DataDog also specifies that you can run via CLI: https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/nodejs/?tab=containers#adding-the-tracer-via-command-line-arguments. NextJS specifies in their documentation about their CLI: https://nextjs.org/docs/api-reference/cli. # Specify Node Options
export NODE_OPTIONS='-r dd-trace/init'
# Specify DataDog Tracer Configurations
export DD_LOGS_INJECTION=true
export DD_RUNTIME_METRICS_ENABLED=true
# Run NextJS Command
next startYou will have to configure the DataDog tracer through environment variables: https://docs.datadoghq.com/tracing/trace_collection/library_config/nodejs/ |
Beta Was this translation helpful? Give feedback.
-
|
@jmrtnz94 There's nothing much there. I can share a reduced version with project specific parts removed. Newer versions of dd-trace might do this automatically but at least at the time it didn't. The idea is to be able to get requests to dynamic URL's to group under the same endpoint by replacing the dynamic parts with a placeholder. Similarly as Datadog seemed to be doing to API endpoint URL's of services using Java/.NET based frameworks. const queryMatcher = /^(.*)(\?.+)$/;
const nextDataHashMatcher = /^(\/_next\/data\/)[^/]+(.*)$/;
const localeMatcher = /^(.*)\/([a-z]{2})$/;
/**
* Generalize URL to facilitate resource name grouping.
* @param {string} requestUrl
*
* @see https://docs.datadoghq.com/tracing/configure_data_security/
* @see https://docs.datadoghq.com/tracing/troubleshooting/quantization/
**/
const generalizeUrl = (requestUrl) => {
let url = requestUrl.replace(queryMatcher, '$1');
// Strip cache-busting hash from Next.js page requests
if (nextDataHashMatcher.test(url)) {
return url.replace(nextDataHashMatcher, '$1{hash}$2');
}
// Replace locale with placeholder
if (localeMatcher.test(url)) {
url = url.replace(localeMatcher, '$1/{locale}');
}
return url;
}; |
Beta Was this translation helpful? Give feedback.
-
|
Does this work for vercel serverless API too? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to rely on NextJS built-in server as much as possible without relying on an external server like
expressorkoa. When I looked at integrating DataDog and NextJS server, all the examples use hooking up middleware that performs tracing to DataDog. This is one of the blogs that explains that.How could I integrate DataDog with built-in NextJS server?
Beta Was this translation helpful? Give feedback.
All reactions