Skip to content

Commit 408a7a3

Browse files
committed
=docc initial docc docs setup
some initial docc preparation remove jazzy we need ruby still formatting docker cleanups some more docs for the types Apply suggestions from code review Co-authored-by: Yim Lee <[email protected]> license fix
1 parent 52e86db commit 408a7a3

21 files changed

+529
-208
lines changed

.swiftformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
--extensionacl on-declarations
1313
--disable typeSugar
1414

15-
# rules
15+
# rules

Package.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.6
22
//===----------------------------------------------------------------------===//
33
//
44
// This source file is part of the Swift Metrics API open source project
@@ -23,19 +23,29 @@ let package = Package(
2323
],
2424
dependencies: [
2525
.package(url: "https://github.com/apple/swift-metrics.git", from: "2.3.2"),
26+
27+
// ~~~ SwiftPM Plugins ~~~
28+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
2629
],
2730
targets: [
2831
.target(
2932
name: "SystemMetrics",
30-
dependencies: ["CoreMetrics"]
33+
dependencies: [
34+
.product(name: "CoreMetrics", package: "swift-metrics"),
35+
]
3136
),
3237
.target(
3338
name: "MetricsTestUtils",
34-
dependencies: ["Metrics", "CoreMetrics"]
39+
dependencies: [
40+
.product(name: "Metrics", package: "swift-metrics"),
41+
.product(name: "CoreMetrics", package: "swift-metrics"),
42+
]
3543
),
3644
.testTarget(
3745
name: "SystemMetricsTests",
38-
dependencies: ["SystemMetrics"]
46+
dependencies: [
47+
"SystemMetrics",
48+
]
3949
),
4050
]
4151
)

[email protected]

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// swift-tools-version:5.0
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// This source file is part of the Swift Metrics API open source project
5+
//
6+
// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors
7+
// Licensed under Apache License v2.0
8+
//
9+
// See LICENSE.txt for license information
10+
// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors
11+
//
12+
// SPDX-License-Identifier: Apache-2.0
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
import PackageDescription
17+
18+
let package = Package(
19+
name: "swift-metrics-extras",
20+
products: [
21+
.library(name: "SystemMetrics", targets: ["SystemMetrics"]),
22+
.library(name: "MetricsTestUtils", targets: ["MetricsTestUtils"]),
23+
],
24+
dependencies: [
25+
.package(url: "https://github.com/apple/swift-metrics.git", from: "2.3.2"),
26+
],
27+
targets: [
28+
.target(
29+
name: "SystemMetrics",
30+
dependencies: ["CoreMetrics"]
31+
),
32+
.target(
33+
name: "MetricsTestUtils",
34+
dependencies: ["Metrics", "CoreMetrics"]
35+
),
36+
.testTarget(
37+
name: "SystemMetricsTests",
38+
dependencies: ["SystemMetrics"]
39+
),
40+
]
41+
)

[email protected]

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// swift-tools-version:5.1
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// This source file is part of the Swift Metrics API open source project
5+
//
6+
// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors
7+
// Licensed under Apache License v2.0
8+
//
9+
// See LICENSE.txt for license information
10+
// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors
11+
//
12+
// SPDX-License-Identifier: Apache-2.0
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
import PackageDescription
17+
18+
let package = Package(
19+
name: "swift-metrics-extras",
20+
products: [
21+
.library(name: "SystemMetrics", targets: ["SystemMetrics"]),
22+
.library(name: "MetricsTestUtils", targets: ["MetricsTestUtils"]),
23+
],
24+
dependencies: [
25+
.package(url: "https://github.com/apple/swift-metrics.git", from: "2.3.2"),
26+
],
27+
targets: [
28+
.target(
29+
name: "SystemMetrics",
30+
dependencies: ["CoreMetrics"]
31+
),
32+
.target(
33+
name: "MetricsTestUtils",
34+
dependencies: ["Metrics", "CoreMetrics"]
35+
),
36+
.testTarget(
37+
name: "SystemMetricsTests",
38+
dependencies: ["SystemMetrics"]
39+
),
40+
]
41+
)

