io.opentracing.contrib:opentracing-scala-akka

OpenTracing Instrumentation for Scala Akka

License

License

Categories

Categories

Scala Languages Akka Container Microservices Reactive libraries
GroupId

GroupId

io.opentracing.contrib
ArtifactId

ArtifactId

opentracing-scala-akka
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

io.opentracing.contrib:opentracing-scala-akka
OpenTracing Instrumentation for Scala Akka
Project URL

Project URL

https://github.com/opentracing-contrib/scala-akka
Source Code Management

Source Code Management

http://github.com/opentracing-contrib/scala-akka

Download opentracing-scala-akka

How to add to project

<!-- https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-scala-akka/ -->
<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-scala-akka</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-scala-akka/
implementation 'io.opentracing.contrib:opentracing-scala-akka:0.1.1'
// https://jarcasting.com/artifacts/io.opentracing.contrib/opentracing-scala-akka/
implementation ("io.opentracing.contrib:opentracing-scala-akka:0.1.1")
'io.opentracing.contrib:opentracing-scala-akka:jar:0.1.1'
<dependency org="io.opentracing.contrib" name="opentracing-scala-akka" rev="0.1.1">
  <artifact name="opentracing-scala-akka" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.opentracing.contrib', module='opentracing-scala-akka', version='0.1.1')
)
libraryDependencies += "io.opentracing.contrib" % "opentracing-scala-akka" % "0.1.1"
[io.opentracing.contrib/opentracing-scala-akka "0.1.1"]

Dependencies

compile (2)

Group / Artifact Type Version
io.opentracing : opentracing-util jar 0.32.0
com.typesafe.akka : akka-actor_2.13 jar 2.5.23

provided (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.0

test (4)

Group / Artifact Type Version
io.opentracing : opentracing-util test-jar 0.32.0
io.opentracing : opentracing-mock jar 0.32.0
org.awaitility : awaitility-scala jar 3.1.6
org.scalatest : scalatest_2.13 jar 3.0.8

Project Modules

There are no modules declared in this project.

Build Status Coverage Status Released Version Apache-2.0 license

OpenTracing Scala Akka instrumentation

OpenTracing instrumentation for Scala Akka.

Installation

build.sbt

libraryDependencies += "io.opentracing.contrib" % "opentracing-scala-akka" % "VERSION"

Usage

Tracer registration

Instantiate tracer and register it with GlobalTracer:

val tracer: Tracer = ???
GlobalTracer.register(tracer)

Actor's Span propagation

User is responsible for finishing the Spans. For this to work, classes must inherit from TracedAbstractActor instead of Actor, and messages must be wrapped using TracedMessage.wrap():

class MyActor extends TracedAbstractActor {
  override def receive(): Receive = {
    case _: String =>
      sender().tell("ciao", self)
  }
}

val scope =  tracer.buildSpan("foo").startActive(true)

// scope.span() will be captured as part of TracedMessage.wrap(),
// and MyActor will receive the original 'myMessageObj` instance.
val future = ask(myActorRef, TracedMessage.wrap("hello"), timeout)
...
    
scope.close()
    
}

By default, TracedAbstractActor/TracedMessage use io.opentracing.util.GlobalTracer to activate and fetch the Span respectively, but it's possible to manually specify both the Tracer used to activate and the captured Span:

class MyActor(myTracer: Tracer) extends TracedAbstractActor {
  override def receive(): Receive = {
    case _: String =>
      // TracedAbstractActor.tracer() returns the Tracer being used,
      // either GlobalTracer 
      if (tracer().activeSpan() != null) {
        // Use the active Span, to set tags, create children, finish it, etc.
        tracer().activeSpan.finish()
      }
      ...
  }

  override def tracer(): Tracer = myTracer
}

val span = tracer.buildSpan("foo").start()
val future = ask(myActorRef, TracedMessage.wrap(span, "hello"), timeout);

License

Apache 2.0 License.

io.opentracing.contrib

3rd-Party OpenTracing API Contributions

3rd-party contributions that use OpenTracing. **The repositories in this org are *not* affiliated with the CNCF.**

Versions

Version
0.1.1
0.1.0
0.0.1