alpakka-brave

Zipkin's Brave instrumentation for Akka Streams

License

License

Categories

Categories

Akka Container Microservices Reactive libraries
GroupId

GroupId

no.sysco.middleware.alpakka
ArtifactId

ArtifactId

alpakka-brave
Last Version

Last Version

0.1.10
Release Date

Release Date

Type

Type

jar
Description

Description

alpakka-brave
Zipkin's Brave instrumentation for Akka Streams
Source Code Management

Source Code Management

http://github.com/sysco-middleware/alpakka-connectors/tree/master/alpakka-brave

Download alpakka-brave

How to add to project

<!-- https://jarcasting.com/artifacts/no.sysco.middleware.alpakka/alpakka-brave/ -->
<dependency>
    <groupId>no.sysco.middleware.alpakka</groupId>
    <artifactId>alpakka-brave</artifactId>
    <version>0.1.10</version>
</dependency>
// https://jarcasting.com/artifacts/no.sysco.middleware.alpakka/alpakka-brave/
implementation 'no.sysco.middleware.alpakka:alpakka-brave:0.1.10'
// https://jarcasting.com/artifacts/no.sysco.middleware.alpakka/alpakka-brave/
implementation ("no.sysco.middleware.alpakka:alpakka-brave:0.1.10")
'no.sysco.middleware.alpakka:alpakka-brave:jar:0.1.10'
<dependency org="no.sysco.middleware.alpakka" name="alpakka-brave" rev="0.1.10">
  <artifact name="alpakka-brave" type="jar" />
</dependency>
@Grapes(
@Grab(group='no.sysco.middleware.alpakka', module='alpakka-brave', version='0.1.10')
)
libraryDependencies += "no.sysco.middleware.alpakka" % "alpakka-brave" % "0.1.10"
[no.sysco.middleware.alpakka/alpakka-brave "0.1.10"]

Dependencies

compile (4)

Group / Artifact Type Version
com.typesafe.akka : akka-stream_2.12 jar 2.5.13
io.zipkin.brave : brave jar 5.2.0
org.assertj : assertj-core jar 3.10.0
org.scala-lang : scala-library jar 2.12.6

test (2)

Group / Artifact Type Version
com.typesafe.akka : akka-stream-testkit_2.12 jar 2.5.13
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Alpakka Connectors

Build Status

Maven metadata URI

File Connectors

Listening to changes in a directory

The RecursiveDirectoryChangesSource tries to improve the existing DirectoryChangesSource from alpakka with recursive folder monitoring. It will emit elements every time there is a change to a watched directory in the local file system or any of the subdirectories (new or existing). The enumeration consists of the path that was changed and an enumeration describing what kind of change it was.

import no.sysco.middleware.alpakka.files.javadsl.RecursiveDirectoryChangesSource;

public class App {
    public static void main(String[] args){
        final ActorSystem system = ActorSyste.create();
        final ActorMaterializer mat = ActorMaterializer.create(system);
        
        final FileSystem fs = FileSystems.getDefault();
        final Duration pollingInterval = Duration.of(1, ChronoUnit.SECONDS);
        final int maxBufferSize = 1000;
        final Source<Pair<Path, DirectoryChange>, NotUsed> changes =
            RecursiveDirectoryChangesSource.create(fs.getPath(path), pollingInterval, maxBufferSize);


        changes.runForeach((Pair<Path, DirectoryChange> pair) -> {
            final Path changedPath = pair.first();
            final DirectoryChange change = pair.second();
            System.out.println("Path: " + changedPath + ", Change: " + change);
        }, mat);
    }
}

ZeroMQ Connectors

ZeroMQ Connector uses JeroMQ library to expose Source, Flow and Sinks based on ZeroMQ Socket types (e.g. PUB/SUB, PULL/PUSH).

import no.sysco.middleware.alpakka.zeromq.javadsl.Zmq;

public class App {
    public static void main(String[] args) {
        final ActorSystem system = ActorSystem.create();
        final ActorMaterializer mat = ActorMaterializer.create(system);
        
        Source.repeat("hello")
              .map(ZMsg::createNewMsg)
              .to(Zmq.publishServerSink("tcp://*:5555"))
              .run(mat);
        
        Zmq.subscribeClientSource("tcp://localhost:5555")
           .map(zmsg -> {
               System.out.println(zmsg.popString());
               return zmsg;
           })
           .runWith(Sink.ignore(), mat);
    }
}

Zipkin-Brave Connectors

Brave connectors create Spans flows to integrate tracing into your Akka Streams applications.

public class App {
  public static void main(String[] args){
    final ActorSystem system = ActorSystem.create();
        final ActorMaterializer mat = ActorMaterializer.create(system);
        
        final Tracing tracing = ...;
        
        Source.repeat("hello")
          .via(Brave.startSpanFlow(tracing, "akka-stream-trace"))
          .via(Brave.childSpanFlow(tracing, "akka-stream-span-map", Flow.<String>create().map(s -> s)))
          .via(Brave.finishSpanFlow(tracing))
          .to(Sink.ignore())
          .run(materializer);
  }
}
no.sysco.middleware.alpakka

SYSCO Middleware

Middleware Department from SYSCO AS

Versions

Version
0.1.10
0.1.6