From 1e077f3c4d4b87b562bc9460de89c8ae77638e54 Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Fri, 2 Aug 2024 22:49:16 -0400 Subject: [PATCH] spectator-py doc fixes --- docs/spectator/lang/py/migrations.md | 10 ++++--- docs/spectator/lang/py/usage.md | 44 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/docs/spectator/lang/py/migrations.md b/docs/spectator/lang/py/migrations.md index 24a6165d..63d5bccf 100644 --- a/docs/spectator/lang/py/migrations.md +++ b/docs/spectator/lang/py/migrations.md @@ -44,7 +44,7 @@ class. It has been preserved, because it continues to fulfill the purpose of sim and `PercentileTimer` meters record their values after exiting a block of code, and there are a few uses of this class across the organization. -**Before:** +Before: ```python import time @@ -56,7 +56,7 @@ with server_latency.stopwatch(): time.sleep(5) ``` -**After:** +After: ```python import time @@ -85,7 +85,7 @@ maintained to help minimize the amount of code change that application owners ne when adopting the thin-client version of the library. Replace with direct use of `Registry`. * There are no plans to remove the `GlobalRegistry`, until we know that all uses have been removed. -**Before:** +Before: ```python from spectator import GlobalRegistry @@ -93,7 +93,7 @@ from spectator import GlobalRegistry GlobalRegistry.gauge("server.queueSize", ttl_seconds=120).set(10) ``` -**After:** +After: ```python from spectator.registry import Registry @@ -156,3 +156,5 @@ to SpectatorD. * Implemented new meter types supported by [SpectatorD]: `age_gauge`, `max_gauge` and `monotonic_counter`. See the SpectatorD documentation or the class docstrings for more details. + +[SpectatorD]: ../../agent/usage.md diff --git a/docs/spectator/lang/py/usage.md b/docs/spectator/lang/py/usage.md index d9059a35..fea6db39 100644 --- a/docs/spectator/lang/py/usage.md +++ b/docs/spectator/lang/py/usage.md @@ -219,6 +219,28 @@ registry = Registry(config) registry.counter("server.numRequests").increment() ``` +## Output Location + +If you need to override the default output location (UDP) of the `Registry`, then you can set a +`Config` class location to one of the following supported values: + +* `none` - Disable output. +* `memory` - Write to memory. +* `stderr` - Write to standard error for the process. +* `stdout` - Write to standard out for the process. +* `udp` - Write to the default UDP port for `spectatord`. +* `unix` - Write to the default unix datagram socket for `spectatord`. +* `file://$path_to_file` - Write to a custom file (e.g. `file:///tmp/foo/bar`). +* `udp://$host:$port` - Write to a custom UDP socket. + +The `SPECTATOR_OUTPUT_LOCATION` environment variable accepts the same values, and can be used to +override the value provided to the `Config` class, which may be useful in CI/CD contexts. For +example, if you want to disable metrics publishing from the `Registry`, then you can set: + +```shell +export SPECTATOR_OUTPUT_LOCATION=none +``` + ## Writing Tests To write tests against this library, instantiate an instance of the `Registry` and provide a `Config` @@ -245,28 +267,6 @@ class MetricsTest(unittest.TestCase): self.assertEqual("c:server.numRequests:1", r.writer().last_line()) ``` -### Overriding Output Location - -If you need to override the default output location (UDP) of the `Registry`, then you can set a -`Config` class location to one of the following supported values: - -* `none` - Disable output. -* `memory` - Write to memory. -* `stderr` - Write to standard error for the process. -* `stdout` - Write to standard out for the process. -* `udp` - Write to the default UDP port for spectatord. -* `unix` - Write to the default unix datagram socket for spectatord. -* `file://$path_to_file` - Write to a custom file (e.g. `file:///tmp/foo/bar`). -* `udp://$host:$port` - Write to a custom UDP socket. - -The `SPECTATOR_OUTPUT_LOCATION` environment variable accepts the same values, and can be used to -override the value provided to the `Config` class, which may be useful in CI/CD contexts. For -example, if you want to disable metrics publishing from the `Registry`, then you can set: - -```shell -export SPECTATOR_OUTPUT_LOCATION=none -``` - ### Protocol Parser A [SpectatorD] line protocol parser is available, which ca be used for validating the results