GithubHelp home page GithubHelp logo

Comments (8)

willnewrelic avatar willnewrelic commented on July 19, 2024

Hi Dan

I presume you are using WrapHandle and/or WrapHandleFunc and would like to notice an error in one of your handlers? Use type assertion on the http.ResponseWriter:

func noticeError(w http.ResponseWriter, r *http.Request) {
    if txn, ok := w.(newrelic.Transaction); ok {
        txn.NoticeError(errors.New("my error message"))
    }
}

from go-agent.

danbrakeley avatar danbrakeley commented on July 19, 2024

So when I do that, I end up with 2 errors in new relic, not 1.

from go-agent.

willnewrelic avatar willnewrelic commented on July 19, 2024

Disabling the normal http response code error instrumentation (and using NoticeError) will be easier than modifying the agent. I recommend adding the following configuration:

cfg.ErrorCollector.IgnoreStatusCodes = []int{500, 501} // and any other codes

I understand the friction here: It would be nice to easily add some "why" context to the automatically captured response code errors. We will contemplate this.

from go-agent.

danbrakeley avatar danbrakeley commented on July 19, 2024

Excellent, that was what I was trying to get at. I was about to ask if there was a way to disable the default status code error. Thanks, I'll try that now!

from go-agent.

danbrakeley avatar danbrakeley commented on July 19, 2024

@willnewrelic Hmm, on second thought, this sucks. If I want to never have those errors fire, I need to list all 400 and 500 status codes?

Alternatively, I can add my error to the current transaction via AddAttribute, and in the new Error Analytics view, I can click on that custom attribute to get a listing by count of each error string. That seems like the best solution so far.

from go-agent.

willnewrelic avatar willnewrelic commented on July 19, 2024

Understood. A setting to disable status code errors entirely would be great here. We will discuss this.

Happy to hear the attribute/error-analytics approach is working!

from go-agent.

lpetre avatar lpetre commented on July 19, 2024

Are you suggesting a way to disable the status code errors per-transaction or globally?

from go-agent.

willnewrelic avatar willnewrelic commented on July 19, 2024

@lpetre Considering anything and everything! A transaction method for per-transaction disabling would be more powerful, but a global config setting in the Config would be simpler for customers that want to always have it disabled.

from go-agent.

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.