DataDog / dd-trace-js

JavaScript APM Tracer
https://docs.datadoghq.com/tracing/
Other
637 stars 301 forks source link

Traces (auto-instrumentation) not showing up in APM console (Lambda/Express/serverless-http) #2524

Open Ranchman42 opened 1 year ago

Ranchman42 commented 1 year ago

I have been having issues getting auto-instrumentation working on a basic nodejs/express web server running in lambda.

Expected behaviour

Display trace data with middleware, type of request, url and etc.

Actual behaviour image

When calling the web server with a basic GET i only get the above partial traces, showing no real data about the function execution.

Steps to reproduce have the following lambda environment variables (along with DD_API_KEY set): image

Code:

lambda.js


// Modules;
const serverless = require("serverless-http");
const app = require("./server");

// Cache;
let handler;

// Handler;
exports.handler = async (event, context) => {
  if (!handler) {
    handler = serverless(app, {
      request: (request) => {
        request.serverless = { event, context };
      },
    });
  }

  const res = await handler(event, context);

  return res;
};

server.js

const express = require("express");
const { test } = require("./test");
const app = express();

app.use(express.json());

app.use(test);

app.get("/", (req, res) => {
  res.send("GET request to the homepage");
});

module.exports = app;

test.js

module.exports.test = async (req, res, next) => {
  console.log("test");
  next();
};

Packages installed:

  "dependencies": {
    "express": "^4.18.2",
    "serverless-http": "^3.1.0"
  }

Environment

Lambda Layer Config:

image

Finally, I have a number of other services running the serverless framework using fastify/express and they all work just fine.

astuyve commented 1 year ago

Hi, thanks for reaching out!

We've fixed this here. For now you can use v83 or earlier, a new fix should be ready shortly after the holidays.

Thanks!

Ranchman42 commented 1 year ago

Hello! Thanks for the response.

I tried with extension version 82 and 80 and got the same result.