Skip to content

Commit

Permalink
spectator-py doc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
copperlight committed Aug 3, 2024
1 parent 3eddfd4 commit 1e077f3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
10 changes: 6 additions & 4 deletions docs/spectator/lang/py/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -56,7 +56,7 @@ with server_latency.stopwatch():
time.sleep(5)
```

**After:**
After:

```python
import time
Expand Down Expand Up @@ -85,15 +85,15 @@ 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

GlobalRegistry.gauge("server.queueSize", ttl_seconds=120).set(10)
```

**After:**
After:

```python
from spectator.registry import Registry
Expand Down Expand Up @@ -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
44 changes: 22 additions & 22 deletions docs/spectator/lang/py/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
Expand Down

0 comments on commit 1e077f3

Please sign in to comment.