-
Notifications
You must be signed in to change notification settings - Fork 10
/
SpanAttributes+ThreadSemantics.swift
51 lines (44 loc) · 1.77 KB
/
SpanAttributes+ThreadSemantics.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Distributed Tracing open source project
//
// Copyright (c) 2023 Apple Inc. and the Swift Distributed Tracing project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift Distributed Tracing project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Tracing
extension SpanAttributes {
/// General thread attributes.
///
/// OpenTelemetry Spec: [General thread attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.11.0/specification/trace/semantic_conventions/span-general.md#general-thread-attributes)
public var thread: ThreadAttributes {
get {
.init(attributes: self)
}
set {
self = newValue.attributes
}
}
}
/// General thread attributes.
///
/// OpenTelemetry Spec: [General thread attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.11.0/specification/trace/semantic_conventions/span-general.md#general-thread-attributes)
@dynamicMemberLookup
public struct ThreadAttributes: SpanAttributeNamespace {
public var attributes: SpanAttributes
public init(attributes: SpanAttributes) {
self.attributes = attributes
}
public struct NestedSpanAttributes: NestedSpanAttributesProtocol {
public init() {}
/// Current "managed" thread ID (as opposed to OS thread ID). E.g. 42.
public var id: Key<Int> { "thread.id" }
/// Current thread name. E.g. "main".
public var name: Key<String> { "thread.name" }
}
}