hs-opentelemetry-awsxray: [synopsis]

[ library, mit, utils ] [ Propose Tags ]
Versions [RSS],
Change log CHANGELOG.md
Dependencies base (>= && <5), bytestring, errors, hs-opentelemetry-api, hs-opentelemetry-sdk, http-types, memory, microlens, random (>=1.2.1), text, time, unliftio, unliftio-core, unordered-containers [details]
License MIT
Maintainer Freckle Education
Category Utils
Home page https://github.com/freckle/hs-opentelemetry-awsxray#readme
Bug tracker https://github.com/freckle/hs-opentelemetry-awsxray/issues
Source repo head: git clone https://github.com/freckle/hs-opentelemetry-awsxray
Uploaded by PatrickBrisbin at 2023-03-01T16:58:29Z
Distributions NixOS:
Downloads 44 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-03-01 [all 1 reports]

Readme for hs-opentelemetry-awsxray-

[back to package description]

AWS X-Ray Support for hs-opentelemetry


An IdGenerator and Propagator for hs-opentelemetry-sdk that generates and propagates TraceId and SpanId values that are compatible with AWS X-Ray.


The API currently exposed by the hs-opentelemetry-sdk package lacks a convenient way to modify the TracerProviderOptions (to tell it to use our generator/propagator) as part of initialization. You basically have to re-implement the internals of initializeTracerProvider to do so.

While we plan to open a PR upstream to address the lack of API here, the workaround approach has at least been been encapsulated in a module of this library for convenience:

import OpenTelemetry.AWSXRay
import OpenTelemetry.Trace
import OpenTelemetry.Trace.Setup
import OpenTelemetry.Trace.Setup.Lens

main :: IO ()
main = do
  withTracerProvider modifyTracerProviderOptions $ \tracerProvider -> do
    let tracer = makeTracer tracerProvider "my-app" tracerOptions

    -- do something with tracer

modifyTracerProviderOptions :: TracerProviderOptions -> TracerProviderOptions
modifyTracerProviderOptions =
  idGeneratorL .~ awsXRayIdGenerator
    . propagatorL <>~ awsXRayContextPropagator

This example uses lens, but you certainly don't have to.

Additional References