Skip to content

Fastify wont capture body - fix proposed #3217

@ddoice

Description

@ddoice

Fastify

When instrumenting a fastify server the captureBody option wont work, it seems that the function getContextFromRequest is not able to recover the body.

To Reproduce

Steps to reproduce the behavior:

  1. Start the fastify server
  2. Then call some endpoint (tried both with and without error)
  3. Check kibana APM module and look for that transaction

image

Expected behavior

To have the body available in the transaction.

Environment (please complete the following information)

  • OS: Linux
  • Node.js version: 18.14.2
  • APM Server version: 7.6.1
  • Agent version: 3.43.0
  • Fastify version 4.13.0

How are you starting the agent? (please tick one of the boxes)

  • Calling agent.start() directly (e.g. require('elastic-apm-node').start(...))
  • Requiring elastic-apm-node/start from within the source code
  • Starting node with -r elastic-apm-node/start

Additional context

Agent config options:

Click to expand
    serverUrl: 'http://localhost:8200',
    logLevel: 'trace',
    verifyServerCert: false,
    captureBody: 'all',

package.json dependencies:

Click to expand
    "@fastify/sensible": "5.2.0",
    "@fastify/swagger": "8.3.1",
    "@fastify/swagger-ui": "1.5.0",
    "@prisma/client": "4.10.1",
    "@types/pg": "8.6.6",
    "elastic-apm-node": "^3.43.0",
    "fastify": "4.13.0",
    "fastify-plugin": "4.5.0",
    "fluent-json-schema": "4.1.0",
    "pg": "8.10.0"

Metadata

Metadata

Assignees

Labels

agent-nodejsMake available for APM Agents project planning.community

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions