io.opentracing.contrib:opentracing-scala-concurrent

OpenTracing Instrumentation for Scala concurrent package

Лицензия

Лицензия

Категории

Категории

Scala Языки программирования
Группа

Группа

io.opentracing.contrib
Идентификатор

Идентификатор

opentracing-scala-concurrent
Последняя версия

Последняя версия

0.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

io.opentracing.contrib:opentracing-scala-concurrent
OpenTracing Instrumentation for Scala concurrent package
Ссылка на сайт

Ссылка на сайт

https://github.com/opentracing-contrib/scala-concurrent
Система контроля версий

Система контроля версий

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

Скачать opentracing-scala-concurrent

Как подключить последнюю версию

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

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
io.opentracing : opentracing-util jar 0.31.0

provided (1)

Идентификатор библиотеки Тип Версия
org.scala-lang : scala-library jar 2.12.4

test (3)

Идентификатор библиотеки Тип Версия
io.opentracing : opentracing-mock jar 0.31.0
org.awaitility : awaitility-scala jar 3.0.0
org.scalatest : scalatest_2.12 jar 3.0.4

Модули Проекта

Данный проект не имеет модулей.

Build Status Coverage Status Released Version

OpenTracing instrumentation for scala.concurrent

OpenTracing instrumentation for scala.concurrent package.

Installation

Scala 2.12

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

Scala 2.13

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

Usage

Please see the examples directory. Overall, an ExecutionContext is wrapped so the active Span can be captured and activated for a given Scala Future.

Create a TracedExecutionContext wrapping the actually used ExecutionContext, and pass it around when creating Futures:

// Instantiate tracer
val tracer: Tracer = ...
val ec: ExecutionContext = new TracedExecutionContext(executionContext, tracer);

Span Propagation

Future {
  // The active Span at Future creation time, if any,  
  // will be captured and restored here.
  tracer.activeSpan().setTag("status.code", getStatusCode())
}(ec)

Future.onComplete and other Future methods will capture too any active Span by the time they were registered, so you have to make sure that both happened under the same active Span/Scope for this to work smoothly.

Span lifetime handling is not done at the TracedExecutionContext, and hence explicit calls to Span.finish() must be put in place - usually either in the last Future/message block or in a onComplete callback function:

Future {  
   ...
}(ec).onComplete { _ => {
  tracer.activeSpan().finish()
}
}(ec)

Auto finish Span handling

Span auto-finish is supported through a reference-count system using the specific AutoFinishScopeManager -which needs to be provided at Tracer creation time-, along with using TracedAutoFinishExecutionContext:

val scopeManager = new AutoFinishScopeManager();
val tracer: Tracer = ??? // Use the created scopeManager here.
val ec = new TracedAutoFinishExecutionContext(executionContext, tracer)
...
val span = tracer.buildSpan("request").start()
val scope = tracer.activateSpan(span)
try {
    Future {
	// Span will be reactivated here
	...
	Future {
	    // Span will be reactivated here as well.  
	    // By the time this future is done,  
	    // the Span will be automatically finished.
	  } (ec)
  } (ec)
} finally {
 scope.close()
}

Reference count for Spans is set to 1 at creation, and is increased when registering onComplete, andThen, map, and similar Future methods - and is decreased upon having such function/callback executed:

Future {
    ...
}(ec)
.map {...}(ec)
.onComplete {
    // No need to call `Span.finish()` here at all, as  
    // lifetime handling is done implicitly.
}(ec)

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.**

Версии библиотеки

Версия
0.0.1