### Install Xcode Command Line Tools Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/DEVELOPING.md Install the Xcode Command Line Tools after installing and running Xcode. ```sh xcode-select --install ``` -------------------------------- ### Install bats-core and jq using Homebrew Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/DEVELOPING.md Install bats-core for local testing and jq for processing JSON output using Homebrew. ```sh brew install bats-core brew install jq ``` -------------------------------- ### Install Network Instrumentation Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/complete-api-summary.md Installs network instrumentation using provided Honeycomb options. This function is internal. ```swift internal func installNetworkInstrumentation(options: HoneycombOptions) ``` -------------------------------- ### Install clang-format using Homebrew Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/DEVELOPING.md Install clang-format, a tool for auto-formatting Objective-C code, using the Homebrew package manager. ```sh brew install clang-format ``` -------------------------------- ### Load Honeycomb Configuration from Plist Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/configuration.md This example shows how to load Honeycomb SDK configuration from a plist file at runtime using `HoneycombOptions.Builder(contentsOfFile:)`. ```swift if let configURL = Bundle.main.url(forResource: "Honeycomb", withExtension: "plist") { let builder = try HoneycombOptions.Builder(contentsOfFile: configURL) let options = try builder.build() } ``` -------------------------------- ### installWindowInstrumentation() Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/instrumentation-api.md Installs automatic tracking of touch events and window interactions, creating spans for touch interactions and adding relevant attributes. ```APIDOC ## Window/Touch Instrumentation: installWindowInstrumentation() ### Description Installs automatic tracking of touch events and window interactions. ### Availability iOS, tvOS (not watchOS) ### Behavior - Tracks user touch events - Creates spans for touch interactions - Adds touch location and gesture type attributes ### Configuration Example ```swift let options = try HoneycombOptions.Builder() .setTouchInstrumentationEnabled(true) // Default is false .build() ``` ``` -------------------------------- ### Install Window/Touch Instrumentation Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/instrumentation-api.md Enable automatic tracking of touch events and window interactions. This is disabled by default. ```swift let options = try HoneycombOptions.Builder() .setTouchInstrumentationEnabled(true) // Default is false .build() ``` -------------------------------- ### Get Application Resources Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/complete-api-summary.md Retrieves application resource information as a dictionary of key-value strings. ```swift public func getAppResources() -> [String: String] ``` -------------------------------- ### Install UI Navigation Instrumentation Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/complete-api-summary.md Installs instrumentation for UIKit navigation events. This allows for automatic tracing of navigation within your application. ```APIDOC ## installUINavigationInstrumentation ### Description Installs instrumentation for UIKit navigation. ### Method `installUINavigationInstrumentation()` ### Endpoint N/A (SDK Function) ### Parameters None ### Request Example ```swift installUINavigationInstrumentation() ``` ### Response None ``` -------------------------------- ### Complete Honeycomb SDK Configuration Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/configuration.md This example demonstrates how to configure the Honeycomb SDK using the Builder pattern, setting various options including authentication, datasets, endpoints, service information, sampling, debug mode, and instrumentation. ```swift import Honeycomb let options = try HoneycombOptions.Builder() // Authentication .setAPIKey("hc1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") .setTracesAPIKey("hc1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") .setMetricsAPIKey("hc1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") .setLogsAPIKey("hc1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") // Datasets (classic API only) .setDataset("production") .setMetricsDataset("metrics-prod") // Endpoints .setAPIEndpoint("https://api.honeycomb.io:443") .setTracesAPIEndpoint("https://api.honeycomb.io:443/v1/traces") // Service information .setServiceName("my-app") .setServiceVersion("1.2.3") .setResourceAttributes([ "environment": "production", "region": "us-east-1", "custom.tag": "value" ]) // Headers .setHeaders(["user-agent": "my-app/1.0"]) // Timeouts .setTimeout(10.0) .setTracesTimeout(10.0) // Protocols .setProtocol(.httpProtobuf) // Sampling .setSampleRate(10) // Sample 1 in 10 traces // Debug .setDebug(true) // Session .setSessionTimeout(TimeInterval(60 * 60 * 8)) // 8 hours // Instrumentation .setMetricKitInstrumentationEnabled(true) .setURLSessionInstrumentationEnabled(true) .setUIKitInstrumentationEnabled(true) .setUnhandledExceptionInstrumentationEnabled(true) .setNetworkStatusTrackingEnabled(true) // Offline caching .setOfflineCachingEnabled(false) .build() try Honeycomb.configure(options: options) ``` -------------------------------- ### Install Network Instrumentation Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/instrumentation-api.md Installs automatic instrumentation for URLSession network requests. This is typically called automatically during Honeycomb.configure(). ```swift internal func installNetworkInstrumentation(options: HoneycombOptions) ``` ```swift let options = try HoneycombOptions.Builder() .setAPIKey("key") .setServiceName("app") .setURLSessionInstrumentationEnabled(true) // Automatic install .build() try Honeycomb.configure(options: options) // Network requests now automatically generate spans let (data, response) = try await URLSession.shared.data( from: URL(string: "https://api.example.com/users")! ) // Span automatically created and closed ``` -------------------------------- ### HoneycombOptions Configuration with httpProtobuf Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/types.md Example of configuring HoneycombOptions to use the httpProtobuf protocol. Ensure you set the API key and service name. ```swift let options = try HoneycombOptions.Builder() .setProtocol(.httpProtobuf) .setAPIKey("key") .setServiceName("app") .build() ``` -------------------------------- ### Example of Missing Navigation Reporting Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/README.md This example demonstrates how spans might be attributed to the wrong screen if navigation is not explicitly reported using `Honeycomb.setCurrentScreen` or a similar mechanism. ```swift struct ContentView: View { var body: some View { TabView { ViewA() .padding() .tabItem { Label("View A") } .onAppear { Honeycomb.setCurrentScreen(path: "View A") } ViewB() .padding() .tabItem { Label("View B" } // no onAppear callback and no reportNavigation() call } } } ``` -------------------------------- ### Enable UIKit Instrumentation via Options Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/navigation-instrumentation.md Configure Honeycomb with options to automatically enable UIKit navigation instrumentation. This is the recommended approach over manual installation. ```swift let options = try HoneycombOptions.Builder() .setAPIKey("key") .setUIKitInstrumentationEnabled(true) // Enables automatic installation .build() try Honeycomb.configure(options: options) ``` -------------------------------- ### Verify Honeycomb Setup in Swift Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/quick-start.md Check the service resource and current session. Enable debug mode to view all generated spans directly in the console. ```swift // Check resource let resource = Honeycomb.resource print("Service: \(resource.attributes["service.name"])") // Check session if let session = Honeycomb.currentSession() { print("Session active: \(session.id)") } // Enable debug mode to see spans let options = try HoneycombOptions.Builder() .setAPIKey("key") .setServiceName("app") .setDebug(true) // See all spans printed .build() ``` -------------------------------- ### Logging with Attributes Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/types.md Example of creating and using a dictionary of AttributeValue instances for logging. This allows rich context to be attached to logs. ```swift let attributes: [String: AttributeValue] = [ "request.method": AttributeValue("GET"), "request.duration_ms": AttributeValue(125), "request.success": AttributeValue(true), "tags": AttributeValue.array( AttributeArray(values: [ AttributeValue("tag1"), AttributeValue("tag2") ]) ) ] Honeycomb.log( error: error, attributes: attributes, thread: Thread.current ) ``` -------------------------------- ### SwiftUI Navigation Instrumentation Usage Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/navigation-instrumentation.md Example demonstrating how to apply the instrumentNavigation view extension within a SwiftUI NavigationStack to track user-initiated navigation events. ```swift import SwiftUI import Honeycomb struct ContentView: View { @State var navigationPath = NavigationPath() var body: some View { NavigationStack(path: $navigationPath) { VStack { NavigationLink("Go to Details", value: "details") } .navigationDestination(for: String.self) { DetailsView() .instrumentNavigation(path: screen, reason: "user_tap") } } } } ``` -------------------------------- ### Build Honeycomb Options Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb-options.md Use the Builder to configure Honeycomb options and then call build() to create the immutable options object. This example shows setting the API key, service name, sampling rate, and debug mode. ```swift let options = try HoneycombOptions.Builder() .setAPIKey("your-api-key") .setServiceName("my-app") .setSampleRate(10) .setDebug(true) .build() ``` -------------------------------- ### Get Resource Information Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/quick-start.md Access resource information, such as the service name, from the Honeycomb SDK. ```swift let resource = Honeycomb.resource if let serviceName = resource.attributes["service.name"] { print("Service: \(serviceName)") } ``` -------------------------------- ### MetricKitSubscriber Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/instrumentation-api.md Subscribes to MetricKit metrics for app performance monitoring. It is installed automatically if metricKitInstrumentationEnabled is true. ```APIDOC ## MetricKitSubscriber ### Description Subscribes to MetricKit metrics for app performance monitoring. ### Availability iOS 13.0+ (not tvOS, not macOS) ### Namespace `Sources/Honeycomb/` ### Metrics Collected - App hang events - Memory issues - Battery usage - Network connectivity ### Installation Automatic if `metricKitInstrumentationEnabled` is true (default). ### Note The OpenTelemetry native `MetricKitInstrumentation` takes precedence if both are enabled. ``` -------------------------------- ### installNetworkInstrumentation(options:) Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/instrumentation-api.md Installs automatic instrumentation for URLSession network requests. This function is called automatically during Honeycomb.configure() if urlSessionInstrumentationEnabled is true in options. It uses method swizzling to intercept network requests and creates spans with attributes like HTTP method, URL, status code, etc. ```APIDOC ## installNetworkInstrumentation(options:) ### Description Installs automatic instrumentation for URLSession network requests. This function is called automatically during `Honeycomb.configure()` if `urlSessionInstrumentationEnabled` is true in options. ### Method `internal func installNetworkInstrumentation(options: HoneycombOptions)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (`HoneycombOptions`) - Required - Configuration options ### Request Example ```swift // Automatically installed via options let options = try HoneycombOptions.Builder() .setAPIKey("key") .setServiceName("app") .setURLSessionInstrumentationEnabled(true) // Automatic install .build() try Honeycomb.configure(options: options) // Network requests now automatically generate spans let (data, response) = try await URLSession.shared.data( from: URL(string: "https://api.example.com/users")! ) // Span automatically created and closed ``` ### Response #### Success Response `Void` #### Response Example None (Void return type) ``` -------------------------------- ### Set Sample Rate for Performance Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/INDEX.md To address performance issues, you can reduce the sample rate. This example sets the sample rate to 100, meaning 1 in 100 traces will be exported. ```swift .setSampleRate(100) ``` -------------------------------- ### Custom Span Processor Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/instrumentation-api.md Provides an example of how to add custom span processing by creating a `CustomSpanProcessor` class and setting it via `HoneycombOptions.Builder.setSpanProcessor()`. ```APIDOC ## Custom Instrumentation To add custom span processing: ```swift class CustomSpanProcessor: SpanProcessor { var isStartRequired: Bool { true } var isEndRequired: Bool { true } func onStart(parentContext: SpanContext?, span: any ReadableSpan) { // Add custom attributes to every span if let readableSpan = span as? Span { readableSpan.setAttribute(key: "custom.field", value: "value") } } func onEnd(span: any ReadableSpan) { // Process span on end } func shutdown(explicitTimeout: TimeInterval?) {} func forceFlush(timeout: TimeInterval?) {} } let options = try HoneycombOptions.Builder() .setAPIKey("key") .setServiceName("app") .setSpanProcessor(CustomSpanProcessor()) .build() try Honeycomb.configure(options: options) ``` ``` -------------------------------- ### Get Application Resources Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/complete-api-summary.md Retrieves application resource information, such as version and platform details, which can be useful for context in telemetry data. ```APIDOC ## getAppResources ### Description Retrieves application resource information. ### Method `getAppResources()` ### Endpoint N/A (SDK Function) ### Parameters None ### Request Example ```swift let resources = getAppResources() ``` ### Response #### Success Response - `[String: String]` - A dictionary containing application resource key-value pairs. ``` -------------------------------- ### Get a Tracer Instance Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/types.md Retrieve a tracer instance from the global tracer provider. Use this tracer to create spans for your application or library. ```swift let tracer = OpenTelemetry.instance.tracerProvider.get( instrumentationName: "io.honeycomb.custom", instrumentationVersion: "1.0" ) ``` -------------------------------- ### Install UIKit Navigation Instrumentation Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/navigation-instrumentation.md Call this function to automatically instrument UIKit navigation events. It's typically enabled via HoneycombOptions rather than called directly. ```swift public func installUINavigationInstrumentation() ``` -------------------------------- ### Accessing Session Start Timestamp Property Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb-session.md Demonstrates how to access the `startTimestamp` property of a `HoneycombSession` object to retrieve the date and time when the session was created. This is useful for calculating session duration. ```swift if let session = Honeycomb.currentSession() { let elapsedTime = Date().timeIntervalSince(session.startTimestamp) print("Session duration: \(elapsedTime) seconds") } ``` -------------------------------- ### UIKit Integration: installUINavigationInstrumentation Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/navigation-instrumentation.md Installs automatic UIKit navigation instrumentation. This method is called automatically if setUIKitInstrumentationEnabled(true) is set in HoneycombOptions. It uses method swizzling on UIViewController to automatically track navigation events. ```APIDOC ## UIKit Integration: installUINavigationInstrumentation() ### Description Installs automatic UIKit navigation instrumentation. This method is called automatically if `setUIKitInstrumentationEnabled(true)` is set in `HoneycombOptions`. ### Availability iOS, tvOS (not watchOS) ### Behavior Uses method swizzling on `UIViewController` to automatically track navigation events when view controllers are presented, pushed, or dismissed. ### Namespace `Sources/Honeycomb/UIKit/NavigationInstrumentation.swift` ### Usage Example ```swift // Usually not called manually - configured via options let options = try HoneycombOptions.Builder() .setAPIKey("key") .setUIKitInstrumentationEnabled(true) // Enables automatic installation .build() try Honeycomb.configure(options: options) ``` ``` -------------------------------- ### Accessing HoneycombSession ID and Start Timestamp Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb-session.md Demonstrates how to retrieve the current active session and access its unique identifier and creation timestamp. This is useful for logging or debugging session-related information. ```swift import Honeycomb // Get the current active session if let currentSession = Honeycomb.currentSession() { print("Active session: \(currentSession.id)") print("Started at: \(currentSession.startTimestamp)") } else { // SDK not configured or no active session print("No active session") } ``` -------------------------------- ### Add Custom Span Processor Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/instrumentation-api.md Implement a custom SpanProcessor to add attributes to spans or process them on start and end. This example adds a custom field to every span. ```swift class CustomSpanProcessor: SpanProcessor { var isStartRequired: Bool { true } var isEndRequired: Bool { true } func onStart(parentContext: SpanContext?, span: any ReadableSpan) { // Add custom attributes to every span if let readableSpan = span as? Span { readableSpan.setAttribute(key: "custom.field", value: "value") } } func onEnd(span: any ReadableSpan) { // Process span on end } func shutdown(explicitTimeout: TimeInterval?) {} func forceFlush(timeout: TimeInterval?) {} } let options = try HoneycombOptions.Builder() .setAPIKey("key") .setServiceName("app") .setSpanProcessor(CustomSpanProcessor()) .build() try Honeycomb.configure(options: options) ``` -------------------------------- ### Calculating and Logging Session Duration Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb-session.md Illustrates how to calculate the duration of the current session by comparing the current time with the session's start timestamp. The calculated duration and session ID are then emitted as log attributes. ```swift if let session = Honeycomb.currentSession() { let duration = Date().timeIntervalSince(session.startTimestamp) // Log session metrics let logger = Honeycomb.getDefaultErrorLogger() logger.logRecordBuilder() .setAttributes([ "session.duration": AttributeValue(duration), "session.id": AttributeValue(session.id) ]) .emit() } ``` -------------------------------- ### HoneycombNavigationPathSpanProcessor onStart Method Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/navigation-instrumentation.md Implementation of the onStart method for HoneycombNavigationPathSpanProcessor. It adds screen context attributes to spans when they begin. ```swift public func onStart( parentContext: SpanContext?, span: any ReadableSpan ) ``` -------------------------------- ### Configure Honeycomb SDK with Basic Options Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/configuration.md This snippet shows the basic configuration of the Honeycomb SDK using the builder pattern. It sets the API key and service name, then builds the options and configures the SDK. ```swift let options = try HoneycombOptions.Builder() .setAPIKey("your-api-key") .setServiceName("my-service") .build() try Honeycomb.configure(options: options) ``` -------------------------------- ### configure(options:) Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb.md Initializes the Honeycomb SDK with the provided options. This method must be called once during application initialization before any telemetry is emitted. It configures the OpenTelemetry SDK with exporters for traces, metrics, and logs. ```APIDOC ## configure(options:) ### Description Initializes the Honeycomb SDK with the provided options. This method must be called once during application initialization before any telemetry is emitted. It configures the OpenTelemetry SDK with exporters for traces, metrics, and logs. ### Method `static public func configure(options: HoneycombOptions) throws` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **options** (`HoneycombOptions`) - Required - Configuration options built via `HoneycombOptions.Builder` ### Return Type `Void` ### Throws `HoneycombOptionsError` - Thrown when options are invalid, endpoints are malformed, API keys are missing, or unsupported protocols are specified. **Common error conditions:** - `.malformedURL(_)` - When trace, metric, or log endpoint URLs cannot be parsed - `.missingAPIKey(_)` - When an API key is required but not provided - `.unsupportedProtocol(_)` - When protocol is unsupported (e.g., http/json) - `.unsupportedExporter(_)` - When OTEL exporter is not OTLP ### Usage Example ```swift import Honeycomb @main struct ExampleApp: App { init() { do { let options = try HoneycombOptions.Builder() .setAPIKey("YOUR-API-KEY") .setServiceName("YOUR-SERVICE-NAME") .build() try Honeycomb.configure(options: options) } catch { NSException( name: NSExceptionName("HoneycombOptionsError"), reason: "\(error)" ).raise() } } } ``` ``` -------------------------------- ### Initialize Honeycomb SDK Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/quick-start.md Initialize the Honeycomb SDK with your API key and service name in your application's entry point. ```swift import SwiftUI import Honeycomb @main struct MyApp: App { init() { do { let options = try HoneycombOptions.Builder() .setAPIKey("YOUR-API-KEY") .setServiceName("my-app") .build() try Honeycomb.configure(options: options) } catch { NSException( name: NSExceptionName("HoneycombError"), reason: "\(error)" ).raise() } } var body: some Scene { WindowGroup { ContentView() } } } ``` -------------------------------- ### HoneycombSession Structure Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/complete-api-summary.md Represents a telemetry session with a unique ID and start timestamp. ```APIDOC ## HoneycombSession ### Description Represents a telemetry session. ### Properties - `id`: The unique identifier for the session (String). - `startTimestamp`: The date and time when the session started (Date). ### Methods - `== (lhs: HoneycombSession, rhs: HoneycombSession) -> Bool`: Compares two HoneycombSession objects for equality. ``` -------------------------------- ### Initialize HoneycombOptions Builder Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb-options.md Creates a builder with default options. All settings use documented defaults until explicitly set. ```swift let builder = HoneycombOptions.Builder() ``` -------------------------------- ### Get Current Session ID Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/quick-start.md Retrieve the current Honeycomb session ID if available. ```swift if let session = Honeycomb.currentSession() { print("Session: \(session.id)") } ``` -------------------------------- ### Basic Usage of setCurrentScreen with String Path Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb.md Demonstrates the simplest usage of `setCurrentScreen` with a direct string path. ```swift Honeycomb.setCurrentScreen(path: "MainView") ``` -------------------------------- ### Use Supported Protocols Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/errors.md Utilize supported protocols like `.httpProtobuf` or `.grpc` for data transmission to Honeycomb. ```swift .httpProtobuf ``` ```swift .grpc ``` -------------------------------- ### Build Honeycomb Options Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/INDEX.md This snippet demonstrates how to build the Honeycomb options, including setting the API key, service name, and a custom span processor. ```swift try HoneycombOptions.Builder() .setAPIKey("key") .setServiceName("app") .setSpanProcessor(AnalyticsSpanProcessor()) .build() ``` -------------------------------- ### HoneycombSession Equality Comparison Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb-session.md Compares two HoneycombSession objects for equality based on their ID and start timestamp. ```APIDOC ## Equality Comparison Compares two sessions for equality. Sessions are equal if both their `id` and `startTimestamp` match. **Usage:** ```swift if let session1 = Honeycomb.currentSession(), let session2 = getStoredSession() { if session1 == session2 { print("Same session") } } ``` ``` -------------------------------- ### HoneycombNavigationPathSpanProcessor Properties Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/navigation-instrumentation.md Defines the behavior of the HoneycombNavigationPathSpanProcessor, indicating it hooks span start events but not end events. ```swift public let isStartRequired = true ``` ```swift public let isEndRequired = false ``` -------------------------------- ### UIDeviceSpanProcessor Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/instrumentation-api.md Automatically adds device information attributes to spans on iOS and tvOS. It is installed automatically during Honeycomb.configure() on iOS. ```APIDOC ## UIDeviceSpanProcessor ### Description Automatically adds device information attributes to spans on iOS and tvOS. ### Availability iOS, tvOS (not watchOS) ### Namespace `Sources/Honeycomb/UIKit/` ### Installation Installed automatically during `Honeycomb.configure()` on iOS. ### Span Attributes Added - Device model - OS version - Screen dimensions - Available memory - Battery state - Network connectivity status ``` -------------------------------- ### SwiftUI Entry Points Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/complete-api-summary.md Entry points for integrating Honeycomb tracing and logging within SwiftUI applications. ```APIDOC ## SwiftUI Entry Points ### Description Provides methods for setting the current screen and instrumenting navigation within SwiftUI views. ### Methods - `Honeycomb.setCurrentScreen(screenName: String)`: Sets the name of the current screen for tracing purposes. - `View.instrumentNavigation()`: An extension method on `View` to automatically instrument navigation. - `HoneycombInstrumentedView`: A view modifier or wrapper for instrumenting SwiftUI views. ### Usage These methods allow developers to easily integrate Honeycomb's observability features into their SwiftUI applications without extensive manual setup. ``` -------------------------------- ### HoneycombOptions.Builder Initializers Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb-options.md Initialize the HoneycombOptions.Builder either with default settings or by loading configuration from a plist file. ```APIDOC ## Default initializer ### Description Creates a builder with default options. All settings use documented defaults until explicitly set. ### Signature ```swift override public init() ``` ### Usage ```swift let builder = HoneycombOptions.Builder() ``` --- ## From plist file ### Description Creates a builder with options pre-populated from a plist file. Used for loading configuration from app bundle resources. ### Signature ```swift public convenience init(contentsOfFile path: URL) throws ``` ### Parameters #### Path Parameters - **path** (`URL`) - Required - Path to the plist configuration file ### Throws Errors from data reading or PropertyList deserialization ### Usage ```swift if let configURL = Bundle.main.url(forResource: "Honeycomb", withExtension: "plist") { let builder = try HoneycombOptions.Builder(contentsOfFile: configURL) let options = try builder.build() } ``` ``` -------------------------------- ### HoneycombNavigationPathSpanProcessor Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/navigation-instrumentation.md A SpanProcessor that automatically adds navigation context attributes to all spans. This processor is installed automatically during SDK configuration. ```APIDOC ## HoneycombNavigationPathSpanProcessor ```swift public struct HoneycombNavigationPathSpanProcessor: SpanProcessor ``` ### Description A `SpanProcessor` that automatically adds navigation context attributes to all spans. This processor is installed automatically during SDK configuration. ### Namespace `Sources/Honeycomb/HoneycombNavigationSpanInstrumentation.swift` ### Properties #### isStartRequired ```swift public let isStartRequired = true ``` Indicates that this processor hooks span start events. #### isEndRequired ```swift public let isEndRequired = false ``` Indicates that this processor does not hook span end events. ### Methods #### onStart(parentContext:span:) ```swift public func onStart( parentContext: SpanContext?, span: any ReadableSpan ) ``` Called when a span is started. Adds screen context attributes from the current navigation path. | Parameter | Type | Description | |-----------|------|-------------| | parentContext | `SpanContext?` | Parent span context (not used) | | span | `any ReadableSpan` | The span being started | **Attributes added:** - `screen.name` - The current screen name (last path element), or "/" if no path - `screen.path` - The full path serialized as "/" separated string (e.g., "/Home/Details") #### onEnd(span:) ```swift public func onEnd(span: any ReadableSpan) ``` No-op implementation; this processor does not process span end events. ``` -------------------------------- ### NetworkStatusSpanProcessor Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/instrumentation-api.md Tracks network connectivity status and adds network attributes to spans. It is installed automatically during Honeycomb.configure() if networkStatusTrackingEnabled is true. ```APIDOC ## NetworkStatusSpanProcessor ### Description Tracks network connectivity status and adds network attributes to spans. ### Availability iOS (not macCatalyst) ### Namespace `Sources/Honeycomb/` ### Span Attributes Added - `network.type` - WiFi, Cellular, etc. - `network.subtype` - Specific network type (4G, LTE, etc.) - `network.available` - Whether network is available ### Automatic Installation Installed during `Honeycomb.configure()` if `networkStatusTrackingEnabled` is true (default). ### Configuration Example ```swift let options = try HoneycombOptions.Builder() .setNetworkStatusTrackingEnabled(true) // Default .build() ``` ``` -------------------------------- ### Usage of setCurrentScreen with Prefix and String Path Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb.md Demonstrates how to prepend a prefix to the navigation path using the `prefix` parameter in `setCurrentScreen`. ```swift Honeycomb.setCurrentScreen(prefix: "app", path: "ProductDetails") ``` -------------------------------- ### Logging with Severity Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/types.md Example of setting the severity level to 'error' when emitting a log record. This is useful for capturing critical events. ```swift let logger = Honeycomb.getDefaultErrorLogger() logger.logRecordBuilder() .setSeverity(.error) .emit() ``` -------------------------------- ### HoneycombSession Struct Definition Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/types.md Defines a structure representing an active user session, including a unique ID and start timestamp. ```swift public struct HoneycombSession: Equatable { public let id: String public let startTimestamp: Date } ``` -------------------------------- ### Basic View Instrumentation Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb-instrumented-view.md Demonstrates how to wrap a basic SwiftUI view with HoneycombInstrumentedView to instrument its rendering. ```swift import SwiftUI import Honeycomb struct ContentView: View { var body: some View { HoneycombInstrumentedView(name: "ContentView") { VStack(spacing: 20) { Text("Hello, World!") Button("Press me") { } } } } } ``` -------------------------------- ### Development Configuration Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/quick-start.md Configure the Honeycomb SDK for development with debug logging enabled and all spans sampled. ```swift let options = try HoneycombOptions.Builder() .setAPIKey("hc1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") .setServiceName("dev-app") .setDebug(true) // Print debug info .setSampleRate(1) // All spans .build() ``` -------------------------------- ### Get Current Honeycomb Session Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb.md Retrieve the currently active Honeycomb session. Returns `nil` if no session is active or if the SDK has not been configured. ```swift if let session = Honeycomb.currentSession() { print("Current session ID: \(session.id)") print("Session started: \(session.startTimestamp)") } ``` -------------------------------- ### Core Components Architecture Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/INDEX.md Illustrates the main components of the Honeycomb SDK and its relationship with OpenTelemetry. ```text Honeycomb (Static class) ├── Configure → HoneycombOptions.Builder ├── Logger → getDefaultErrorLogger() ├── Session → currentSession() └── Navigation → setCurrentScreen() OpenTelemetry (Underlying) ├── Tracer Provider ├── Meter Provider ├── Logger Provider └── Exporters (HTTP/gRPC) ``` -------------------------------- ### Setting API Key for Honeycomb Options Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/errors.md Demonstrates the correct way to set an API key when building Honeycomb options, preventing the `missingAPIKey` error. This is essential for authenticated communication with Honeycomb services. ```swift let options = try HoneycombOptions.Builder() .setAPIKey("your-api-key-here") .setServiceName("my-app") .build() ``` -------------------------------- ### Lint and format code using Makefile Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/DEVELOPING.md Use the Makefile to lint and auto-format both Swift and Objective-C code. ```sh make lint make format ``` -------------------------------- ### Implement a Custom Span Processor Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/README.md Create a custom `SpanProcessor` to add application-specific attributes to spans before they are exported. This example adds a 'custom.attribute' to every span. ```swift import Foundation import Honeycomb import OpenTelemetryApi import OpenTelemetrySdk // Create a custom span processor internal struct AppVersionSpanProcessor: SpanProcessor { public let isStartRequired = true public let isEndRequired = true // Add custom logic when a span starts public func onStart(parentContext: SpanContext?, span: any ReadableSpan) { // For example, add a custom attribute to every span: span.setAttribute(key: "custom.attribute", value: "custom_value") } public func onEnd(span: any ReadableSpan) {} public func shutdown(explicitTimeout: TimeInterval? = nil) {} public func forceFlush(timeout: TimeInterval? = nil) {} } // Then when configuring the SDK, add your processor: let options = try HoneycombOptions.Builder() .setAPIKey("YOUR-API-KEY") .setServiceName("YOUR-SERVICE-NAME") .setSpanProcessor(MyCustomSpanProcessor()) .build() try Honeycomb.configure(options: options) ``` -------------------------------- ### Custom Span Processor Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/INDEX.md Implement a custom SpanProcessor to add analytics logic to your spans. This example shows how to create a processor that can be configured with Honeycomb options. ```swift class AnalyticsSpanProcessor: SpanProcessor { var isStartRequired: Bool { true } var isEndRequired: Bool { true } func onStart(parentContext: SpanContext?, span: any ReadableSpan) { // Add tracking } func onEnd(span: any ReadableSpan) { // Send to analytics } func shutdown(explicitTimeout: TimeInterval?) {} func forceFlush(timeout: TimeInterval?) {} } let options = try HoneycombOptions.Builder() .setAPIKey("key") .setServiceName("app") .setSpanProcessor(AnalyticsSpanProcessor()) .build() ``` -------------------------------- ### UIKit Entry Points Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/complete-api-summary.md Entry points for integrating Honeycomb tracing and logging within UIKit applications. ```APIDOC ## UIKit Entry Points ### Description Provides methods for setting the current screen and installing navigation instrumentation within UIKit applications. ### Methods - `Honeycomb.setCurrentScreen(screenName: String)`: Sets the name of the current screen for tracing purposes. - `installUINavigationInstrumentation()`: Installs instrumentation for UIKit navigation controllers. ### Usage These functions enable developers to add Honeycomb observability to their UIKit apps, tracking screen views and navigation events. ``` -------------------------------- ### HoneycombOptions.Builder Configuration Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/complete-api-summary.md Use the Builder to configure HoneycombOptions, setting API keys, datasets, endpoints, service details, headers, timeouts, protocols, sampling rates, and enabling various instrumentation and debugging features. ```swift public class Builder: NSObject { // Initialization override public init() public convenience init(contentsOfFile path: URL) throws // Build public func build() throws -> HoneycombOptions // API Keys @objc public func setAPIKey(_ apiKey: String) -> Builder @objc public func setTracesAPIKey(_ apiKey: String) -> Builder @objc public func setMetricsAPIKey(_ apiKey: String) -> Builder @objc public func setLogsAPIKey(_ apiKey: String) -> Builder // Datasets @objc public func setDataset(_ dataset: String) -> Builder @objc public func setMetricsDataset(_ dataset: String) -> Builder // Endpoints @objc public func setAPIEndpoint(_ endpoint: String) -> Builder @objc public func setTracesAPIEndpoint(_ endpoint: String) -> Builder @objc public func setMetricsAPIEndpoint(_ endpoint: String) -> Builder @objc public func setLogsAPIEndpoint(_ endpoint: String) -> Builder // Service Configuration @objc public func setServiceName(_ serviceName: String) -> Builder @objc public func setServiceVersion(_ serviceVersion: String) -> Builder @objc public func setResourceAttributes(_ resources: [String: String]) -> Builder // Headers @objc public func setHeaders(_ headers: [String: String]) -> Builder @objc public func setTracesHeaders(_ headers: [String: String]) -> Builder @objc public func setMetricsHeaders(_ headers: [String: String]) -> Builder @objc public func setLogsHeaders(_ headers: [String: String]) -> Builder // Timeouts @objc public func setTimeout(_ timeout: TimeInterval) -> Builder @objc public func setTracesTimeout(_ timeout: TimeInterval) -> Builder @objc public func setMetricsTimeout(_ timeout: TimeInterval) -> Builder @objc public func setLogsTimeout(_ timeout: TimeInterval) -> Builder // Protocols public func setProtocol(_ protocol: OTLPProtocol) -> Builder public func setTracesProtocol(_ protocol: OTLPProtocol) -> Builder public func setMetricsProtocol(_ protocol: OTLPProtocol) -> Builder public func setLogsProtocol(_ protocol: OTLPProtocol) -> Builder // Sampling @objc public func setSampleRate(_ sampleRate: Int) -> Builder // Debug @objc public func setDebug(_ debug: Bool) -> Builder // Span Processing public func setSpanProcessor(_ processor: SpanProcessor) -> Builder // Sessions @objc public func setSessionTimeout(_ timeout: TimeInterval) -> Builder // Instrumentation @objc public func setMetricKitInstrumentationEnabled(_ enabled: Bool) -> Builder @objc public func setOTELMetricKitInstrumentationEnabled(_ enabled: Bool) -> Builder @objc public func setURLSessionInstrumentationEnabled(_ enabled: Bool) -> Builder @objc public func setOTELURLSessionInstrumentationEnabled(_ enabled: Bool) -> Builder @objc public func setUIKitInstrumentationEnabled(_ enabled: Bool) -> Builder @objc public func setTouchInstrumentationEnabled(_ enabled: Bool) -> Builder @objc public func setUnhandledExceptionInstrumentationEnabled(_ enabled: Bool) -> Builder @objc public func setNetworkStatusTrackingEnabled(_ enabled: Bool) -> Builder // Offline Caching @objc public func setOfflineCachingEnabled(_ enabled: Bool) -> Builder } ``` -------------------------------- ### HoneycombOptions.Builder Configuration Methods Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/complete-api-summary.md The HoneycombOptions.Builder class provides a fluent interface for configuring various aspects of the Honeycomb OpenTelemetry SDK, including API keys, datasets, endpoints, service information, timeouts, and instrumentation. ```APIDOC ## HoneycombOptions.Builder ### Description Provides methods to configure the Honeycomb OpenTelemetry SDK. ### Methods - `init()`: Initializes a new builder instance. - `init(contentsOfFile: URL) throws`: Initializes a builder with configuration from a file. - `build() throws -> HoneycombOptions`: Builds and returns the HoneycombOptions object. #### API Keys - `setAPIKey(_ apiKey: String) -> Builder`: Sets the main API key. - `setTracesAPIKey(_ apiKey: String) -> Builder`: Sets the API key for traces. - `setMetricsAPIKey(_ apiKey: String) -> Builder`: Sets the API key for metrics. - `setLogsAPIKey(_ apiKey: String) -> Builder`: Sets the API key for logs. #### Datasets - `setDataset(_ dataset: String) -> Builder`: Sets the default dataset name. - `setMetricsDataset(_ dataset: String) -> Builder`: Sets the dataset name for metrics. #### Endpoints - `setAPIEndpoint(_ endpoint: String) -> Builder`: Sets the default API endpoint. - `setTracesAPIEndpoint(_ endpoint: String) -> Builder`: Sets the API endpoint for traces. - `setMetricsAPIEndpoint(_ endpoint: String) -> Builder`: Sets the API endpoint for metrics. - `setLogsAPIEndpoint(_ endpoint: String) -> Builder`: Sets the API endpoint for logs. #### Service Configuration - `setServiceName(_ serviceName: String) -> Builder`: Sets the service name. - `setServiceVersion(_ serviceVersion: String) -> Builder`: Sets the service version. - `setResourceAttributes(_ resources: [String: String]) -> Builder`: Sets custom resource attributes. #### Headers - `setHeaders(_ headers: [String: String]) -> Builder`: Sets default headers. - `setTracesHeaders(_ headers: [String: String]) -> Builder`: Sets headers for traces. - `setMetricsHeaders(_ headers: [String: String]) -> Builder`: Sets headers for metrics. - `setLogsHeaders(_ headers: [String: String]) -> Builder`: Sets headers for logs. #### Timeouts - `setTimeout(_ timeout: TimeInterval) -> Builder`: Sets the default request timeout. - `setTracesTimeout(_ timeout: TimeInterval) -> Builder`: Sets the timeout for traces requests. - `setMetricsTimeout(_ timeout: TimeInterval) -> Builder`: Sets the timeout for metrics requests. - `setLogsTimeout(_ timeout: TimeInterval) -> Builder`: Sets the timeout for logs requests. #### Protocols - `setProtocol(_ protocol: OTLPProtocol) -> Builder`: Sets the default OTLP protocol. - `setTracesProtocol(_ protocol: OTLPProtocol) -> Builder`: Sets the OTLP protocol for traces. - `setMetricsProtocol(_ protocol: OTLPProtocol) -> Builder`: Sets the OTLP protocol for metrics. - `setLogsProtocol(_ protocol: OTLPProtocol) -> Builder`: Sets the OTLP protocol for logs. #### Sampling - `setSampleRate(_ sampleRate: Int) -> Builder`: Sets the sample rate for traces. #### Debug - `setDebug(_ debug: Bool) -> Builder`: Enables or disables debug logging. #### Span Processing - `setSpanProcessor(_ processor: SpanProcessor) -> Builder`: Sets a custom span processor. #### Sessions - `setSessionTimeout(_ timeout: TimeInterval) -> Builder`: Sets the session timeout for telemetry. #### Instrumentation - `setMetricKitInstrumentationEnabled(_ enabled: Bool) -> Builder`: Enables MetricKit instrumentation. - `setOTELMetricKitInstrumentationEnabled(_ enabled: Bool) -> Builder`: Enables OTel MetricKit instrumentation. - `setURLSessionInstrumentationEnabled(_ enabled: Bool) -> Builder`: Enables URLSession instrumentation. - `setOTELURLSessionInstrumentationEnabled(_ enabled: Bool) -> Builder`: Enables OTel URLSession instrumentation. - `setUIKitInstrumentationEnabled(_ enabled: Bool) -> Builder`: Enables UIKit instrumentation. - `setTouchInstrumentationEnabled(_ enabled: Bool) -> Builder`: Enables touch event instrumentation. - `setUnhandledExceptionInstrumentationEnabled(_ enabled: Bool) -> Builder`: Enables unhandled exception instrumentation. - `setNetworkStatusTrackingEnabled(_ enabled: Bool) -> Builder`: Enables network status tracking. ``` -------------------------------- ### Initialize Uncaught Exception Instrumentation (Manual) Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/instrumentation-api.md Manually initializes automatic logging of uncaught exceptions and crashes. Use this if not configuring via Honeycomb.configure(). ```swift HoneycombUncaughtExceptionHandler.initializeUnhandledExceptionInstrumentation() ``` ```swift // Uncaught exceptions are now automatically logged func riskyFunction() { NSException( name: NSExceptionName("TestException"), reason: "This is a test" ).raise() } // When this is called and unhandled, it's automatically logged riskyFunction() ``` -------------------------------- ### Accessing Session ID Property Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb-session.md Shows how to access the `id` property of a `HoneycombSession` object to get the unique identifier for the session. This ID is automatically generated when the session is created. ```swift if let session = Honeycomb.currentSession() { print("Session ID: \(session.id)") } ``` -------------------------------- ### Honeycomb Navigation Methods Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/complete-api-summary.md Provides static methods for setting the current screen in navigation instrumentation. ```APIDOC ## Honeycomb Navigation Methods ### Description Methods for setting the current screen in navigation instrumentation. ### Methods - `setCurrentScreen(prefix: String?, path: NavigationPath, reason: String?)`: Sets the current screen using a `NavigationPath`. - `setCurrentScreen(prefix: String?, path: String, reason: String?)`: Sets the current screen using a String path. - `setCurrentScreen(prefix: String?, path: Encodable, reason: String?)`: Sets the current screen using an `Encodable` path. - `setCurrentScreen(prefix: String?, path: [Encodable], reason: String?)`: Sets the current screen using an array of `Encodable` paths. - `setCurrentScreen(prefix: String?, path: Any, reason: String?)`: Sets the current screen using any type for the path. ``` -------------------------------- ### SpanProcessor Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/types.md The SpanProcessor protocol defines an interface for processing span lifecycle events, allowing for custom handling of span start and end events, as well as SDK shutdown and flushing. ```APIDOC ## SpanProcessor **Namespace:** OpenTelemetry SDK (re-exported) **Type:** `protocol SpanProcessor` Interface for processing span lifecycle events. Can be implemented for custom span processing. ```swift public protocol SpanProcessor { var isStartRequired: Bool { get } var isEndRequired: Bool { get } func onStart(parentContext: SpanContext?, span: any ReadableSpan) func onEnd(span: any ReadableSpan) func shutdown(explicitTimeout: TimeInterval?) func forceFlush(timeout: TimeInterval?) } ### Properties | Property | Type | Description | |----------|------|-------------| | `isStartRequired` | `Bool` | Whether `onStart` should be called | | `isEndRequired` | `Bool` | Whether `onEnd` should be called | ### Methods | Method | Description | |--------|-------------| | `onStart(parentContext:span:)` | Called when span starts | | `onEnd(span:)` | Called when span ends | | `shutdown(explicitTimeout:)` | Called during SDK shutdown | | `forceFlush(timeout:)` | Called when flushing pending spans | ``` -------------------------------- ### build() Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/api-reference/honeycomb-options.md Builds and returns the immutable HoneycombOptions object. This method validates all configured options and throws an error if any configuration is invalid. ```APIDOC ## build() ### Description Builds and returns the immutable `HoneycombOptions` from the current builder state. Validates all options and throws errors if configuration is invalid. ### Return Type `HoneycombOptions` ### Throws `HoneycombOptionsError` - `.missingAPIKey(_)` - When connecting to Honeycomb API but API key not set - `.malformedURL(_)` - When any endpoint URL cannot be parsed - `.unsupportedProtocol(_)` - When protocol is unsupported - `.unsupportedExporter(_)` - When exporter setting is invalid ### Automatic attributes added to resource: - `honeycomb.distro.version` - SDK version - `honeycomb.distro.runtime_version` - OS version string - `telemetry.distro.name` - "honeycomb-opentelemetry-swift" - `telemetry.distro.version` - SDK version - App-specific attributes from `getAppResources()` ### Usage: ```swift let options = try HoneycombOptions.Builder() .setAPIKey("your-api-key") .setServiceName("my-app") .setSampleRate(10) .setDebug(true) .build() try Honeycomb.configure(options: options) ``` ``` -------------------------------- ### Observe Session Lifecycle Events Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/README.md Subscribe to session lifecycle events using NotificationCenter to be notified of session start and end events. This allows you to react to changes in user sessions within your application. ```swift import Sessions NotificationCenter.default.addObserver( forName: Notification.Name(SessionConstants.sessionEventNotification), object: nil, queue: .main ) { notification in guard let sessionEvent = notification.object as? SessionEvent else { return } switch sessionEvent.eventType { case .start: print("Session started: \(sessionEvent.session.id)") if let previousId = sessionEvent.session.previousId { print("Previous session: \(previousId)") } case .end: print("Session ended: \(sessionEvent.session.id)") } } ``` -------------------------------- ### Emit an Error Log Record Source: https://github.com/honeycombio/honeycomb-opentelemetry-swift/blob/main/_autodocs/types.md Get the default error logger and emit a log record with an error severity and custom attributes. Log records capture events that occur during application execution. ```swift let logger = Honeycomb.getDefaultErrorLogger() logger.logRecordBuilder() .setSeverity(.error) .setAttributes(["error": AttributeValue("value")]) .emit() ```