Giter VIP home page Giter VIP logo

Comments (13)

thbar avatar thbar commented on June 3, 2024 1

@unflxw thanks for the quick feedback. I will try that out and see if this works, thank you!

from appsignal-elixir.

unflxw avatar unflxw commented on June 3, 2024 1

Perfect! Closing this for now, but feel free to re-open this (or reach out at [email protected]) if this doesn't work for you.

Also, as a public transit and open data aficionado, I am really thankful for the project that you're working on. 🎉

from appsignal-elixir.

thbar avatar thbar commented on June 3, 2024 1

My latest integration is a bit better. I must say it was a bit too involved for that type of things. Maybe having a more flexible way to achieve things (maybe a module name & function name in the config) could be nice, although the existing settings help already.

I think I have nailed it so far, thank you for your help.

from appsignal-elixir.

unflxw avatar unflxw commented on June 3, 2024

Hi @thbar!

You can denylist specific routes that you're not interesting in monitoring using the ignore_actions config option. Use the name by which those actions show up in the AppSignal "Performance > Actions" view.

Let us know whether this answers your question!

from appsignal-elixir.

thbar avatar thbar commented on June 3, 2024

Hi @unflxw!

It will work but only for a limited set of cases, because we have many of them. Is there a way to use regular expressions, or maybe a code block instead of a fixed list?

from appsignal-elixir.

thbar avatar thbar commented on June 3, 2024

(also, one action name is reported as GET /gbfs/*_, I am unsure if the filtering will actually work for this or not!)

from appsignal-elixir.

unflxw avatar unflxw commented on June 3, 2024

Is there a way to use regular expressions, or maybe a code block instead of a fixed list?

This does not currently exist out of the box, but I'm checking in with my colleagues for alternative solutions.

@thbar GET /gbfs/*_

That should be fine, but do let us know if it doesn't work!

from appsignal-elixir.

unflxw avatar unflxw commented on June 3, 2024

@thbar Here's a suggestion: in the code that handles those endpoints that you wish to ignore, set the root span's namespace to a fixed value (for example, "ignored"), and then configure the ignore_namespaces config option to ignore the "ignored" namespace.

Would that work for your use case?

from appsignal-elixir.

thbar avatar thbar commented on June 3, 2024

@unflxw I have tried adding a Plug to change the namespace, but the queries still pop up as "web" on the other side. I believe the namespace is probably re-written by the AppSignal integration itself (but I could not dig into that further).

For reference, my plug (which I didn't add to our app for now since it does not work) is:

defmodule TransportWeb.Plugs.AppSignalFilter do
  @moduledoc """
  An attempt to reduce the volume of events sent to AppSignal in order to keep a lower bill.

  This sets the namespace to a well-known "ignore" value, which must be added to the
  AppSignal `ignore_namespaces` config value.

  See: https://github.com/etalab/transport-site/issues/3274
  """

  def init(options), do: options
  require Logger

  def call(conn, _opts) do
    if function_exported?(Appsignal.Tracer, :root_span, 0) do
      if must_ignore?(conn) do
        Logger.info("Marking as ignore for AppSignal")

        Appsignal.Tracer.root_span()
        |> Appsignal.Span.set_namespace("ignore")
      end
    end

    conn
  end

  # this method allows us to filter programmatically as needed
  defp must_ignore?(conn) do
    conn.host =~ ~r/proxy/i or conn.request_path =~ ~r/\/gbfs/i
  end
end

I will try to move it further in the Plug pipeline, but I'm unsure if it will work or not.

from appsignal-elixir.

thbar avatar thbar commented on June 3, 2024

(I cannot re-open although I would like to!)

from appsignal-elixir.

unflxw avatar unflxw commented on June 3, 2024

Hi again @thbar! Sorry to hear that didn't work. As you said, it might be that this is taking place before the integration has created the root span, and it needs to be moved further up the pipeline.

I have consulted with a colleague who might have more information on how to proceed. In the meantime, could you check the value of Appsignal.Tracer.root_span() at that point in the code? For example:

def call(conn, _opts) do
  IO.puts(inspect(Appsignal.Tracer.root_span()))
  # ...

If it is nil, then the root span has not been created yet, and this code will do nothing -- it will need to be moved further up the pipeline, for example, to a Phoenix controller.

from appsignal-elixir.

thbar avatar thbar commented on June 3, 2024

It is indeed nil, so this explains that. I will try to move the code further down the line.

from appsignal-elixir.

unflxw avatar unflxw commented on June 3, 2024

I'm glad that worked! I agree that it can be a bit too complicated to fine-tune. I will share your feedback with the team.

from appsignal-elixir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.