akka-stream-trace


License

License

Categories

Categories

Net Akka Container Microservices Reactive libraries
GroupId

GroupId

net.findhotel
ArtifactId

ArtifactId

akka-stream-trace_2.12
Last Version

Last Version

0.3
Release Date

Release Date

Type

Type

jar
Description

Description

akka-stream-trace
akka-stream-trace
Project Organization

Project Organization

net.findhotel
Source Code Management

Source Code Management

https://github.com/FindHotel/akka-stream-trace

Download akka-stream-trace_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/net.findhotel/akka-stream-trace_2.12/ -->
<dependency>
    <groupId>net.findhotel</groupId>
    <artifactId>akka-stream-trace_2.12</artifactId>
    <version>0.3</version>
</dependency>
// https://jarcasting.com/artifacts/net.findhotel/akka-stream-trace_2.12/
implementation 'net.findhotel:akka-stream-trace_2.12:0.3'
// https://jarcasting.com/artifacts/net.findhotel/akka-stream-trace_2.12/
implementation ("net.findhotel:akka-stream-trace_2.12:0.3")
'net.findhotel:akka-stream-trace_2.12:jar:0.3'
<dependency org="net.findhotel" name="akka-stream-trace_2.12" rev="0.3">
  <artifact name="akka-stream-trace_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.findhotel', module='akka-stream-trace_2.12', version='0.3')
)
libraryDependencies += "net.findhotel" % "akka-stream-trace_2.12" % "0.3"
[net.findhotel/akka-stream-trace_2.12 "0.3"]

Dependencies

compile (8)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.2
com.typesafe : config jar 1.3.0
joda-time : joda-time jar 2.8.1
com.typesafe.akka : akka-http_2.12 jar 10.0.0
com.typesafe.akka : akka-http-testkit_2.12 jar 10.0.0
org.apache.htrace : htrace-core4 jar 4.3.0-SNAPSHOT
org.apache.htrace : htrace-zipkin jar 4.3.0-SNAPSHOT
org.scalactic : scalactic_2.12 jar 3.0.0

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.0

Project Modules

There are no modules declared in this project.

Gitter Chat Maven Central

Htrace extension for akka http and akka streams

prerequistes:

docker run -d -p 9411:9411 -p 9410:9410 openzipkin/zipkin

running the examples:

sbt examples/run

then choose 1 for http example or 2 for streaming example

The http example will bind to port 8080. point your browesr to localhost:8080/frontend in order to initiate a request.

Getting Started:

The main advantage of using this library is that it eliminates the need for manual calls for logs and lets you focus on the right things, when things break you will still have a clear view into your applications, you can always add anontations later.

add the dependecy:

resolvers +=  Resolver.sonatypeRepo("releases") //akka-stream-trace sources 
resolvers += "Apache OSS Snapshots" at "https://repository.apache.org/content/groups/snapshots/" // htrace sources
libraryDependencies += "net.findhotel" %% "akka-stream-trace" % "0.3"

The first part of integrating the library is adding a config file, here's a basic example:

htrace{
  span.receiver.classes = org.apache.htrace.impl.ZipkinSpanReceiver
  sampler.classes = org.apache.htrace.core.AlwaysSampler
  zipkin.scribe.hostname = "localhost"
}

This example tells htrace to use the zipkin receiver, samples all traces and points htrace to localhost as the span server.

now we have to configure the actor system to use the tracing dispatcher

  implicit val as = ActorSystem()
  val set = ActorMaterializerSettings(as)
  //We want to use the tracing dispatcher
  .withDispatcher("tracing-dispatcher")
  implicit val met = ActorMaterializer(set)

if you are using akka-http you are done, if this is a akka-streams applications add this call before your call to run:

val s = StreamTracer.tracer.newScope("compute")
Source.fromIterator(() => (1 to 100).toIterator).runFold(0)(_ +_)

don't forget to close the scope after the call to run

s.close()

this method is shown in here https://github.com/FindHotel/akka-stream-trace/blob/master/modules/examples/src/main/scala/BasicStreamExample.scala

Videos:

Tracing akka streams (scalar 2017):

Tracing Akka Steams with htrach

net.findhotel

FindHotel

Hi! ๐Ÿ‘‹We are hiring frontend/backend/data/devops engineers: get in touch! ๐Ÿ‘

Versions

Version
0.3