spandex-project/spandex_datadog

service names for apps in umbrella project

Opened this issue · 1 comments

This is more of a question than an issue. Is it possible to emit traces using a service name that corresponds to the individual apps in an umbrella?

For example, if I have apps/a, apps/b, and apps/c with a's application.ex starting the SpandexDatadog.ApiServer, can I emit traces from b that would show up in datadog under the service name b?

I have an umbrella project that's structured like this and all the traces appear under the a service name.

Thanks!

Hey @tjstankus. I recently solved that by using Conn.put_private in a plug to store the app name, and pulled it out in a customize_metadata function.

def customize_metadata(conn) do
    service = Map.get(conn.private, :service, :elixir)

    meta =
      conn
      |> SpandexPhoenix.default_metadata()
      |> Keyword.put(:service, service)
      |> Keyword.put(:resource, compute_new_resource(conn))

    case conn.status in 500..599 do
      true -> Keyword.put(meta, :error, error?: true)
      false -> meta
    end
  end