Giter VIP home page Giter VIP logo

sentry-java's Introduction

Sentry

Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us Check out our open positions

Sentry SDK for Java and Android

GH Workflow codecov Discord Chat

Packages Maven Central Minimum Android API Version
sentry-android Maven Central 19
sentry-android-core Maven Central 19
sentry-android-ndk Maven Central 19
sentry-android-okhttp Maven Central 21
sentry-android-timber Maven Central 19
sentry-android-fragment Maven Central 19
sentry-android-navigation Maven Central 19
sentry-android-sqlite Maven Central 19
sentry-compose-android Maven Central 21
sentry-compose-desktop Maven Central
sentry-compose Maven Central
sentry-apache-http-client-5 Maven Central
sentry Maven Central 19
sentry-jul Maven Central
sentry-jdbc Maven Central
sentry-apollo Maven Central 19
sentry-apollo-3 Maven Central 19
sentry-kotlin-extensions Maven Central 19
sentry-servlet Maven Central
sentry-servlet-jakarta Maven Central
sentry-spring-boot Maven Central
sentry-spring-boot-jakarta Maven Central
sentry-spring-boot-starter Maven Central
sentry-spring-boot-starter-jakarta Maven Central
sentry-spring Maven Central
sentry-spring-jakarta Maven Central
sentry-logback Maven Central
sentry-log4j2 Maven Central
sentry-bom Maven Central
sentry-graphql Maven Central
sentry-quartz Maven Central
sentry-openfeign Maven Central
sentry-opentelemetry-agent Maven Central
sentry-opentelemetry-agentcustomization Maven Central
sentry-opentelemetry-core Maven Central
sentry-okhttp Maven Central

Useful links and docs

Blog posts

Samples

Development

This repository includes sentry-native as a git submodule. To build against sentry-native checked-out elsewhere in your file system, create a symlink sentry-android-ndk/sentry-native-local that points to your sentry-native directory. For example, if you had sentry-native checked-out in a sibling directory to this repo:

ln -s ../../sentry-native sentry-android-ndk/sentry-native-local

which will be picked up by gradle and used instead of the git submodule. This directory is also included in .gitignore not to be shown as pending changes.

Sentry Self Hosted Compatibility

Since version 3.0.0 of this SDK, Sentry version >= v20.6.0 is required. This only applies to self-hosted Sentry, if you are using sentry.io no action is needed.

Since version 6.0.0 of this SDK, Sentry version >= v21.9.0 is required or you have to manually disable sending client reports via the sendClientReports option. This only applies to self-hosted Sentry, if you are using sentry.io no action is needed.

Since version 7.0.0 of this SDK, Sentry version >= 22.12.0 is required to properly ingest transactions with unfinished spans. This only applies to self-hosted Sentry, if you are using sentry.io no action is needed.

Resources

  • Java Documentation
  • Android Documentation
  • Discussions
  • Discord Chat
  • Stack Overflow
  • Code of Conduct
  • Twitter Follow

sentry-java's People

Contributors

adinauer avatar bitsandfoxes avatar bruno-garcia avatar buenaflor avatar denrase avatar dependabot-preview[bot] avatar dependabot[bot] avatar evmetatron avatar getsentry-bot avatar github-actions[bot] avatar iker-barriocanal avatar kamilogorek avatar krystofwoldrich avatar lbloder avatar lucas-zimerman avatar maciejwalkowiak avatar marandaneto avatar markushi avatar metlos avatar mitsuhiko avatar neseleznev avatar philipphofmann avatar princeyesuraj avatar romtsn avatar stefanosiano avatar swatinem avatar tyrrrz avatar vaind avatar vestrel00 avatar wzieba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sentry-java's Issues

SSL issue with log4j SentryAppender

log4j.rootLogger=WARN, sentry

log4j.appender.sentry=net.kencochrane.sentry.SentryAppender
log4j.appender.sentry.sentry_dsn=https://:@app.getsentry.com/876

CertificateException: No subject alternative DNS name matching app.getsentry.com found

Adding origin URL to the Sentry 'Client Security' pane doesn't appear to solve the problem.

Please let me know if I can provide any additional details!

Many thanks, Drew

HTTP header values appear in Sentry as [u'value']

HTTP headers values are sent to Sentry as arrays which causes them to appear as [u'value']:

screen shot 2013-05-09 at 13 53 14

The documentation doesn't say whether the header values should be strings or arrays.

I think the correct action would be to send as strings if there is a single header value and as arrays when there are multiple values.

403 from log4j appender

java.io.IOException: Server returned HTTP response code: 403 for URL: https://app.getsentry.com/api/store/
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1403)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at net.kencochrane.sentry.RavenClient$MessageSender.send(RavenClient.java:323)
    at net.kencochrane.sentry.RavenClient.sendMessage(RavenClient.java:218)
    at net.kencochrane.sentry.RavenClient.captureMessage(RavenClient.java:256)
    at net.kencochrane.sentry.SentryWorker.sendToSentry(SentryWorker.java:70)
    at net.kencochrane.sentry.SentryWorker.run(SentryWorker.java:36)

double checked the api key and url.

any ideas?

UPD connection closed

I was wondering what would happen if the connection to the sentry server (in UDP) is closed (sentry restarting, network failure, etc.).

From my reading the socket is just dead and never attempts to reconnect.

If that's the case, what would be the best approach? Trying to reopen a socket if the current one is down? What if the network is still down, should it try again until the socket is successfully created?
Should the socket be closed every time and reopened every time (and if it fails, the event is ignored)?

Creation of an EventBuilder to avoid having one method per type of logged event

Currently when an exception is logged, there are four methods that can be called depending on the parameters you have or not.
Same when it's a message that is logged.

If the sentry API evolves and adds the possibility of more customisation there will be even more methods for each combination of parameters you could have or not.

Instead of doing that, it could be more practical to have only one method capture(Event) where the event is an already existing object containing every parameter and already set up entirely.

To make things even easier, it would be nice to have a builder that would allow to set some fields of that new object (that were previously parameters in captureException/captureMessage) and then automatically set up the default values for everything that hasn't been set yet.


I started some work that does exactly this: https://github.com/ColinHebert/raven-java/tree/07312d20e5/raven/src/main/java/net/kencochrane/raven/event

I'm going to work a bit more on that, but I wanted to know what was everyone thought on:

  • breaking the Client class so it only handles an already built Event (for now called LoggedEvent in my code)
  • forcing a separation between the object representation of an event used internally and a serialisation that would happen at the very last minute (right now it's in JSON, but technically if it's separated you could serialise that however you want).
  • having the sentry interfaces represented by actual objects that would build the additional content before the serialisation (actually it makes things a bit easier when you want to create a new custom sentry interface).

Docs about how to create SentryInterface and how to add them to JsonMarshaller

I'm trying to write my own implementation of SentryInterface to get data from Play! Framework request. But when I try to send event with such sentry interface i get error in console (not fatal thou):

26.04.2013 12:56:12 net.kencochrane.raven.marshaller.json.JsonMarshaller writeInterfaces
SEVERE: Couldn't parse the content of 'sentry.interfaces.Http' provided in controllers.Application$PlayHttpRequestInterface@1d77daaa.

Then I look into JsonMarshaller.java and see that only hard coded instances of InterfaceBinding were added and then processed.

Is there any way to add my own InterfaceBinding implementation to marshaller?

Should logback Maven dependency scope in provided scope?

https://github.com/kencochrane/raven-java/blob/master/raven-logback/pom.xml

 <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>

Should the above use <scope>provided</scope or sth like that?
(i really don't know the nature this project good enough to suggest it to change, it's really a question)

for now, I have to use the following to get it work

  <dependency>
            <groupId>net.kencochrane.raven</groupId>
            <artifactId>raven-logback</artifactId>
            <version>4.0</version>
            <exclusions>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

Is this version working with Sentry 4.0.10

Hi,
I was using raven-client with Sentry 4.0.4 and every thing was fine.
But after upgrading to 4.0.10 I got this message in sentry console:

Traceback (most recent call last):
File "/Users/jalal/apps/sentry/lib/python2.7/site-packages/sentry-4.0.10-py2.7.egg/sentry/utils/safe.py", line 17, in safe_execute
result = func(_args, *_kwargs)
TypeError: post_process() takes exactly 5 arguments (2 given)
[2012-04-18 06:46:40,487: ERROR/PoolWorker-1] Error processing 'post_process' on 'instancemethod': post_process() takes exactly 5 arguments (2 given)

I suspect maybe it relates to raven-java client which I use. Is this true?
Thanks,
Jalal Ashrafi

Non-Maven Support

What work would it entail to provide Jars of releases? Is there a service that makes this easier that we could pay for? Would it be easiest if we just had a public jenkins instance?

Usage naiveSsl in custom code

I tried to log messages with imported certificate and it works fine. However I don't want use this method on production site, at least for now. naiveSsl seems suitable option but I can not get it working. Can somebody suggest why snippet bellow does not work and produce SSLHandshakeException with JDK6

RavenClient cl = new RavenClient("...", null, true);
cl.captureMessage("Test message w/ naive SSL");

Also, would be great to see a couple of words about UDP usage in documentation. How I can use it? Replacing https:// with udp:// leads to "port out of range:-1"

I built raven-java from sources.

raven-logback-2.0-SNAPSHOT Doesn't Send Anything to Sentry

I set up the logback appender within my Java project but nothing seems to get sent to my Sentry server. Here is my appender:

    <appender name="SENTRY" class="net.kencochrane.raven.logback.SentryAppender">
        <sentryDsn>my sentry project url</sentryDsn>
    </appender>

I've tried manually sending a test message via net.kencochrane.raven.Client and that works as expected.

Also, the tests fails when trying to execute mvn clean install. I had to skip the tests in order to compile the jar. If this is related, is there an earlier version that is working?

Client API Spec

From the Sentry server perspective, we need all first-class and supported clients to provide a basic set of APIs.

In Java this used to exist, which made debugging and other various things easy, but with the latest refactoring things have gotten very abstract, and very complicated.

The gist of the API is here: http://sentry.readthedocs.org/en/latest/developer/client/index.html#client-usage-end-user

Most importantly, the client needs to be usable without log4j or any other logging framework (despite whatever your opinion is). Sentry isn't logging, and it's not appropriate to consider it only usable if you abstract it through standard logging.

What we need to be able to achieve are the following:

  • Easy client creation (this used to be new Raven(dsn))
  • Base APIs for the common cases: capture messages and exceptions, in whatever syntax is most fluid for Java (though really it should just be client.captureException)

We get quite a few questions regarding the Java integration (and its constant changing, or under-documented APIs), and its honestly become quite a burden trying to keep up with things.

(I realize I brought this up before, but at this point the Sentry team has to make a choice whether to keep supporting raven-java, or fork it)

Move setup-code to AppenderSkeleton.activateOptions()

The code inside the append() method should be as fast as possible. Having a synchronized block in there with setup-code will make it a lot slower than needed, as for example several threads trying to log at the same time will have to wait for their turn. It is better to move this code into an activateOptions() method instead.

Look at the ConsoleAppender for an example of how this is done.

NPE when used with Play

Play for some reason removes all the appenders on startup. This causes a NPE as worker has not been initialized:

Exception in thread "main" java.lang.NullPointerException
    at net.kencochrane.sentry.SentryQueue.shutdown(SentryQueue.java:35)
    at net.kencochrane.sentry.SentryAppender.close(SentryAppender.java:91)
    at org.apache.log4j.helpers.AppenderAttachableImpl.removeAllAppenders(AppenderAttachableImpl.java:141)
    at org.apache.log4j.Category.removeAllAppenders(Category.java:891)
    at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:726)
    at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:547)
    at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:415)
    at play.Logger.init(Logger.java:79)
    at play.Play.init(Play.java:206)
    at play.server.Server.main(Server.java:159)

Event location

Hello,

It seems that the "Location" of the exception in events is slightly off. Instead of giving either the line where the exception has been thrown or caught, it will be set to the first entry in the stacktrace which is often the main() method or Thread.run().

Cheers,

Colin

Change the groupId of the project

Related to #32

Currently the groupId of the project is net.kencochrane.
For the sake of clarity it would be probably better to change it to net.kencochrane.raven.

Feature request: Pass additional information to Sentry

Hi,

it would be nice if raven-java would pass additional information of the request in web applications to Sentry.

I've already done it and extended raven-java to do it. I don't know if it is the best way, but it works for me. Maybe you guys would do it another way.

But let me explain my approach. It's quite simple: I just put the corresponding information into the Log4J MDC. If a logging event occurs, Sentry can get this information. For example I use the following code (and a little bit more) in a javax.servlet.Filter.

      Map<String, Object> sentryInfo = new HashMap<String, Object>();
      HttpServletRequest servletRequest = (HttpServletRequest) request;
      HttpSession session = servletRequest.getSession();

//    {
//    "is_authenticated": true,
//    "id": "unique_id",
//    "username": "foo",
//    "email": "[email protected]"
//  }

      User user = (User) session.getAttribute("User");
      Map<String, Object> userInfo = new HashMap<String, Object>();
      userInfo.put("is_authenticated", false);
      userInfo.put("id", 0);
      if (user != null) {
        userInfo.put("is_authenticated", true);
        userInfo.put("id", user.getId());
        userInfo.put("username", user.getUsername());
        userInfo.put("email", user.getEmail());
      }
      sentryInfo.put("userInfo", userInfo);

      // ...
      // pass other information to the sentryInfo Map 
      // ...

      MDC.put("sentryInfo", sentryInfo);
      try {
        chain.doFilter(request, response);
      }
      finally {
        MDC.remove("sentryInfo");
      }

You can get the MDC from the Log4J LogginEvent. I pass the sentryInfo Map to RavenClient#buildJSON and extended the JSON what is built there.

It would be nice if you could extend raven-java this way and document the structure you would expect. Or, if you want, I can implement it. But I'm not very familiar with Git and GitHub.

Regards,
Christian

Group similar log entries

Hello,

I currently have a small problem with Sentry and raven-java.
It seems that when a same Exception (thrown from the same line and caught/logged at the same line) is logged twice with two different messages ("Unable to remove user X"/"Unable to remove user Y") two groups of events are created.

Is it possible to group those events? Most of the time I suppose that the "partial stacktrace" (from the moment when the exception is thrown to the moment when the exception is logged) is more relevant to define the similarity between two events than the message itself (that is, if the logged data is indeed an exception).

Cheers,

Colin

Is it possible to monitor JBoss application logs raven-java?

Hi,

Is it possible to use raven-java to monitor Jboss application logs?.

Could you please explain the purpose of "raven-1.0-SNAPSHOT.jar "?

I tried to use "raven-log4j-1.0-SNAPSHOT.jar" with Log4j but I am getting lots of error in the log.

Is "raven-1.0-SNAPSHOT.jar " can send logs directly to Sentry?

Can you please suggest a solution?

Thanks in Advance,

Arun S

Mark some "common" stackframes as not "in_app".

I was wondering if it would be relevant to use the in_app parameter in the stacktrace interface in order to hide some of the most common stackframes.

The IDE I use for example automatically hides some parts of the stacktrace such as the java.* or com.sun.*.

Any thoughts?

Settings in IntelliJ (actually those are places where the debbuger won't try to step into, but the first elements of the list are relevant to that issue)
Screen Shot 2013-04-05 at 15 52 29

Tags as Map<String, Collection<String>>

I'm not sure I understand why the tags for messages are handled as Map<String, ?> instead of a Map<String, Collection<String>>.

If I understand the documentation correctly what is expected in the end is a collection String. Why not enforcing that?

It would also be possible to add a tool to convert a String to a Collection<String> if needed, but internally the type of the values in the Map should be known

Better support for exceptions

I need to dig into this more, so this ticket is mostly investigate, but the gist is that a formatted traceback might look something like this:

org.springframework.security.authentication.AuthenticationServiceException: Authentication failed 
at com.foobar.core.security.processor.AuthenticationProcessorImpl.authenticate(AuthenticationProcessorImpl.java:88)  

Where in Sentry, we end up with a somewhat-incorrect traceback:

Caused by: org.springframework.security.authentication.AuthenticationServiceException ("Authentication failed") ? at line -1
com.foobar.core.security.processor.AuthenticationProcessorImpl ? in authenticate at line 88

The big things here being:

  1. Caused by should actually be part of the Exception interface
  2. We're not recording a filename (though I'm not sure whats all available there)

There might be some additional things to clean up here as well.

Of note, I'm going to change how Java (and more importantly language-based) tracebacks look so they feel more natural to each individual platform.

Easier message/event creation

I may be missing it, but there doesn't seem to be an obvious way to do two simple things:

  • Capture a message
  • Capture an exception

Looking at SentryHandler.java:buildEvent, it feels like most of this code could be thrown into a CaptureException method and made general purpose.

The Sentry spec suggests two apis for these:

  • Client->CaptureException(exception)
  • Client->CaptureMessage(message)

Default to env['SENTRY_DSN'] if none is passed

We should allow the client to be configurable via an environment DSN variable (its common on the Heroku platform, and supported by PHP and Python).