[email protected]

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// swift-tools-version:5.2
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// This source file is part of the Swift Metrics API open source project
5+
//
6+
// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors
7+
// Licensed under Apache License v2.0
8+
//
9+
// See LICENSE.txt for license information
10+
// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors
11+
//
12+
// SPDX-License-Identifier: Apache-2.0
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
import PackageDescription
17+
18+
let package = Package(
19+
name: "swift-metrics-extras",
20+
products: [
21+
.library(name: "SystemMetrics", targets: ["SystemMetrics"]),
22+
.library(name: "MetricsTestUtils", targets: ["MetricsTestUtils"]),
23+
],
24+
dependencies: [
25+
.package(url: "https://github.com/apple/swift-metrics.git", from: "2.3.2"),
26+
],
27+
targets: [
28+
.target(
29+
name: "SystemMetrics",
30+
dependencies: [
31+
.product(name: "CoreMetrics", package: "swift-metrics"),
32+
]
33+
),
34+
.target(
35+
name: "MetricsTestUtils",
36+
dependencies: [
37+
.product(name: "Metrics", package: "swift-metrics"),
38+
.product(name: "CoreMetrics", package: "swift-metrics"),
39+
]
40+
),
41+
.testTarget(
42+
name: "SystemMetricsTests",
43+
dependencies: [
44+
"SystemMetrics",
45+
]
46+
),
47+
]
48+
)

[email protected]

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// swift-tools-version:5.3
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// This source file is part of the Swift Metrics API open source project
5+
//
6+
// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors
7+
// Licensed under Apache License v2.0
8+
//
9+
// See LICENSE.txt for license information
10+
// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors
11+
//
12+
// SPDX-License-Identifier: Apache-2.0
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
import PackageDescription
17+
18+
let package = Package(
19+
name: "swift-metrics-extras",
20+
products: [
21+
.library(name: "SystemMetrics", targets: ["SystemMetrics"]),
22+
.library(name: "MetricsTestUtils", targets: ["MetricsTestUtils"]),
23+
],
24+
dependencies: [
25+
.package(url: "https://github.com/apple/swift-metrics.git", from: "2.3.2"),
26+
],
27+
targets: [
28+
.target(
29+
name: "SystemMetrics",
30+
dependencies: [
31+
.product(name: "CoreMetrics", package: "swift-metrics"),
32+
]
33+
),
34+
.target(
35+
name: "MetricsTestUtils",
36+
dependencies: [
37+
.product(name: "Metrics", package: "swift-metrics"),
38+
.product(name: "CoreMetrics", package: "swift-metrics"),
39+
]
40+
),
41+
.testTarget(
42+
name: "SystemMetricsTests",
43+
dependencies: [
44+
"SystemMetrics",
45+
]
46+
),
47+
]
48+
)

[email protected]

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// swift-tools-version:5.4
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// This source file is part of the Swift Metrics API open source project
5+
//
6+
// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors
7+
// Licensed under Apache License v2.0
8+
//
9+
// See LICENSE.txt for license information
10+
// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors
11+
//
12+
// SPDX-License-Identifier: Apache-2.0
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
import PackageDescription
17+
18+
let package = Package(
19+
name: "swift-metrics-extras",
20+
products: [
21+
.library(name: "SystemMetrics", targets: ["SystemMetrics"]),
22+
.library(name: "MetricsTestUtils", targets: ["MetricsTestUtils"]),
23+
],
24+
dependencies: [
25+
.package(url: "https://github.com/apple/swift-metrics.git", from: "2.3.2"),
26+
],
27+
targets: [
28+
.target(
29+
name: "SystemMetrics",
30+
dependencies: [
31+
.product(name: "CoreMetrics", package: "swift-metrics"),
32+
]
33+
),
34+
.target(
35+
name: "MetricsTestUtils",
36+
dependencies: [
37+
.product(name: "Metrics", package: "swift-metrics"),
38+
.product(name: "CoreMetrics", package: "swift-metrics"),
39+
]
40+
),
41+
.testTarget(
42+
name: "SystemMetricsTests",
43+
dependencies: [
44+
"SystemMetrics",
45+
]
46+
),
47+
]
48+
)

