Comments (3)
So my work around implementation looks like this.
try {
RaygunMessage message;
message = RaygunServletMessageBuilder.New()
.SetRequestDetails(request)
.SetEnvironmentDetails()
.SetMachineName(InetAddress.getLocalHost().getHostName())
.SetExceptionDetails(throwable)
.SetClientDetails()
.Build();
this.executor.execute(new SubmitExceptionCommand(client, message));
} catch (UnknownHostException e) {
// error when handling errors, not much to do but log and fail
e.printStackTrace();
}
//
private final class SubmitExceptionCommand implements Runnable {
public SubmitExceptionCommand(RaygunClient client, RaygunMessage message) {
this.client = client;
this.message = message;
}
private final RaygunClient client;
private final RaygunMessage message;
@Override
public void run() {
client.Post(message);
}
}
Three things are slightly annoying.
- I can't get the builder out of the client without duplicating the code. Something like
.messageBuilderForException(
would help. - I can't add the servlet request to a non servlet client's builder,
- The Servlet builder should return specific subclasses in its methods, because you have to call
.SetRequestDetails(request)
first or it won't work
from raygun4java.
Just to clarify:
- messageBuilderForException() should take a Throwable, call
RaygunServletMessageBuilder.New().SetRequestDetails()...Build()
(with all the various parts of the message set, request, env, machineName etc), then return the resulting RaygunMessage? Or just call.New()
? - This should be by design as core.RaygunClient is built without the reference to
javax.servlet.http.HttpServletRequest
, as otherwise non-web projects would need to have a server on their classpath, or import the Maven deps even if they weren't otherwise used. The RaygunServletClient specifically does have this dependency (and the Play 2 client has its own Request object reference yet again) as it is used.
The non-servlet core.RaygunClient has no concept of web requests for that reason, to avoid the dependency - if this seems wrong let me know. - Just modified BuildServletMessage quickly to test this:
RaygunServletMessageBuilder.New()
//.SetRequestDetails(servletRequest)
.SetEnvironmentDetails()
.SetMachineName(InetAddress.getLocalHost().getHostName())
.SetExceptionDetails(throwable)
.SetClientDetails()
.SetVersion(_version)
.SetUser(_user)
.Build();
and that builds and sends the RaygunMessage as expected without setting the request at all. The New() instantiates the RaygunServletMessageBuilder, the inherited methods set their props then Build() sets and returns the final RaygunServletMessage so as long as New()'s called first and Build() last this should work - might be a different scenario I haven't repro'd here.
from raygun4java.
Closing this issue for now. If you wish to see this issue addressed please create a new issue or post within our forums (https://raygun.com/forums). Thank you.
from raygun4java.
Related Issues (20)
- RaygunServletMessageBuilder throws NPE when no user has been set HOT 3
- Plans for a logback appender? HOT 6
- Headless server RaygunEnvironmentMessage does not gather data HOT 6
- EnvironmentData not able to collect => WARN is spamming our logs
- raygun4java-play2 1.6.0 can't be resolved HOT 5
- Spammy environment errors when running server side. HOT 1
- Add BeforeSend hook HOT 1
- Add configuration for timeout on Send calls HOT 1
- How to integrate with Spring application? HOT 2
- Error without Throwable crashes HOT 1
- Add test scope to junit in pom.xml HOT 1
- InetAddress.getLocalHost().getHostName() throws UnkownHostException HOT 1
- Returning null from OnBeforeSend handler sends "null" message HOT 1
- RaygunServletMessageBuilder cannot handle empty values in query string
- Crash Reporting Environment show issues HOT 1
- Play 2.4 support HOT 4
- bug in Raygunclient sendUnhandled?
- is Java APM support officially supported? HOT 1
- Java 11 and ManagementFactory HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raygun4java.