GithubHelp home page GithubHelp logo

eventtracker's Introduction

Eventtracker, a Java library for the Dwarf Collector

The eventtracker library is a Java library to send events to the Collector (github.com/pierre/collector).

Please refer to the serialization library FAQ for an overview of the Event concept: pierre.github.com/dwarf/serialization/faq.html

Usage

The eventtracker library is synced to Maven Central. Simply add the dependency to your pom.xml:

<dependency>
    <groupId>com.ning</groupId>
    <artifactId>metrics.eventtracker</artifactId>
    <version>3.1.0</version>
</dependency>

The library offers a simple method to send events. Here is a complete working example to send one Thrift event (we assume myShinyEvent is a Thrift object):

ThriftEnvelopeEvent eventToSend = ThriftToThriftEnvelopeEvent.extractEvent("MyShinyEvent", myShinyEvent);

// See the Javadocs for fine-tuning of the parameters
// There is also a Guice module which uses config-magic for parameters injection:
//        Injector injector = Guice.createInjector(new CollectorControllerModule());
//        CollectorController controller = injector.getInstance(CollectorController.class);
EventTrackerConfig eventTrackerConfig = new EventTrackerConfig();
eventTrackerConfig.setScribeHost("collector-vip.company.com");

CollectorController controller = ScribeCollectorFactory.createScribeController(eventTrackerConfig);

controller.offerEvent(eventToSend);

// Optional, see below
controller.commit();
controller.flush();

You can send any type of Event (not necessarily Thrift) via the library (see below).

How does it work?

Each event accepted via the offerEvent(Event) API is directly serialized to disk using the com.ning:metrics.serialization-writer library for persistency. Events are then de-serialized and sent to the collector periodically and/or after a certain number of events have been offered.

The library supports all Collector APIs: HTTP based and Scribe (Thrift).

The CollectorController class provides the commit() call to force a promotion from the temporary queue of events to the final queue: only events in the final queue are sent (a separate thread wakes up periodically to see if there is anything to send). The commit() call bypasses the promotion rules mentioned above.

One can force a flush to the final queue by calling flush() on the controller object. This forces all events in the queue to be sent remotely.

Serialization to disk is done using the Java Serialization mechanisms (ObjectOutputStream to file). The whole Event object is written to disk. This is not configurable.

Final serialization on the wire is configurable (e.g. Java Serialization, Thrift). You can extend your event to support your own serialization protocol by implementing getSerializedBytes(). These bytes are sent on the wire.

License (see LICENSE-2.0.txt file for full license)

Copyright 2010-2011 Ning

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

eventtracker's People

Stargazers

Thai Ngo avatar

Watchers

Thai Ngo avatar James Cloos 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.