io.opentracing.contrib:opentracing-akka

OpenTracing Instrumentation for Akka

License

License

Categories

Categories

Akka Container Microservices Reactive libraries
GroupId

GroupId

io.opentracing.contrib
ArtifactId

ArtifactId

opentracing-akka
Last Version

Last Version

0.1.4
Release Date

Release Date

Type

Type

jar
Description

Description

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

Project URL

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

Source Code Management

https://github.com/opentracing-contrib/java-akka

Download opentracing-akka

How to add to project

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

Dependencies

compile (2)

Group / Artifact Type Version
io.opentracing : opentracing-api jar 0.33.0
io.opentracing : opentracing-util jar 0.33.0

provided (2)

Group / Artifact Type Version
com.typesafe.akka : akka-actor_2.12 jar 2.6.1
com.typesafe.akka : akka-cluster-sharding_2.12 Optional jar 2.6.1

test (4)

Group / Artifact Type Version
io.opentracing : opentracing-mock jar 0.33.0
io.opentracing : opentracing-util test-jar 0.33.0
junit : junit jar 4.12
org.awaitility : awaitility jar 4.0.1

Project Modules

There are no modules declared in this project.

Build Status Coverage Status Released Version Apache-2.0 license

OpenTracing Akka Instrumentation

OpenTracing instrumentation for Akka.

Installation

pom.xml

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-akka</artifactId>
    <version>VERSION</version>
</dependency>

Usage

Actor's Span propagation (experimental design)

There's an experimental design and support for propagating Spans between Actors (without any lifetime handling, which means the user is responsible for finishing the Spans). For this to work, classes must inherit from TracedAbstractActor instead of AbstractActor, and messages must be wrapped using TracedMessage.wrap():

class MyActor extends TracedAbstractActor {
   @Override
   public Receive createReceive() {
       return receiveBuilder()
           .match(String.class, msg -> {
                // the Span 'foo' will be active for this block,
                // and will NOT be finished upon deactivation.
                getSender().tell("ciao", getSelf());
            })
           .build();
    }
}

try (Scope scope = tracer.buildSpan("foo").startActive()) {
    // scope.span() will be captured as part of TracedMessage.wrap(),
    // and MyActor will receive the original 'myMessageObj` instance.
    Future<String> f = ask(myActorRef, TracedMessage.wrap("hello"), timeout);
    ...
}

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 extends TracedAbstractActor {
   public Receive createReceive() {
       return receiveBuilder()
           .match(String.class, msg -> {
                // TracedAbstractActor.tracer() returns the Tracer being used,
                // either GlobalTracer or the explicit set one.
                if (tracer().activeSpan() != null) {
                   // Use the active Span, to set tags, create children, finish it, etc.
                   tracer().activeSpan.finish();
                }
                ...
            })
           .build();
   }
}

Span span = tracer.buildSpan("foo").start();
Future<String> f = 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.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.2
0.0.1