question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

create a config that allows to exclude spans from transactions

See original GitHub issue

There are cases where our users are interested in exclude certain spans from a transaction.

In order to achieve that we are going to create a new configuration named ignoreSpans. It will work the same way as ignoreTransactions config

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kyungeunnicommented, Nov 28, 2022

Hi @xirdneh! Thanks for your interest!!

Yes, for the time being you might consider using addFilter API to filter out spans you’d like to exclude. I think the example shown in the link might give you an idea of how to access the transactions and spans, but here’s the pseudo-code to demonstrate how you could manipulate the payload:

apm.addFilter(function (payload) {
  if (payload.errors) {
    payload.errors.forEach(function (error) {
      error.exception.message = error.exception.message.replace('secret', '[REDACTED]')
    })
  }
  if (payload.transactions) {
    payload.transactions.forEach(function (tr) {
      const filteredSpans = tr.spans.filter(span => shouldIncludeSpan);
      tr.spans = filteresSpans;
    })
  }
  return payload
})
...
function shouldIncludeSpan(span) {
    // some logic to filter span
    return true;
}

I will also keep you updated with the progress on the ignoreSpans . Thanks!!

0reactions
xirdnehcommented, Nov 30, 2022

@kyungeunni Thanks, this works great!

for future references it would be great if spans had attributes to know if it’s an HTTP request span and to easily grab the HTTP verb and URL. This would make it easier to filter out the unwanted spans. For now we had to do something like this to figure out if a span was an HTTP request and which URL it is using:

    apmClient.addFilter((payload) => {
      if (!payload.transactions) return payload;
      payload.transactions.forEach((transaction) => {
        const filteredSpans = transaction.spans.filter((span) => {
          const spanNameParts = span.name.split(' ');
          const url = spanNameParts.find((part) => part.startsWith('https://'));
          if (!url) return span;
          const spanUrl = new URL(url);
          if (!hostnamesToExclude.includes(spanUrl.hostname)) return span;
        });
        transaction.spans = filteredSpans;
      });
      return payload;
    });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Java agent configuration: Config file | New Relic Documentation
New Relic's Java agent config settings for APM, including transaction tracer, ... To identify the directory where the files are located, either create...
Read more >
newrelic-ruby-agent/newrelic.yml at dev - GitHub
This file configures the New Relic Agent. New Relic monitors Ruby, Java,. # .NET, PHP, Python, Node, and Go applications with deep visibility...
Read more >
Ignoring Unwanted Resources in APM - Datadog Docs
The ignore resources option allows resources to be excluded if the global root span of the trace matches certain criteria. See Exclude resources...
Read more >
Exclude a table from cloning
On the source instance, navigate to System Clone > Exclude Tables. · Click New. · Enter the table Name. Entering a parent table...
Read more >
All configuration options - Quarkus
AWS Lambda Type Default AWS Lambda Common Type Default AWS Lambda Gateway REST API Type Default Agroal ‑ Database connection pool Type Default
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found