Skip to content
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

service names for apps in umbrella project #49

Open
tjstankus opened this issue Jun 2, 2022 · 1 comment
Open

service names for apps in umbrella project #49

tjstankus opened this issue Jun 2, 2022 · 1 comment

Comments

@tjstankus
Copy link

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!

@aselder
Copy link

aselder commented Jun 15, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants