Skip to content

zensum/ktor-sentry-feature

Repository files navigation

ktor-sentry - Sentry reporting for ktor

license

Ktor-sentry adds support for reporting unhandled exceptions in ktor to Sentry. Just set the SENTRY_DSN environment variable and install the feature in ktor and you're ready to go.

// Add an import...
import se.zensum.ktorSentry.SentryFeature

embeddedServer(Netty, 8080) {
    // ...and then in your server add the install
    install(SentryFeature)
}.start(wait = true)

Installation

First add jitpack.io to your dependencies

maven { url 'https://jitpack.io' }

And then our dependency

dependencies {
            compile 'com.github.zensum:ktor-sentry-feature:-SNAPSHOT'
}

Customization

Currently there are two customizable variables for the feature: The SENTRY_DSN to use which, per default, is fetched from the environment. The other variable appEnv sets the environment (e.g. prod or dev) the exceptions are reported as occurring within.

import se.zensum.ktorSentry.SentryFeature

embeddedServer(Netty, 8080) {
    install(SentryFeature){
        dsn = yourSentryDSN // Override the default of SENTRY_DSN
        appEnv = yourAppEnv // Set an enviorment such as prod or dev for reported exceptions
        serverName = yourServerName // Set the server name that will be used in exception reports
    }
}.start(wait = true)