Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Examples/ConcurrencyContext/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@

func childSpan() async throws {
// SpanBuilder's `setActive` method is not available here, since it isn't compatible with structured concurrency based context management
try await tracer.spanBuilder(spanName: "parentSpan").setSpanKind(spanKind: .client).withActiveSpan { span in
try await tracer.spanBuilder(spanName: "parentSpan").setSpanKind(spanKind: .client).withActiveSpan { @Sendable span in
span.setAttribute(key: sampleKey, value: sampleValue)
await Task.detached {
await Task.detached { @Sendable in
// A detached task doesn't inherit the task local context, so this span won't have a parent.
let notAChildSpan = tracer.spanBuilder(spanName: "notAChild").setSpanKind(spanKind: .client).startSpan()
notAChildSpan.setAttribute(key: sampleKey, value: sampleValue)
Expand Down
15 changes: 15 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import Foundation
Expand Down Expand Up @@ -51,7 +51,8 @@ let package = Package(
.testTarget(
name: "OpenTelemetryApiTests",
dependencies: ["OpenTelemetryApi", "OpenTelemetryTestUtils"],
path: "Tests/OpenTelemetryApiTests"
path: "Tests/OpenTelemetryApiTests",
swiftSettings: [.unsafeFlags(["-Xfrontend", "-disable-availability-checking", "-strict-concurrency=minimal"])]
),
.testTarget(
name: "OpenTelemetrySdkTests",
Expand All @@ -60,7 +61,8 @@ let package = Package(
"OpenTelemetryConcurrency",
"OpenTelemetryTestUtils",
],
path: "Tests/OpenTelemetrySdkTests"
path: "Tests/OpenTelemetrySdkTests",
swiftSettings: [.unsafeFlags(["-Xfrontend", "-disable-availability-checking"])]
),
.executableTarget(
name: "ConcurrencyContext",
Expand Down
2 changes: 1 addition & 1 deletion Scripts/semantic-convention/generate.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ROOT_DIR="${SCRIPT_DIR}/../.."
# freeze the spec & generator tools versions to make SemanticAttributes generation reproducible

# repository: https://github.com/open-telemetry/semantic-conventions
SEMCONV_VERSION=1.37.0
SEMCONV_VERSION=1.38.0
SPEC_VERSION=v$SEMCONV_VERSION

# repository: https://github.com/open-telemetry/build-tools
Expand Down
1 change: 1 addition & 0 deletions Scripts/semantic-convention/semantic-conventions
Submodule semantic-conventions added at 8e16df
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ extension SemanticConventions {
{{attribute.brief | comment}}
*/
{% if attribute is enum %}
public struct {{class_name}}: CustomStringConvertible {
public struct {{class_name}}: CustomStringConvertible, Sendable {
{% for member in attribute.type.members %}
{% if member.brief is defined %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import Foundation

/// No-op implementations of BaggageManager.
public class DefaultBaggageManager: BaggageManager {
public final class DefaultBaggageManager: BaggageManager, @unchecked Sendable {
private init() {}

/// Returns a BaggageManager singleton that is the default implementation for
/// BaggageManager.
public static var instance = DefaultBaggageManager()
public static let instance = DefaultBaggageManager()

public func baggageBuilder() -> BaggageBuilder {
return DefaultBaggageBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import Foundation

/// No-op implementations of BaggageManager.
public class DefaultBaggageManagerProvider: BaggageManagerProvider {
public static var instance = DefaultBaggageManagerProvider()
public final class DefaultBaggageManagerProvider: BaggageManagerProvider, @unchecked Sendable {
public static let instance = DefaultBaggageManagerProvider()

public func create() -> BaggageManager {
return DefaultBaggageManager.instance
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenTelemetryApi/Baggage/EmptyBaggage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import Foundation

/// An immutable implementation of the Baggage that does not contain any entries.
class EmptyBaggage: Baggage {
final class EmptyBaggage: Baggage, @unchecked Sendable {
private init() {}

/// Returns the single instance of the EmptyBaggage class.
static var instance = EmptyBaggage()
static let instance = EmptyBaggage()

static func baggageBuilder() -> BaggageBuilder {
return EmptyBaggageBuilder()
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenTelemetryApi/Baggage/EntryKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
/// and contain only printable ASCII characters.
/// EntryKeys are designed to be used as constants. Declaring each key as a constant
/// prevents key names from being validated multiple times.
public struct EntryKey: Equatable, Comparable, Hashable {
public struct EntryKey: Equatable, Comparable, Hashable, Sendable {
// RFC7230 token characters for valid keys
private static let validKeyCharacters: CharacterSet = {
var chars = CharacterSet()
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenTelemetryApi/Baggage/EntryValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation
/// A validated entry value.
/// Validation ensures that the String has a maximum length of 255 and
/// contains only printable ASCII characters.
public struct EntryValue: Equatable {
public struct EntryValue: Equatable, Sendable {
/// The maximum length for a entry value. The value is 255.
static let maxLength = 255

Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenTelemetryApi/Common/AttributeArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import Foundation

open class AttributeArray: Hashable, Codable {
open class AttributeArray: Hashable, Codable, @unchecked Sendable {
public private(set) var values: [AttributeValue]
public static var empty = AttributeArray()
public static let empty = AttributeArray()
public var description: String {
values.description
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/OpenTelemetryApi/Common/AttributeSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import Foundation

open class AttributeSet: Hashable, Codable {
open class AttributeSet: Hashable, Codable, @unchecked Sendable {
public private(set) var labels: [String: AttributeValue]

/// Empty LabelSet.
public static var empty = AttributeSet()
public static let empty = AttributeSet()

private init() {
labels = [String: AttributeValue]()
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenTelemetryApi/Common/AttributeValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import Foundation

/// An enum that represents all the possible values for an attribute.
public enum AttributeValue: Equatable, CustomStringConvertible, Hashable {
public enum AttributeValue: Equatable, CustomStringConvertible, Hashable, Sendable {
case string(String)
case bool(Bool)
case int(Int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extension SemanticConventions {
/**
This attribute represents the state of the application.
*/
public struct AppStateValues: CustomStringConvertible {
public struct AppStateValues: CustomStringConvertible, Sendable {

/// Any time before Activity.onResume() or, if the app has no Activity, Context.startService() has been called in the app for the first time.
public static let created = AppStateValues("created")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,41 @@ extension SemanticConventions {
*/
case screenCoordinateY = "app.screen.coordinate.y"

/**
An identifier that uniquely differentiates this screen from other screens in the same application.

- Examples:
```
attributes[SemanticConventions.App.screenId.rawValue] = "f9bc787d-ff05-48ad-90e1-fca1d46130b3"
attributes[SemanticConventions.App.screenId.rawValue] = "com.example.app.MainActivity"
attributes[SemanticConventions.App.screenId.rawValue] = "com.example.shop.ProductDetailFragment"
attributes[SemanticConventions.App.screenId.rawValue] = "MyApp.ProfileView"
attributes[SemanticConventions.App.screenId.rawValue] = "MyApp.ProfileViewController"
```

- Note: A screen represents only the part of the device display drawn by the app. It typically contains multiple widgets or UI components and is larger in scope than individual widgets. Multiple screens can coexist on the same display simultaneously (e.g., split view on tablets).

- Requires: Value type should be `String`
*/
case screenId = "app.screen.id"

/**
The name of an application screen.

- Examples:
```
attributes[SemanticConventions.App.screenName.rawValue] = "MainActivity"
attributes[SemanticConventions.App.screenName.rawValue] = "ProductDetailFragment"
attributes[SemanticConventions.App.screenName.rawValue] = "ProfileView"
attributes[SemanticConventions.App.screenName.rawValue] = "ProfileViewController"
```

- Note: A screen represents only the part of the device display drawn by the app. It typically contains multiple widgets or UI components and is larger in scope than individual widgets. Multiple screens can coexist on the same display simultaneously (e.g., split view on tablets).

- Requires: Value type should be `String`
*/
case screenName = "app.screen.name"

/**
An identifier that uniquely differentiates this widget from other widgets in the same application.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ extension SemanticConventions {
/**
The result of the authentication operation.
*/
public struct AuthenticationResultValues: CustomStringConvertible {
public struct AuthenticationResultValues: CustomStringConvertible, Sendable {

/// Authentication was successful.
public static let success = AuthenticationResultValues("success")
Expand All @@ -328,7 +328,7 @@ extension SemanticConventions {
/**
The result of calling the authorization service.
*/
public struct AuthorizationResultValues: CustomStringConvertible {
public struct AuthorizationResultValues: CustomStringConvertible, Sendable {

/// Authorization was successful.
public static let success = AuthorizationResultValues("success")
Expand All @@ -350,7 +350,7 @@ extension SemanticConventions {
/**
ASP.NET Core exception middleware handling result.
*/
public struct DiagnosticsExceptionResultValues: CustomStringConvertible {
public struct DiagnosticsExceptionResultValues: CustomStringConvertible, Sendable {

/// Exception was handled by the exception handling middleware.
public static let handled = DiagnosticsExceptionResultValues("handled")
Expand Down Expand Up @@ -378,7 +378,7 @@ extension SemanticConventions {
/**
The result from checking the password.
*/
public struct IdentityPasswordCheckResultValues: CustomStringConvertible {
public struct IdentityPasswordCheckResultValues: CustomStringConvertible, Sendable {

/// Password check was successful.
public static let success = IdentityPasswordCheckResultValues("success")
Expand Down Expand Up @@ -409,7 +409,7 @@ extension SemanticConventions {
/**
The result of the identity operation.
*/
public struct IdentityResultValues: CustomStringConvertible {
public struct IdentityResultValues: CustomStringConvertible, Sendable {

/// Identity operation was successful.
public static let success = IdentityResultValues("success")
Expand All @@ -431,7 +431,7 @@ extension SemanticConventions {
/**
Whether the sign in result was success or failure.
*/
public struct IdentitySignInResultValues: CustomStringConvertible {
public struct IdentitySignInResultValues: CustomStringConvertible, Sendable {

/// Sign in was successful.
public static let success = IdentitySignInResultValues("success")
Expand Down Expand Up @@ -462,7 +462,7 @@ extension SemanticConventions {
/**
The authentication type.
*/
public struct IdentitySignInTypeValues: CustomStringConvertible {
public struct IdentitySignInTypeValues: CustomStringConvertible, Sendable {

/// Sign in with password.
public static let password = IdentitySignInTypeValues("password")
Expand Down Expand Up @@ -496,7 +496,7 @@ extension SemanticConventions {
/**
What the token will be used for.
*/
public struct IdentityTokenPurposeValues: CustomStringConvertible {
public struct IdentityTokenPurposeValues: CustomStringConvertible, Sendable {

/// The token is for resetting a user password.
public static let resetPassword = IdentityTokenPurposeValues("reset_password")
Expand Down Expand Up @@ -530,7 +530,7 @@ extension SemanticConventions {
/**
The result of token verification.
*/
public struct IdentityTokenVerifiedValues: CustomStringConvertible {
public struct IdentityTokenVerifiedValues: CustomStringConvertible, Sendable {

/// Token verification was successful.
public static let success = IdentityTokenVerifiedValues("success")
Expand All @@ -552,7 +552,7 @@ extension SemanticConventions {
/**
The user update type.
*/
public struct IdentityUserUpdateTypeValues: CustomStringConvertible {
public struct IdentityUserUpdateTypeValues: CustomStringConvertible, Sendable {

/// Identity user updated.
public static let update = IdentityUserUpdateTypeValues("update")
Expand Down Expand Up @@ -667,7 +667,7 @@ extension SemanticConventions {
/**
Rate-limiting result, shows whether the lease was acquired or contains a rejection reason
*/
public struct RateLimitingResultValues: CustomStringConvertible {
public struct RateLimitingResultValues: CustomStringConvertible, Sendable {

/// Lease was acquired
public static let acquired = RateLimitingResultValues("acquired")
Expand Down Expand Up @@ -695,7 +695,7 @@ extension SemanticConventions {
/**
Match result - success or failure
*/
public struct RoutingMatchStatusValues: CustomStringConvertible {
public struct RoutingMatchStatusValues: CustomStringConvertible, Sendable {

/// Match succeeded
public static let success = RoutingMatchStatusValues("success")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ extension SemanticConventions {
/**
The [launch type](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html) for an ECS task.
*/
public struct EcsLaunchtypeValues: CustomStringConvertible {
public struct EcsLaunchtypeValues: CustomStringConvertible, Sendable {

/// Amazon EC2
public static let ec2 = EcsLaunchtypeValues("ec2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extension SemanticConventions {
attributes[SemanticConventions.Azure.cosmosdbOperationContactedRegions.rawValue] = ["North Central US", "Australia East", "Australia Southeast"]
```

- Note: Region name matches the format of `displayName` in [Azure Location API](https://learn.microsoft.com/rest/api/subscription/subscriptions/list-locations?view=rest-subscription-2021-10-01&tabs=HTTP#location)
- Note: Region name matches the format of `displayName` in [Azure Location API](https://learn.microsoft.com/rest/api/resources/subscriptions/list-locations)

- Requires: Value type should be `[String]`
*/
Expand Down Expand Up @@ -122,7 +122,7 @@ extension SemanticConventions {
/**
Cosmos client connection mode.
*/
public struct CosmosdbConnectionModeValues: CustomStringConvertible {
public struct CosmosdbConnectionModeValues: CustomStringConvertible, Sendable {

/// Gateway (HTTP) connection.
public static let gateway = CosmosdbConnectionModeValues("gateway")
Expand All @@ -144,7 +144,7 @@ extension SemanticConventions {
/**
Account or request [consistency level](https://learn.microsoft.com/azure/cosmos-db/consistency-levels).
*/
public struct CosmosdbConsistencyLevelValues: CustomStringConvertible {
public struct CosmosdbConsistencyLevelValues: CustomStringConvertible, Sendable {

/// Strong
public static let strong = CosmosdbConsistencyLevelValues("Strong")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ extension SemanticConventions {
/**
The consistency level of the query. Based on consistency values from [CQL](https://docs.datastax.com/en/cassandra-oss/3.0/cassandra/dml/dmlConfigConsistency.html).
*/
public struct ConsistencyLevelValues: CustomStringConvertible {
public struct ConsistencyLevelValues: CustomStringConvertible, Sendable {

/// All
public static let all = ConsistencyLevelValues("all")
Expand Down
Loading
Loading