Skip to content

Update functions_gen1.md example nodejs function #28786

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

Merged
merged 1 commit into from
Apr 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions content/en/serverless/google_cloud_run/functions_gen1.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,19 @@ The following example contains a sample function with tracing and metrics set up
```js
// Example of a simple Cloud Run Function with traces and custom metrics
// dd-trace must come before any other import.
const tracer = require('dd-trace').init();
const tracer = require('dd-trace').init()

require('@datadog/serverless-compat').start();

const functions = require('@google-cloud/functions-framework');

function handler(req, res) {
tracer.dogstatsd.increment('dd.function.sent', 1, {'runtime':'nodejs'});
return res.send('Welcome to Datadog💜!');
}
const handlerWithTrace = tracer.wrap('example-span', handler)

functions.http('httpexample', handlerWithTrace)
const handlerWithTrace = tracer.wrap('example-span', handler)

module.exports = handlerWithTrace
```
Expand Down
Loading