hs-opentelemetry-api

OpenTelemetry API for use by libraries for direct instrumentation or wrapper packages.

https://github.com/iand675/hs-opentelemetry#readme

Stackage Nightly 2025-10-11:0.3.0.0
Latest on Hackage:0.3.0.0

See all snapshots hs-opentelemetry-api appears in

BSD-3-Clause licensed by Ian Duncan, Jade Lovelace
Maintained by [email protected]
This version can be pinned in stack with:hs-opentelemetry-api-0.3.0.0@sha256:d864e4e1758bdeb8310d99e18084b77cff875a7b56589db55dfaf1dd17864dd3,4162

Module documentation for 0.3.0.0

OpenTelemetry API for Haskell

This package provides an interface for instrumentors to use when instrumenting a library directly or implementing a wrapper API around an existing project.

The methods in this package can be safely called by libraries or end-user applications regardless of whether the application has registered an OpenTelemetry SDK configuration or not. When the OpenTelemetry SDK has not registered a tracer provider with any span processors, there API incurs minimal performance overhead, as most of the core interface performs no-ops.

In order to generate and export telemetry data, you will also need to use the OpenTelemetry Haskell SDK.

The inspiration of the OpenTelemetry project is to make every library and application observable out of the box by having them call the OpenTelemetry API directly. Until that happens, there is a need for a separate library which can inject this information. A library that enables observability for another library is called an instrumentation library. In the case of Haskell, instrumentation is currently entirely manual.

Visit the GitHub project for a list of provided instrumentation libraries.

Install Dependencies

Add hs-opentelemetry-api to your package.yaml or Cabal file.

Useful Links

Changes

Changelog for hs-opentelemetry-api

Unreleased

0.3.0.0

  • Export fromList from OpenTelemetry.Trace.TraceState for creating TraceState from key-value pairs

0.2.1.0

  • defined and exported toImmutableSpan and FrozenOrDropped from OpenTelemetry.Trace.Core

0.2.0.0

  • callerAttributes and ownCodeAttributes now work properly if the call stack has been frozen. Hence most span-construction functions should now get correct source code attributes in this situation also (#137.
  • Added detectInstrumentationLibrary for producing InstrumentationLibrarys with TH (#2).
  • Fixed precedence order of resource merge (#156).
  • Added the ability to add links to spans after creation (#152).
  • Correctly compute attribute length limits (#151).
  • Add helper for reading boolean environment variables correctly (#153).
  • Initial scaffolding for logging support. Renamed Processor to SpanProcessor.
  • Export FlushResult (#96)
  • Use HashMap Text Attribute instead of [(Text, Attribute)] as attributes
  • Improved conformance with semantic conventions.

0.0.3.6

  • GHC 9.4 support
  • Add Show instances to several api types

0.0.3.1

  • adjustContext uses an empty context if one hasn’t been created on the current thread yet instead of acting as a no-op.

0.0.2.1

  • Doc enhancements

0.0.2.0

  • Separate Link and NewLink into two different datatypes to improve Link creation interface.
  • Add some version bounds
  • Catch & print all synchronous exceptions when calling span processor start and end hooks

0.0.1.0

  • Initial release