Being that I have no idea how Java works, I'm only somewhat confident this is possible, but ideally it would just look like:

RavenClient client = new RavenClient()

NetworkOnMainThreadException for SentryAppender on Android

it's obviously an Androids specific issue :-) But i somehow think flushing log to network shouldn't happen in the main thread even for a JSE app. It isn't hard to store the events in a queue and run a thread to flush the log events at a configurable interval.

p.s. I'm using the latest 4.1-SNAPSHOT as of this moment.

I/System.out( 2669): 09:09:31,390 |-ERROR in net.kencochrane.raven.logback.SentryAppender[Sentry] - Appender [Sentry] failed to append. android.os.NetworkOnMainThreadException
I/System.out( 2669):    at android.os.NetworkOnMainThreadException
I/System.out( 2669):    at  at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
I/System.out( 2669):    at  at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
I/System.out( 2669):    at  at java.net.InetAddress.getLocalHost(InetAddress.java:365)
I/System.out( 2669):    at  at net.kencochrane.raven.event.EventBuilder$HostnameCache.updateCache(EventBuilder.java:343)
I/System.out( 2669):    at  at net.kencochrane.raven.event.EventBuilder$HostnameCache.getHostname(EventBuilder.java:330)
I/System.out( 2669):    at  at net.kencochrane.raven.event.EventBuilder.autoSetMissingValues(EventBuilder.java:79)
I/System.out( 2669):    at  at net.kencochrane.raven.event.EventBuilder.build(EventBuilder.java:277)
I/System.out( 2669):    at  at net.kencochrane.raven.logback.SentryAppender.buildEvent(SentryAppender.java:131)

How to configure to work with elasticsearch

Hey all,

Firstly, thanks for this library! I am hoping this will be the answer to my dreams!

I am trying to configure elasticsearch to report errors to my sentry instance.

I have editted my logging.yml to look like:

appender:
console:
type: console
layout:
type: consolePattern
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"

file:
type: dailyRollingFile
file: ${path.logs}/${cluster.name}.log
datePattern: "'.'yyyy-MM-dd"
layout:
type: pattern
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"

index_search_slow_log_file:
type: dailyRollingFile
file: ${path.logs}/${cluster.name}_index_search_slowlog.log
datePattern: "'.'yyyy-MM-dd"
layout:
type: pattern
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"

index_indexing_slow_log_file:
type: dailyRollingFile
file: ${path.logs}/${cluster.name}_index_indexing_slowlog.log
datePattern: "'.'yyyy-MM-dd"
layout:
type: pattern
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"

sentry:
type: net.kencochrane.sentry.SentryAppender
dsn: "http://XXX:[email protected]/9"
threshold: ERROR

And I have added:

rootLogger: INFO, console, file, sentry

I have grabbed the following from the sonatype site

raven-4.0-20130509.125810-7.jar
raven-log4j-4.0-20130509.125829-7.jar
raven-logback-4.0-20130509.125843-7.jar

and have placed them in /usr/share/elasticsearch/lib

I am triggering an error:

[2013-05-16 10:39:40,987][DEBUG][action.bulk ] [Sweetface] [haystack][3] failed to execute bulk item (index) index
[skipped some data]
org.elasticsearch.index.mapper.MapperParsingException: failed to parse [attributename]
at org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:396)
at org.elasticsearch.index.mapper.object.ObjectMapper.serializeObject(ObjectMapper.java:515)
at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:457)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:506)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:450)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:326)
at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:157)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.elasticsearch.ElasticSearchIllegalArgumentException: unknown property [hey]
at org.elasticsearch.index.mapper.core.StringFieldMapper.parseCreateField(StringFieldMapper.java:281)
at org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:385)

And I still have no sentry events.

Can you please help me?

Bundling getsentry.com SSL

Wanted to bring this discussion up again.

As far as I can tell the only way we can guarantee support of getsentry.com is by bundling the SSL certification with the client and adding a bit of code.

I had a couple thoughts about this:

  • We could straight up bundle our cert with the package
  • If we don't already, we should have a hook for specifying your certificate, and then we could create something like a raven-java-getsentry that pulls in raven-java + our cert

I'm a huge fan of bundling the certificate assuming it's not a huge amount of bloat/trouble, since a good portion of users end up going w/ the hosted solution.

(FYI we solved this temporarily by allowing HTTP connections, which made me caremad a little bit :)

commons-codec issues on Android

I need more time to verify this issue, but obviously, anyone who try using raven-java on Android will get the error so let me add the issue for record first.

  1. if i don't do any special configurations, it results as
java.lang.NoClassDefFoundError: org.apache.commons.codec.binary.Base64OutputStream
  1. if i include commons-codec 1.8, the exception becomes
ava.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.<init>
at org.apache.commons.codec.binary.Base64OutputStream.<init>(Base64OutputStream.java:65) ~[na:0.0]

my app doesn't use commons-codec, so i discard this change to fix the root dependency issue.
3. raven-java uses Apache Commons Codec 1.8 as I see in the pom.xml, but for some reasons, if i don't do any exclusions, "mvn dependency:tree -Dverbose -Dincludes=commons-collections"

[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ android ---
[INFO] MY_PACKAGE:apk:0.2
[INFO] +- net.kencochrane.raven:raven-logback:jar:4.1-SNAPSHOT:compile
[INFO] |  \- net.kencochrane.raven:raven:jar:4.1-SNAPSHOT:compile
[INFO] |     \- commons-codec:commons-codec:jar:1.3:compile
[INFO] \- org.robolectric:robolectric:jar:2.0:test
[INFO]    \- (commons-codec:commons-codec:jar:1.3:compile - scope updated from test; omitted for duplicate)
  1. added exclude for robolectric and then the dependency becomes normal again. The app can start now, but got the following exception
java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.<init>
  1. According to http://stackoverflow.com/questions/2047706/apache-commons-codec-with-android-could-not-find-method, Android's platform uses Apache Commons Codec 1.2. Apparently, Android's default classloader do parent-first, and there is no way to change to parent-last (that makes more sense to me). It seems most ppl choose to workaround by avoid using commons-codec's base64 library (rather than making complaints to Google)

Do you think raven-java should make any change to workaround an issue specific to Android?

Allow SENTRY_DSN to be optional

It would be great if the absence of SENTRY_DSN env variable (and the equivalent log4j setting) would be silent and not yield a RuntimeException when a log4j configuration flag is set. This would allow deployment environments, such as unit testing on CI servers, that lack the presence of Sentry, to be able to run without additional configuration.

SSL Certificates

Odd place for this, but seems like the easiest way to reach out to everyone here.

I want to identify the best possible solution for SSL use on getsentry.com and the JRE.

I know currently that our certificate's CA isn't installed a large chunk of the time, so my question is this:

  1. Is there a better more compatible provider that is generally available with the JRE? (e.g. does Thawte work?)
  2. Is it too-painful to ask people to add the CA to the keystore?
  3. Should we simply document how to run with verification disabled (at least on getsentry.com)?

log4j fails to send...but does send when calling RavenClient in same method?

log4.properties

log4j.rootLogger=WARN, sentry

log4j.appender.sentry=net.kencochrane.sentry.SentryAppender
log4j.appender.sentry.sentry_dsn=https://API:[email protected]/3211

pom

<dependency>
  <groupId>net.kencochrane</groupId>
  <artifactId>raven-java</artifactId>
  <version>0.5</version>
  <scope>test</scope>
</dependency>

test

public class MyTest
{
    private static Logger LOG = Logger.getLogger(MyTest.class);

    @Test
    public void shouldSentry()
    {
        // configure log4j the normal way, and then just use it like you normally would.

        LOG.debug("Debug example"); // ignored
        LOG.error("Error example"); // sent to sentry
        LOG.info("info Example"); // ignored

        try {
            throw new RuntimeException("Uh oh!");
        } catch (RuntimeException e) {
            LOG.error("Error example with stacktrace", e); //sent to sentry
        }

    }
}

This is the simplest form of test I can think of, however, it does not work.

My API KEY is correct as adding the code below to my test delivers both log and direct raven log in Sentry dashboard.

RavenClient client = new RavenClient("https://API:[email protected]/3211");

// record a simple message
client.captureMessage("hello world!");

// capture an exception
try {
     throw new RuntimeException("Uh oh!");
}
    catch (Throwable e) {
        client.captureException(e);
}

Does anyone know what I've done wrong? Or is this a bug?

Thanks

Can't find package in Maven

I've tried to add raven to our project using maven but can't resolve the dependency. I also tried searching the repos for the group Id mentioned but nothing comes up at all. Has it been removed, or am I missing something?

NullPointerException in SentryAppender when null in varargs

NPE in SentryAppender when using

log.info("anything {}", null);
I/System.out(27537): 18:24:07,775 |-ERROR in net.kencochrane.raven.logback.SentryAppender[Sentry] - Appender [Sentry] failed to append. java.lang.NullPointerException
I/System.out(27537):    at java.lang.NullPointerException
I/System.out(27537):    at  at net.kencochrane.raven.logback.SentryAppender.formatArguments(SentryAppender.java:47)
I/System.out(27537):    at  at net.kencochrane.raven.logback.SentryAppender.buildEvent(SentryAppender.java:103)

Line 47 of SentryAppender shall expect null.

private static List<String> formatArguments(Object[] argumentArray) {
        List<String> arguments = new ArrayList<String>(argumentArray.length);
        for (Object argument : argumentArray) {
            /** line 47: */ arguments.add(argument.toString()); /** argument can be null */
        }
        return arguments;
    }

Have queue of request to send to sentry (log4j)

Rather than having the the appender make the network call (which may timeout) it would be better to have a background thread perform the posting of messages and the append just put the messages into a queue.

Otherwise network issues could cause an application to slow to a crawl waiting for logging request to complete.

The queue should be size limited to that it doesn't eat up all the heap.

Events are not showing up in Sentry

Hello,

I'm trying to setup Raven-java to send unhandled exceptions to hosted sentry.
However, no exceptions are showing up in Sentry.

This is the simple code I'm using:

 Event event = new EventBuilder()
                    .setMessage(e.getMessage())
                    .addSentryInterface(new ExceptionInterface(e))
                  .build();

    raven.sendEvent(event);

Nothing is showing up in Sentry though. I've debugged the raven.sendEvent and as far as I can tell the response when submitting the event is a HTTP 301. What am I doing wrong here?

I've setup my DSN to use the http interface (since the SSL certificate is not accepted).

This is the actual HTTP request being sent:

POST /api/9045/store/ HTTP/1.1
User-Agent: Raven-Java/4.0
X-Sentry-Auth: Sentry sentry_version=4,sentry_client=Raven-Java/4.0,sentry_key=<redacted>,sentry_secret=<redacted>
Host: app.getsentry.com
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-type: application/x-www-form-urlencoded
Content-Length: 2268

And the response:

HTTP/1.1 301 Moved Permanently
Content-length: 0
Location: https://app.getsentry.com
Connection: close

Any ideas? Is getsentry.com only allowing HTTPS?
I've also tried using UDP, but those events aren't showing up either.

Remove InitialContext dependency in Dsn for Android compatibility

In Android, it doesn't allow Dsn to reference to InitialContext. (even if the dnsLookup is not executed) As dnsLookup is optional, I suggest to move the logic elsewhere to allow Android users to use this library. thx

E/dalvikvm(16669): Could not find class 'javax.naming.InitialContext', referenced from method net.kencochrane.raven.Dsn.dsnLookup
W/dalvikvm(16669): VFY: unable to resolve new-instance 5051 (Ljavax/naming/InitialContext;) in Lnet/kencochrane/raven/Dsn;
D/dalvikvm(16669): VFY: replacing opcode 0x22 at 0x0001
W/dalvikvm(16669): VFY: unable to resolve exception class 5053 (Ljavax/naming/NoInitialContextException;)
W/dalvikvm(16669): VFY: unable to find exception handler at addr 0x21
W/dalvikvm(16669): VFY:  rejected Lnet/kencochrane/raven/Dsn;.dsnLookup ()Ljava/lang/String;
W/dalvikvm(16669): VFY:  rejecting opcode 0x0d at 0x0021
W/dalvikvm(16669): VFY:  rejected Lnet/kencochrane/raven/Dsn;.dsnLookup ()Ljava/lang/String;
W/dalvikvm(16669): Verifier rejected class Lnet/kencochrane/raven/Dsn;
D/AndroidRuntime(16669): Shutting down VM
W/dalvikvm(16669): threadid=1: thread exiting with uncaught exception (group=0x40aef3a8)
E/AndroidRuntime(16669): FATAL EXCEPTION: main
E/AndroidRuntime(16669): java.lang.VerifyError: net/kencochrane/raven/Dsn

Raven 4.0 & Sentry 5.5.0-DEV - NPE on StackTraceInterface usage

Is the following code a working code for Sentry 5.5.0-Dev version & Raven 4.0.

Following code works without this line of code


.addSentryInterface(new StackTraceInterface(e.getCause().getStackTrace()))

public class SentryLogTest {
    public static void main(String[] args) {
        String rawDsn = "http://public:private@host:port/1";
        Raven client = RavenFactory.ravenInstance(new Dsn(rawDsn));
        EventBuilder eventBuilder = new EventBuilder();
        try {
            String s = null;
            s.toString();
        } catch (Exception e) {
            for (int i = 0; i < 10; i++) {
                eventBuilder
                        .setMessage("LOG : Sentry ERROR Test >> ID : ZZZZ")
                        .setLogger("com.lab.log")
                        .setLevel(Event.Level.ERROR)
                        .setCulprit("Sentry ERROR - Centralized Log Management")
                        .addSentryInterface(new StackTraceInterface(e.getCause().getStackTrace()))
                        .addTag("version", "0.1");

                client.sendEvent(eventBuilder.build());
            }

        }
    }
}

On Executing the above, Getting NPE.

Exception in thread "main" java.lang.NullPointerException
at com.lab.log.SentryLogTest.main(SentryLogTest.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Current build seems broken

I have run a git clone and then a mvn clean install -DskipTests=true

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project raven: Compilation failure
[ERROR] /Users/eamonnfaherty/Development/java/raven-java/raven/src/test/java/net/kencochrane/raven/connection/HttpConnectionTest.java:[121,8] cannot find symbol
[ERROR] symbol : method assertThat(java.util.List<java.util.logging.LogRecord>,org.hamcrest.Matcher<java.lang.Iterable<? super java.lang.Object>>)
[ERROR] location: class net.kencochrane.raven.connection.HttpConnectionTest
[ERROR] -> [Help 1]

Sentry Versions Supported

You can probably just note that it supports protocol version 2.0 (which is Sentry >= 2.0). The server itself generally should only make progressive forward-enhancement compatibility changes that shouldn't affect anything. so as long as it sends things in the appropriate format all should be right in the world.

Document how to run tests

It would be useful, at least to me, to know how to run tests :)

(This may be completely obvious, and if it is, just close this)

mvn test fails on osx with IllegalStateException

Running mvn clean test results in the following failure on osx

Running net.kencochrane.raven.AsyncTransportTest
java.lang.IllegalStateException: Native library for Attach API not available in this JRE
    at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:81)
    at mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:54)
    at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:21)
    at mockit.internal.startup.Startup.initializeIfNeeded(Startup.java:200)
    at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:215)
    at org.junit.runner.Runner.<clinit>(Runner.java:22)
    at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:51)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
    at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: java.lang.UnsatisfiedLinkError: sun.tools.attach.LinuxVirtualMachine.isLinuxThreads()Z
    at sun.tools.attach.LinuxVirtualMachine.isLinuxThreads(Native Method)
    at sun.tools.attach.LinuxVirtualMachine.<clinit>(LinuxVirtualMachine.java:364)
    at mockit.internal.startup.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:71)

