GithubHelp home page GithubHelp logo

isabella232 / periskop-scala Goto Github PK

View Code? Open in Web Editor NEW

This project forked from periskop-dev/periskop-scala

0.0 0.0 0.0 73 KB

Scala low level client for Periskop

License: Apache License 2.0

Scala 99.89% Makefile 0.11%

periskop-scala's Introduction

Periskop Scala Client

Build Status Maven Central

Periskop requires collecting and aggregating exceptions on the client side, as well as exposing them via an HTTP endpoint using a well defined format.

This library provides low level collection and rendering capabilities. Higher level libraries can be built be for better integration with specific libraries and frameworks.

Usage

Add periskop-scala to your SBT dependencies:

libraryDependencies += "com.soundcloud" %% "periskop-scala" % "<version>"

Create an exception collector instance:

val exceptionCollector = new ExceptionCollector

Collect some exceptions:

// An Exception Without Context
exceptionCollector.add(new RuntimeException("ups!"))

// A Message Without Context
exceptionCollector.addMessage("key", "some message")

// An Exception With Context
exceptionCollector.addWithContext(
  ExceptionWithContext(
    throwable = new RuntimeException("another ups!"),
    severity = Severity.Warning,
    httpContext = Some(HttpContext(
      requestMethod = "GET",
      requestUrl = "http://example.com/path?foo=bar",
      requestHeaders = Map("Accept" -> "text/plain"),
      requestBody = Some("body")
    )))
)

// A Message With Context
exceptionCollector.addWithContext(
  ExceptionMessage(
    aggregationKey = "key2",
    message = "some other message",
    severity = Severity.Info,
    httpContext = Some(HttpContext(
      requestMethod = "GET",
      requestUrl = "http://example.com/path?foo=bar",
      requestHeaders = Map("Accept" -> "text/plain"),
      requestBody = Some("body")
    )))
)

Export the exceptions to a format understandable by Periskop:

val exporter = new ExceptionExporter(exceptionCollector)
exporter.export

The exported exceptions need to be exposed via an HTTP endpoint in order for Periskop to be able to scrape them. See Periskop Documentation for more information on how to configure a Periskop server.

Using push gateway

You can also use pushgateway in case you want to push your metrics instead of using pull method. Use only in case you really need it (e.g a batch job) as it could degrade the performance of your application. In the following example, we assume that we deployed an instance of periskop-pushgateway on http://localhost:6767:

val exporter = new ExceptionExporter(exceptionCollector)
exceptionCollector.add(new RuntimeException("ups!"))
exporter.pushToGateway("http://localhost:6767")

Contributing / Release a new version

Please see CONTRIBUTING.md and RELEASE.md

periskop-scala's People

Contributors

jcreixell avatar dziemba avatar annetteres avatar blewis11 avatar grobie avatar

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.