andym

andym

hi everyone, i have an aws ecs fargate container running and i’m trying to send tracing information to datadog (i’m using phoenix + liveview). to do that i’m using the spandex library GitHub - spandex-project/spandex: A platform agnostic tracing library · GitHub along with the datadog adapter GitHub - spandex-project/spandex_datadog: A datadog adapter for the `spandex` library. · GitHub. i have also configured the sidecar container for datadog as per the documentation. the monitoring data from the datadog agent running on ecs reaches datadog just fine, however the custom tracing information from my application does not reach datadog. this is the configuration i have in my code

application.ex

    spandex_opts = [
      host: "localhost",
      port: 8126,
      batch_size: 10,
      sync_threshold: 100,
      http: HTTPoison
    ]
    children = [
      # Start the Telemetry supervisor
      {SpandexDatadog.ApiServer, spandex_opts},
      App.Telemetry,
      # Start the PubSub system
      {Phoenix.PubSub, name: App.PubSub},
      # Start the Endpoint (http/https)
      App.Endpoint
    ]

config.exs

config :app, app.Endpoint,
  url: [host: "localhost"],
  render_errors: [view: app.ErrorView, accepts: ~w(html json), layout: false],
  pubsub_server: app.PubSub,
  live_view: [signing_salt: "dyhFo42f"]

config :app, app.Tracer,
  service: :app,
  adapter: SpandexDatadog.Adapter,
  disabled?: false,
  env: "PROD"

Now in one of the controller i just have the following to make sure the data is going accross

MansionWeb.Tracer.start_trace("about_us")
MansionWeb.Tracer.update_span(service: :mansion, type: :web)
    app.Tracer.start_span("span1")
    app.Tracer.update_span(service: :app, type: :web)
    app.Tracer.finish_span()

    app.Tracer.finish_span()
    app.Tracer.finish_trace()

however this trace information never makes it to the actual datadog traces.

Showing Posts 1 to 6

imsoulfly

imsoulfly

Hello,

have you checked that the api_server.ex module was able to actually send the traces to the sidecar instance?
SpandexDatadog has an undocumented config setting called verbose? that allows some debugging of what the api_server is doing.
Here is the related code: github link

andym

andym OP

thanks for the reply @imsoulfly , i had actually enabled this and this is all i see in the logs

02:47:53.968 [info] Adding trace to stack with 2 spans

i also don’t see any errors on the logs as well of the agent.

outside of this i don’t see anything else in the logs. it does not say if the messages were successfully sent to the agent or failed.

i can see the metrics coming from the datadog agent itself like the cpu percentage and so on, i think the problem is the communication from my application container to the datadog container.

also if it helps this is the container definition for my datadog agent

 {
    "Name": "datadog-agent",
    "Image": "public.ecr.aws/datadog/agent:latest",
    "logConfiguration": {
      "logDriver": "awslogs",
      "options": {
        "awslogs-region": "ap-southeast-2",
        "awslogs-stream-prefix": "${service_name}-dd-log-stream",
        "awslogs-group": "/ecs/${service_name}"
      }
    },
    "portMappings": [
      {
        "hostPort": 8126,
        "protocol": "tcp",
        "containerPort": 8126
      }
    ],
    "Environment": [
      {
        "Name": "DD_API_KEY",
        "Value": "<REAL _ KEY _ HERE>"
      },
      {
        "Name": "DD_APM_ENABLED",
        "Value": "true"
      },
      {
        "Name": "DD_SITE",
        "Value": "us3.datadoghq.com"
      },
      {
        "Name": "ECS_FARGATE",
        "Value": "true"
      },
      {
        "name": "DD_DOGSTATSD_NON_LOCAL_TRAFFIC",
        "value": "true"
      }
    ]
  }
imsoulfly

imsoulfly

The Spandex.ApiServer actually should in any case produce logs of the following kind when it triggers a sendout of the traces.

"Sending 1 traces, 1 spans."
"Trace: [<<a lot of structs>>]"

Just to confirm one thing. do you have the batch_size config in mind. You would need to at least collect 10 traces before the ApiServer process would consider sending the traces.

Also if the ApiServer would receive a response from the Datadog client it would produce this log line.

"Trace response: <<some response details>>"

More info about that config can be found here

andym

andym OP

the only response i see is messages like this

27/02/2023, 04:38:24 23:08:24.374 [info] Adding trace to stack with 2 spans

nothing apart from that, i also sent a bit of a load as well to get it above the 10 batch size but still nothing.

xlphs

xlphs

Try using netcat (nc) or telnet to check connectivity. Most likely the elixir app cannot reach datadog agent.

btw you can set the batch size to 1 to make debugging easier

andym

andym OP

thanks everyone for your replies, i finally got it working, and i can see the traces now. if anyone else is facing a similar problem amongst other things it was primarily because of the phoenix spandex, it was causing some version conflicts and httppoison was missing.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews