Library Moduleswift-service-context 1.1.0ServiceContextModule

ServiceContextModule

Common currency type for type-safe and Swift concurrency aware context propagation.

index.md
import ServiceContextModule

Module information

Declarations
22
Symbols
23

Coverage

81.8 percent of the declarations in ServiceContextModule are fully documented18.2 percent of the declarations in ServiceContextModule are indirectly documented

Declarations

4.5 percent of the declarations in ServiceContextModule are operators22.7 percent of the declarations in ServiceContextModule are initializers, type members, or enum cases36.4 percent of the declarations in ServiceContextModule are instance members4.5 percent of the declarations in ServiceContextModule are instance subscripts4.5 percent of the declarations in ServiceContextModule are protocols9.1 percent of the declarations in ServiceContextModule are protocol requirements4.5 percent of the declarations in ServiceContextModule are default implementations13.6 percent of the declarations in ServiceContextModule are structures

Interfaces

100.0 percent of the declarations in ServiceContextModule are unrestricted
Module stats and coverage details

Overview

ServiceContext is a minimal (zero-dependency) context propagation container, intended to “carry” baggage items for purposes of cross-cutting tools to be built on top of it.

It is modeled after the concepts explained in W3C Baggage and the in the spirit of Tracing Plane’s “Baggage Context” type, although by itself it does not define a specific serialization format.

See https://github.com/apple/swift-distributed-tracing for actual instrument types and implementations which can be used to deploy various cross-cutting instruments all reusing the same baggage type. More information can be found in the SSWG meeting notes.

Automatic propagation through task-locals by using ServiceContext.current is supported in Swift >= 5.5

Getting started

In order to depend on this library you can use the Swift Package Manager, and add the following dependency to your Package.swift:

dependencies: [
  .package(
    url: "https://github.com/apple/swift-service-context.git",
    from: "0.2.0"
  )
]

and depend on the module in your target:

targets: [
    .target(
        name: "MyAwesomeApp",
        dependencies: [
            .product(
              name: "ServiceContextModule",
              package: "swift-service-context"
            ),
        ]
    ),
    // ...
]

Usage

Please refer to in-depth discussion and documentation in the Swift Distributed Tracing repository.