GetSentry Org

Opening a ticket per a conversation we had the other day.

@kencochrane @ColinHebert what are your thoughts on moving this to the getsentry org and having us take over "official" maintainership (really nothing would change, we'd just open up visibility and provide a lot more inbound requests)

Attach HTTP request information to logs

Working in a Python/Java shop, I envy how Raven-Python automagically adds HTTP request information, as well as all the other good stuff. This is tremendously helpful for debugging issues of a web application. I think that Raven-Java should do the same.

However, since Java may be used in a wide array of different environments, it is difficult for Raven-Java to include support for every possible environment that deals with HTTP. What I propose is a plugin architecture, which allows people to include plugins relevant to their environments to their projects. In fact, since I need this badly, I have my own draft implementation already.

Due to the complexity of Java’s multi-threaded nature, I had to make extensive changes to Raven-Java, allowing plugins to be invoked at different stages of the log processing lifecycle. I felt it would be rude to open a pull request with a whole bunch of changes, so I’m posting this issue to see if anyone else is interested first.

Anyway, my plugin can be viewed at:
https://github.com/vvasabi/raven-java-servlet-plugin

Changes needed to make this work:
https://github.com/vvasabi/raven-java/compare/private

Note that these changes include ones from pull request #21. Also note that my implementation is not yet complete. Some more refactoring needs to be done.

Cheers.

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.