trace4cats-http4s-client-zio


License

License

MIT
Categories

Categories

CLI User Interface
GroupId

GroupId

io.janstenpickle
ArtifactId

ArtifactId

trace4cats-http4s-client-zio_2.12
Last Version

Last Version

0.6.0+17-ebfd789c
Release Date

Release Date

Type

Type

jar
Description

Description

trace4cats-http4s-client-zio
trace4cats-http4s-client-zio
Project URL

Project URL

https://github.com/janstenpickle/trace4cats
Project Organization

Project Organization

janstenpickle
Source Code Management

Source Code Management

https://github.com/janstenpickle/trace4cats

Download trace4cats-http4s-client-zio_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/io.janstenpickle/trace4cats-http4s-client-zio_2.12/ -->
<dependency>
    <groupId>io.janstenpickle</groupId>
    <artifactId>trace4cats-http4s-client-zio_2.12</artifactId>
    <version>0.6.0+17-ebfd789c</version>
</dependency>
// https://jarcasting.com/artifacts/io.janstenpickle/trace4cats-http4s-client-zio_2.12/
implementation 'io.janstenpickle:trace4cats-http4s-client-zio_2.12:0.6.0+17-ebfd789c'
// https://jarcasting.com/artifacts/io.janstenpickle/trace4cats-http4s-client-zio_2.12/
implementation ("io.janstenpickle:trace4cats-http4s-client-zio_2.12:0.6.0+17-ebfd789c")
'io.janstenpickle:trace4cats-http4s-client-zio_2.12:jar:0.6.0+17-ebfd789c'
<dependency org="io.janstenpickle" name="trace4cats-http4s-client-zio_2.12" rev="0.6.0+17-ebfd789c">
  <artifact name="trace4cats-http4s-client-zio_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.janstenpickle', module='trace4cats-http4s-client-zio_2.12', version='0.6.0+17-ebfd789c')
)
libraryDependencies += "io.janstenpickle" % "trace4cats-http4s-client-zio_2.12" % "0.6.0+17-ebfd789c"
[io.janstenpickle/trace4cats-http4s-client-zio_2.12 "0.6.0+17-ebfd789c"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.12
io.janstenpickle : trace4cats-http4s-client_2.12 jar 0.6.0+17-ebfd789c
io.janstenpickle : trace4cats-inject-zio_2.12 jar 0.6.0+17-ebfd789c
org.typelevel : cats-core_2.12 jar 2.2.0
org.scala-lang.modules : scala-collection-compat_2.12 jar 2.2.0

test (10)

Group / Artifact Type Version
org.typelevel : cats-laws_2.12 jar 2.2.0
org.typelevel : cats-effect-laws_2.12 jar 2.2.0
org.typelevel : discipline-scalatest_2.12 jar 2.0.1
org.typelevel : discipline-core_2.12 jar 1.0.3
org.scalacheck : scalacheck_2.12 jar 1.14.3
com.github.alexarchambault : scalacheck-shapeless_1.14_2.12 jar 1.2.5
org.scalatest : scalatest_2.12 jar 3.2.2
org.http4s : http4s-blaze-client_2.12 jar 0.21.8
org.http4s : http4s-blaze-server_2.12 jar 0.21.8
org.http4s : http4s-dsl_2.12 jar 0.21.8

Project Modules

There are no modules declared in this project.

Trace4Cats Maven Central Join the chat at https://gitter.im/trace4cats/community

Yet another distributed tracing system, this time just for Scala. Heavily relies upon Cats and Cats-effect.

Compatible with OpenTelemetry and Jaeger, based on, and interoperates wht Natchez.

Obligatory XKCD

For release information and changes see the changelog

Motivation

It increasingly seems that Java tracing libraries are dependent on GRPC, which usually brings along lots of other dependencies. You may find Trace4Cats useful if you want to...

  • Reduce the number of dependencies in your application
  • Resolve a dependency conflict caused by a tracing implementation
  • Create a native-image using Graalvm

Highlights

Trace4Cats supports publishing spans to the following systems:

Instrumentation for trace propagation and continuation is available for the following libraries

Unlike other tracing libraries, trace attributes are lazily evaluated. If a span is not sampled, no computation associated with calculating attribute values will be performed

For more information on how to use these can be found in the examples documentation

Quickstart

For more see the documentation for more advanced examples

Add the following dependencies to your build.sbt:

"io.janstenpickle" %% "trace4cats-core" % "0.7.0"
"io.janstenpickle" %% "trace4cats-inject" % "0.7.0"
"io.janstenpickle" %% "trace4cats-avro-exporter" % "0.7.0"

Then run the collector in span logging mode:

echo "log-spans: true" > /tmp/collector.yaml
docker run -p7777:7777 -p7777:7777/udp -it \
  -v /tmp/collector.yaml:/tmp/collector.yaml \
  janstenpickle/trace4cats-collector-lite:0.7.0 \
  --config-file=/tmp/collector.yaml

Finally, run the following code to export some spans to the collector:

import cats.data.Kleisli
import cats.effect._
import cats.implicits._
import io.chrisdavenport.log4cats.Logger
import io.chrisdavenport.log4cats.slf4j.Slf4jLogger
import io.janstenpickle.trace4cats.Span
import io.janstenpickle.trace4cats.avro.AvroSpanCompleter
import io.janstenpickle.trace4cats.inject.{EntryPoint, Trace}
import io.janstenpickle.trace4cats.kernel.SpanSampler
import io.janstenpickle.trace4cats.model.{SpanKind, SpanStatus, TraceProcess}
import scala.concurrent.duration._

object Trace4CatsQuickStart extends IOApp {
  def entryPoint[F[_]: Concurrent: ContextShift: Timer: Logger](
    blocker: Blocker,
    process: TraceProcess
  ): Resource[F, EntryPoint[F]] =
    AvroSpanCompleter.udp[F](blocker, process, batchTimeout = 50.millis).map { completer =>
      EntryPoint[F](SpanSampler.always[F], completer)
    }

  def runF[F[_]: Sync: Trace]: F[Unit] =
    for {
      _ <- Trace[F].span("span1")(Sync[F].delay(println("trace this operation")))
      _ <- Trace[F].span("span2", SpanKind.Client)(Sync[F].delay(println("send some request")))
      _ <- Trace[F].span("span3", SpanKind.Client)(
        Trace[F].putAll("attribute1" -> "test", "attribute2" -> 200).flatMap { _ =>
          Trace[F].setStatus(SpanStatus.Cancelled)
        }
      )
    } yield ()

  override def run(args: List[String]): IO[ExitCode] =
    (for {
      blocker <- Blocker[IO]
      implicit0(logger: Logger[IO]) <- Resource.liftF(Slf4jLogger.create[IO])
      ep <- entryPoint[IO](blocker, TraceProcess("trace4cats"))
    } yield ep)
      .use { ep =>
        ep.root("this is the root span").use { span =>
          runF[Kleisli[IO, Span[IO], *]].run(span)
        }
      }
      .as(ExitCode.Success)
}

Components

Trace4Cats is made up as both a set of libraries for integration in applications and standalone processes. For information on the libraries and interfaces see the design documentation.

The standalone components are the agent and the collector. To see how they work together, see the topologies documentation, for information on configuring and running the agent and collector see the components documentation.

Documentation

SBT Dependencies

To use Trace4Cats within your application add the dependencies listed below as needed:

"io.janstenpickle" %% "trace4cats-core" % "0.7.0"
"io.janstenpickle" %% "trace4cats-inject" % "0.7.0"
"io.janstenpickle" %% "trace4cats-inject-zio" % "0.7.0"
"io.janstenpickle" %% "trace4cats-rate-sampling" % "0.7.0"
"io.janstenpickle" %% "trace4cats-fs2" % "0.7.0"
"io.janstenpickle" %% "trace4cats-http4s-client" % "0.7.0"
"io.janstenpickle" %% "trace4cats-http4s-server" % "0.7.0"
"io.janstenpickle" %% "trace4cats-sttp-client" % "0.7.0"
"io.janstenpickle" %% "trace4cats-natchez" % "0.7.0"
"io.janstenpickle" %% "trace4cats-avro-exporter" % "0.7.0"
"io.janstenpickle" %% "trace4cats-avro-kafka-exporter" % "0.7.0"
"io.janstenpickle" %% "trace4cats-avro-kafka-consumer" % "0.7.0"
"io.janstenpickle" %% "trace4cats-jaeger-thrift-exporter" % "0.7.0"
"io.janstenpickle" %% "trace4cats-log-exporter" % "0.7.0"
"io.janstenpickle" %% "trace4cats-opentelemetry-otlp-grpc-exporter" % "0.7.0"
"io.janstenpickle" %% "trace4cats-opentelemetry-otlp-http-exporter" % "0.7.0"
"io.janstenpickle" %% "trace4cats-opentelemetry-jaeger-exporter" % "0.7.0"
"io.janstenpickle" %% "trace4cats-stackdriver-grpc-exporter" % "0.7.0"
"io.janstenpickle" %% "trace4cats-stackdriver-http-exporter" % "0.7.0"
"io.janstenpickle" %% "trace4cats-datadog-http-exporter" % "0.7.0"
"io.janstenpickle" %% "trace4cats-newrelic-http-exporter" % "0.7.0"

native-image Compatibility

The following span completers have been found to be compatible with native-image:

Contributing

This project supports the Scala Code of Conduct and aims that its channels (mailing list, Gitter, github, etc.) to be welcoming environments for everyone.

Versions

Version
0.6.0+17-ebfd789c
0.6.0+14-68725e97
0.6.0+13-ef91afe7
0.6.0+11-873b4710
0.6.0+8-92cd29af
0.6.0+6-fbfaa374
0.6.0+2-fc7e40e9
0.6.0
0.5.2
0.5.1+2-8533a57d
0.5.1
0.5.0
0.4.0+53-6e73e55e
0.4.0+51-f07a1f42
0.4.0+47-80ce121f
0.4.0+41-2c78899a
0.4.0+26-5dfd44a5