Home > Back-end >  How to add Faraday request body into Datadog tracing in a Rails app
How to add Faraday request body into Datadog tracing in a Rails app

Time:12-18

I'm trying to configure Faraday tracing in a Rails application using Datadog.

I've set up the Faraday -> Datadog connection:

require 'faraday'
require 'ddtrace'

Datadog.configure do |c|
  c.use :faraday
end

Faraday.post("http://httpstat.us/200", {foo: 1, bar: 2}.to_json)
Faraday.get("http://httpstat.us/201?foo=1&bar=2")

It works well, the requests are being logged to Datadog.

But those logs do not contain any request parameters, nevertheless GET or POST.

GET request log POST request log

Any adviсe on how to get the request params/body logged to Datadog?

CodePudding user response:

So, by default the only things sent to Datadog from Faraday as part of the span in terms of the HTTP request are are:

      span.set_tag(Datadog::Ext::HTTP::URL, env[:url].path)
      span.set_tag(Datadog::Ext::HTTP::METHOD, env[:method].to_s.upcase)
      span.set_tag(Datadog::Ext::NET::TARGET_HOST, env[:url].host)
      span.set_tag(Datadog::Ext::NET::TARGET_PORT, env[:url].port)

Source: Post Get

NB: I am a Datadog employee, but not on the engineering team, just wanted to be transparent!

  • Related