[email protected]

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// swift-tools-version:5.5
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// This source file is part of the Swift Metrics API open source project
5+
//
6+
// Copyright (c) 2018-2019 Apple Inc. and the Swift Metrics API project authors
7+
// Licensed under Apache License v2.0
8+
//
9+
// See LICENSE.txt for license information
10+
// See CONTRIBUTORS.txt for the list of Swift Metrics API project authors
11+
//
12+
// SPDX-License-Identifier: Apache-2.0
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
import PackageDescription
17+
18+
let package = Package(
19+
name: "swift-metrics-extras",
20+
products: [
21+
.library(name: "SystemMetrics", targets: ["SystemMetrics"]),
22+
.library(name: "MetricsTestUtils", targets: ["MetricsTestUtils"]),
23+
],
24+
dependencies: [
25+
.package(url: "https://github.com/apple/swift-metrics.git", from: "2.3.2"),
26+
],
27+
targets: [
28+
.target(
29+
name: "SystemMetrics",
30+
dependencies: [
31+
.product(name: "CoreMetrics", package: "swift-metrics"),
32+
]
33+
),
34+
.target(
35+
name: "MetricsTestUtils",
36+
dependencies: [
37+
.product(name: "Metrics", package: "swift-metrics"),
38+
.product(name: "CoreMetrics", package: "swift-metrics"),
39+
]
40+
),
41+
.testTarget(
42+
name: "SystemMetricsTests",
43+
dependencies: [
44+
"SystemMetrics",
45+
]
46+
),
47+
]
48+
)

README.md

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ or other such metric system agnostic metrics additions–such additions are perf
2222
To add a dependency on the extras package, you need to declare it in your `Package.swift`:
2323

2424
```swift
25-
.package(url: "https://github.com/apple/swift-metrics-extras.git", "1.0.0" ..< "2.0.0"),
25+
.package(url: "https://github.com/apple/swift-metrics-extras.git", from: "0.1.0"),
2626
```
2727

2828
and to your application/library target, add the specific module you would like to depend on to your dependencies:
@@ -37,57 +37,3 @@ Swift Metrics Extras ships the following extra modules:
3737

3838
- [System Metrics](Sources/SystemMetrics)
3939
- [MetricsTestUtils](Sources/MetricsTestUtils)
40-
41-
### System Metrics
42-
43-
The System Metrics package provides default process metrics for applications. The following metrics are exposed:
44-
45-
- Virtual memory in Bytes.
46-
- Resident memory in Bytes.
47-
- Application start time in Seconds.
48-
- Total CPU seconds.
49-
- Maximum number of file descriptors.
50-
- Number of file descriptors currently in use.
51-
52-
***NOTE:*** Currently these metrics are only implemented on Linux platforms, and not on Darwin or Windows.
53-
54-
#### Using System Metrics
55-
56-
After [adding swift-metrics-extras as a dependency](#adding-the-dependency) you can import the `SystemMetrics` module.
57-
58-
```swift
59-
import SystemMetrics
60-
```
61-
62-
This makes the System Metrics API available. This adds a new method to `MetricsSystem` called `bootstrapWithSystemMetrics`. Calling this method will call `MetricsSystem.bootstrap` as well as bootstrapping System Metrics.
63-
64-
`bootstrapWithSystemMetrics` takes a `SystemMetrics.Configuration` object to configure the system metrics. The config has the following properties:
65-
66-
- interval: The interval at which SystemMetrics are being calculated & exported.
67-
- dataProvider: A closure returing `SystemMetrics.Data?`. When `nil` no metrics are exported (the default on non-linux platforms). `SystemMetrics.Data` holds all the values mentioned above.
68-
- labels: `SystemMetrics.Labels` hold a string label for each of the above mentioned metrics that will be used for the metric labels, along with a prefix that will be used for all above mentioned metrics.
69-
70-
Swift Metrics backend implementations are encouraged to provide static extensions to `SystemMetrics.Configuration` that fit the requirements of their specific backends. For example:
71-
```swift
72-
public extension SystemMetrics.Configuration {
73-
/// `SystemMetrics.Configuration` with Prometheus style labels.
74-
///
75-
/// For more information see `SystemMetrics.Configuration`
76-
static let prometheus = SystemMetrics.Configuration(
77-
labels: .init(
78-
prefix: "process_",
79-
virtualMemoryBytes: "virtual_memory_bytes",
80-
residentMemoryBytes: "resident_memory_bytes",
81-
startTimeSeconds: "start_time_seconds",
82-
cpuSecondsTotal: "cpu_seconds_total",
83-
maxFds: "max_fds",
84-
openFds: "open_fds"
85-
)
86-
)
87-
}
88-
```
89-
This allows end users to add System Metrics like this:
90-
91-
```swift
92-
MetricsSystem.bootstrapWithSystemMetrics(myPrometheusInstance, config: .prometheus)
93-
```

0 commit comments

Comments
 (0)