Skip to content

Conversation

@heckj
Copy link
Contributor

@heckj heckj commented Jan 7, 2026

Motivation:

Review of content against docs style guides for upcoming 1.0 release

Modifications:

  • adds in default docs curation for the public types and articles
  • rework language for Apple style guide as well as active voice, present tense, and American english spelling choices. Fixes some typos as well.
  • shifting content into getting started, revising descriptions, removing passive voice
  • manually linking to metrics API (hosted at SPI)

Before:

   --- Experimental coverage output enabled. ---
                | Abstract        | Curated         | Code Listing
Types           | 100% (2/2)      | 50% (1/2)       | 50% (1/2)
Members         | 100% (6/6)      | 0.0% (0/6)      | 0.0% (0/6)
Globals         | 100% (1/1)      | 100% (1/1)      | 100% (1/1)

After:

   --- Experimental coverage output enabled. ---
                | Abstract        | Curated         | Code Listing
Types           | 100% (2/2)      | 100% (2/2)      | 50% (1/2)
Members         | 100% (6/6)      | 100% (6/6)      | 0.0% (0/6)
Globals         | 100% (1/1)      | 100% (1/1)      | 0.0% (0/1)

To quickly preview locally:

gh pr checkout 81
swift package add-dependency https://github.com/swiftlang/swift-docc-plugin --from 1.0.0
swift package --disable-sandbox preview-documentation --target SystemMetrics

ex:
Screenshot 2026-01-07 at 4 22 33 PM

Biggest notable change that you we may not want to run with - I trimmed down what was at the top level, shifting away from the format that swift-configuration used, because that information felt overwhelming (it felt like a giant README trying to shove too much in there), and moved the getting started into a concise article that I curated inline.

I haven't added, but could, a quick walk through article with image snapshots w/ Examples/ServiceIntegration to show setting it up and seeing the metrics being reported in a local grafana instance, although I think the README in that directory is already pretty darned good and gets to the core for someone who just wants to see it work to get a sense of what's included.

@heckj heckj self-assigned this Jan 7, 2026
@heckj heckj added semver/none No version bump required. area/documentation Improvements or additions to documentation. labels Jan 7, 2026
@heckj heckj requested a review from kukushechkin January 8, 2026 00:20
@heckj heckj marked this pull request as ready for review January 8, 2026 00:20
Copy link
Contributor

@czechboy0 czechboy0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @heckj, added a few more suggestions

@@ -0,0 +1,13 @@
# ``SystemMetricsMonitor``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been meaning to ask - what's the docc command to generate these? Or did you hand-write them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol - I hand wrote these. There's not a DocC command to generate them one off, unfortunately- I've just got 'my pattern' of how I do it, which it mostly stub, see what show's up in preview, then iterate to drop the right pieces into place.

That said, there is a curation generation command - although I'm not certain if anyone actually uses it, as it's not detailed anywhere in the docs. The gist of which is:

  • create/get the symbols for the target/module
  • use docc process-catalog to emit a default catalog
mkdir .symbolgraphs
xcrun swift build --target MyProjectExample \
  -Xswiftc -emit-symbol-graph \
  -Xswiftc -emit-symbol-graph-dir \
  -Xswiftc .symbolgraphs
mkdir Sources/MyProjectExample/Documentation.docc

# better generation using --from-symbol
# which constrains the generated content to MyProjectExample
xcrun docc process-catalog \
  emit-generated-curation \
  Sources/MyProjectExample/Documentation.docc \
  --from-symbol MyProjectExample \
  --additional-symbol-graph-dir .symbolgraphs

So it's kind of a pain to use...

## Topics

## Getting started
### Monitor system metrics
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Monitor system metrics
### Essentials

I think "Essentials" is the usual name of the first section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We see it commonly, but at least in the broader API guides, the last guidance I got here was essentials was meant to be "the things you critically had to know to be able to use the API", which I took as a placeholder to mean explanatory content prefixed into the getting started pieces when needed. This didn't quite seem to hit that bar for me, so I leaned into just giving a functional heading that made it reinforced what this was doing, especially since this is just a simple API surface.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's fair - though I'd argue if you don't learn the SystemMetricMonitor API, then there isn't much you can do with the library. So IMO it does raise to the bar of being essential.

## Overview

``SystemMetricsMonitor`` automatically collects key process metrics and reports them through the Swift Metrics API.
Create an instance of ``SystemMetricsMonitor`` to automatically collect key process metrics and report them through the Swift Metrics API.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should preserve the short code snippet, including the dependency snippets, here as well. We try to do that in most of our other packages, as that's what most people landing on this page want to see. We should still preserve the new, more detailed getting started guide, though.

So, I think this should show up on this page (the least customized way to run a system metrics monitor):

import SystemMetrics
import ServiceLifecycle
import Metrics
import Logging

@main
struct Application {
    static func main() async throws {
        let logger = Logger(label: "Application")
        let metrics = MyMetricsBackendImplementation()
        MetricsSystem.bootstrap(metrics)

        let service = FooService()
        let systemMetricsMonitor = SystemMetricsMonitor(logger: logger)

        let serviceGroup = ServiceGroup(
            services: [service, systemMetricsMonitor],
            gracefulShutdownSignals: [.sigint],
            cancellationSignals: [.sigterm],
            logger: logger
        )

        try await serviceGroup.run()
    }
}

README.md Outdated
import SystemMetrics

// Create a logger, or use one of the existing loggers
let logger = Logger(label: "MyLogger")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add the metrics factory here as well to avoid confusion about where the metrics go, so:

import SystemMetrics
import ServiceLifecycle
import Metrics
import Logging

@main
struct Application {
    static func main() async throws {
        let logger = Logger(label: "Application")
        let metrics = MyMetricsBackendImplementation()
        MetricsSystem.bootstrap(metrics)

        let service = FooService()
        let systemMetricsMonitor = SystemMetricsMonitor(logger: logger)

        let serviceGroup = ServiceGroup(
            services: [service, systemMetricsMonitor],
            gracefulShutdownSignals: [.sigint],
            cancellationSignals: [.sigterm],
            logger: logger
        )

        try await serviceGroup.run()
    }
}

Copy link
Contributor Author

@heckj heckj Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in a follow on PR, but this example (which I copy-pasted) isn't using the factory initializer - wasn't 100% sure what that looked like, and honestly if we wanted to promote that path or not. I expect that anything in the README will be the first thing to be copy/pasted into place as an example that gets modified - so I think whatever we expect to be most commonly used would be best here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@czechboy0 do you suggest we change example to use SystemMetricsMonitor(metricsFactory:logger:)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should show the simplest one in the README, so the one without the factory parameter. Customizing the metrics factory is a slightly more advanced use case.

Copy link
Contributor

@kukushechkin kukushechkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for these improvements and explaining the reasoning behind it.

Create an instance of ``SystemMetricsMonitor`` to automatically collect key process metrics and report them through the Swift Metrics API.

### Available metrics
The monitor collects the following metrics:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a max window width the reported label is split into two lines, making it hard to read the label. Can a thing inside the ticks marked to be rendered without line breaks?

Image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can maybe move the constants into a nested bullet point under each metric? That way they'll always start on the same column.

@kukushechkin kukushechkin self-requested a review January 9, 2026 10:28
@heckj heckj merged commit bffbbc4 into apple:main Jan 13, 2026
34 checks passed
@heckj heckj deleted the docs-curation branch January 13, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Improvements or additions to documentation. semver/none No version bump required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants