Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
grouzen committed May 20, 2023
1 parent 5bb78fe commit 8aaec3c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/opentelemetry-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: opentelemetry-example
title: "OpenTelemetry Example"
---

You can find the source code [here](https://github.com/zio/zio-telemetry/tree/series/2.x/opentracing-example).
You can find the source code [here](https://github.com/zio/zio-telemetry/tree/series/2.x/opentelemtry-example).

For an explanation in more detail, check the [OpenTracing Example](opentracing-example.md).

Expand Down
2 changes: 2 additions & 0 deletions docs/opentelemetry-instrumentation-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ id: opentelemetry-instrumentation-example
title: "OpenTelemetry Automatic Instrumentation Example"
---

You can find the source code [here](https://github.com/zio/zio-telemetry/tree/series/2.x/opentelemetry-instrumentation-example).

Firstly, download OpenTelemetry JVM agent JAR:
```bash
OTEL_AGENT_PATH=$(cs fetch --classpath "io.opentelemetry.javaagent:opentelemetry-javaagent:latest.release")
Expand Down
6 changes: 3 additions & 3 deletions docs/opentelemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Since [version 1.25.0](https://github.com/open-telemetry/opentelemetry-java-inst
OpenTelemetry JVM agent supports ZIO.

To enable interoperability between automatic instrumentation and `zio-opentelemetry`, `Tracing` has to be created
using `ContextStorage` backed by OpenTelemetry's `Context`.
using `ContextStorage` backed by OpenTelemetry's `Context` and `Tracer` provided by globally registered `TracerProvider`.

```scala
import zio.telemetry.opentelemetry.tracing.Tracing
Expand All @@ -132,7 +132,7 @@ val app =
ZIO.logInfo("Hello") @@ root("root span", SpanKind.INTERNAL, errorMapper)
}.provide(
Tracing.live,
ContextStorage.openTelemetryContext, // <<<
JaegerTracer.live
ContextStorage.openTelemetryContext, // <<< ContextStorage
ZLayer.fromZIO(ZIO.attempt(GlobalOpenTelemetry.getTracer("hello"))) // <<< Tracer
)
```
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import zio.config.magnolia.descriptor
import zio.config.typesafe.TypesafeConfig
import zio.telemetry.opentelemetry.instrumentation.example.config.AppConfig
import zio._
import zio.config.ReadError
import zio.telemetry.opentelemetry.instrumentation.example.http.HttpClient

object ClientApp extends ZIOAppDefault {

private val configLayer = TypesafeConfig.fromResourcePath(descriptor[AppConfig])
private val configLayer: Layer[ReadError[String], AppConfig] =
TypesafeConfig.fromResourcePath(descriptor[AppConfig])

private val httpBackendLayer: TaskLayer[Backend] =
ZLayer.scoped {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package zio.telemetry.opentelemetry.instrumentation.example

import io.opentelemetry.api.GlobalOpenTelemetry
import io.opentelemetry.api.trace.Tracer
import zio._
import zio.config.ReadError
import zio.config.typesafe.TypesafeConfig
import zio.config.magnolia._
import zio.telemetry.opentelemetry.context.ContextStorage
Expand All @@ -11,10 +13,13 @@ import zio.telemetry.opentelemetry.tracing.Tracing

object ServerApp extends ZIOAppDefault {

private val configLayer = TypesafeConfig.fromResourcePath(descriptor[AppConfig])
private val configLayer: Layer[ReadError[String], AppConfig] =
TypesafeConfig.fromResourcePath(descriptor[AppConfig])

private val globalTracerLayer =
ZLayer.succeed(GlobalOpenTelemetry.getTracer("zio.telemetry.opentelemetry.instrumentation.example.ServerApp"))
private val globalTracerLayer: TaskLayer[Tracer] =
ZLayer.fromZIO(
ZIO.attempt(GlobalOpenTelemetry.getTracer("zio.telemetry.opentelemetry.instrumentation.example.ServerApp"))
)

override def run: Task[ExitCode] =
ZIO
Expand Down
5 changes: 1 addition & 4 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ object Dependencies {
)

lazy val opentelemetryInstrumentationExample = example ++ Seq(
Orgs.softwaremillSttpClient3 %% "zio" % ExampleVersions.sttp3,
Orgs.opentelemetry % "opentelemetry-exporter-jaeger" % Versions.opentelemetry,
Orgs.opentelemetry % "opentelemetry-sdk" % Versions.opentelemetry,
Orgs.grpc % "grpc-netty-shaded" % ExampleVersions.grpcNetty
Orgs.softwaremillSttpClient3 %% "zio" % ExampleVersions.sttp3
)

}

0 comments on commit 8aaec3c

Please sign in to comment.