-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #749 from iRevive/contrib/aws/xray-propagator
sdk-contrib: add `aws-xray-propagator` module
- Loading branch information
Showing
7 changed files
with
545 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# AWS | X-Ray propagator | ||
|
||
The X-Ray propagator implements AWS X-Ray Trace Header [propagation protocol][xray-concepts]. | ||
The propagator utilizes `X-Amzn-Trace-Id` header to extract and inject tracing details. | ||
An example of the AWS X-Ray Tracing Header: | ||
``` | ||
X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1 | ||
``` | ||
|
||
## Getting Started | ||
|
||
@:select(build-tool) | ||
|
||
@:choice(sbt) | ||
|
||
Add settings to the `build.sbt`: | ||
|
||
```scala | ||
libraryDependencies ++= Seq( | ||
"org.typelevel" %%% "otel4s-sdk" % "@VERSION@", // <1> | ||
"org.typelevel" %%% "otel4s-sdk-exporter" % "@VERSION@", // <2> | ||
"org.typelevel" %%% "otel4s-sdk-contrib-aws-xray-propagator" % "@VERSION@" // <3> | ||
) | ||
``` | ||
|
||
@:choice(scala-cli) | ||
|
||
Add directives to the `*.scala` file: | ||
|
||
```scala | ||
//> using lib "org.typelevel::otel4s-sdk::@VERSION@" // <1> | ||
//> using lib "org.typelevel::otel4s-sdk-exporter::@VERSION@" // <2> | ||
//> using lib "org.typelevel::otel4s-sdk-contrib-aws-xray-propagator::@VERSION@" // <3> | ||
``` | ||
|
||
@:@ | ||
|
||
1. Add the `otel4s-sdk` library | ||
2. Add the `otel4s-sdk-exporter` library. Without the exporter, the application will crash | ||
3. Add the `otel4s-sdk-contrib-aws-xray-propagator` library | ||
|
||
_______ | ||
|
||
Then autoconfigure the SDK: | ||
|
||
@:select(sdk-entry-point) | ||
|
||
@:choice(sdk) | ||
|
||
`OpenTelemetrySdk.autoConfigured` configures both `MeterProvider` and `TracerProvider`: | ||
|
||
```scala mdoc:silent:reset | ||
import cats.effect.{IO, IOApp} | ||
import org.typelevel.otel4s.metrics.MeterProvider | ||
import org.typelevel.otel4s.sdk.OpenTelemetrySdk | ||
import org.typelevel.otel4s.sdk.contrib.aws.context.propagation._ | ||
import org.typelevel.otel4s.sdk.exporter.otlp.autoconfigure.OtlpExportersAutoConfigure | ||
import org.typelevel.otel4s.trace.TracerProvider | ||
|
||
object TelemetryApp extends IOApp.Simple { | ||
|
||
def run: IO[Unit] = | ||
OpenTelemetrySdk | ||
.autoConfigured[IO]( | ||
// register OTLP exporters configurer | ||
_.addExportersConfigurer(OtlpExportersAutoConfigure[IO]) | ||
// add AWS X-Ray Propagator propagator | ||
.addTracerProviderCustomizer((b, _) => | ||
b.addTextMapPropagators(AWSXRayPropagator()) | ||
) | ||
) | ||
.use { autoConfigured => | ||
val sdk = autoConfigured.sdk | ||
program(sdk.meterProvider, sdk.tracerProvider) | ||
} | ||
|
||
def program( | ||
meterProvider: MeterProvider[IO], | ||
tracerProvider: TracerProvider[IO] | ||
): IO[Unit] = | ||
??? | ||
} | ||
``` | ||
|
||
@:choice(traces) | ||
|
||
`SdkTraces` configures only `TracerProvider`: | ||
|
||
```scala mdoc:silent:reset | ||
import cats.effect.{IO, IOApp} | ||
import org.typelevel.otel4s.sdk.contrib.aws.context.propagation._ | ||
import org.typelevel.otel4s.sdk.exporter.otlp.trace.autoconfigure.OtlpSpanExporterAutoConfigure | ||
import org.typelevel.otel4s.sdk.trace.SdkTraces | ||
import org.typelevel.otel4s.trace.TracerProvider | ||
|
||
object TelemetryApp extends IOApp.Simple { | ||
|
||
def run: IO[Unit] = | ||
SdkTraces | ||
.autoConfigured[IO]( | ||
// register OTLP exporters configurer | ||
_.addExporterConfigurer(OtlpSpanExporterAutoConfigure[IO]) | ||
// add AWS X-Ray Propagator propagator | ||
.addTracerProviderCustomizer((b, _) => | ||
b.addTextMapPropagators(AWSXRayPropagator()) | ||
) | ||
) | ||
.use { autoConfigured => | ||
program(autoConfigured.tracerProvider) | ||
} | ||
|
||
def program( | ||
tracerProvider: TracerProvider[IO] | ||
): IO[Unit] = | ||
??? | ||
} | ||
``` | ||
|
||
@:@ | ||
|
||
[xray-concepts]: https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ laika.title = SDK | |
laika.navigationOrder = [ | ||
overview.md | ||
configuration.md | ||
aws-xray-propagator.md | ||
] |
Oops, something went wrong.