# `Snakepit.Telemetry.GrpcStream`
[🔗](https://github.com/nshkrdotcom/snakepit/blob/v0.13.0/lib/snakepit/telemetry/grpc_stream.ex#L1)

Manages gRPC telemetry streams from Python workers.

This GenServer maintains bidirectional telemetry streams with Python workers,
translating Python telemetry events into Elixir `:telemetry` events.

Features:
- Automatic stream registration when workers connect
- Dynamic sampling rate adjustments
- Event filtering
- Graceful handling of worker disconnections

# `worker_ctx`

```elixir
@type worker_ctx() :: %{
  worker_id: String.t(),
  pool_name: atom(),
  python_pid: integer() | nil
}
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `list_streams`

Gets the current state of all registered streams.

# `register_worker`

Registers a worker for telemetry streaming.

Automatically initiates a telemetry stream with the worker and starts
consuming events.

## Examples

    iex> channel = connect_to_worker()
    iex> Snakepit.Telemetry.GrpcStream.register_worker(channel, %{
    ...>   worker_id: "worker_1",
    ...>   pool_name: :default,
    ...>   python_pid: 12345
    ...> })
    :ok

# `start_link`

Starts the telemetry stream manager.

# `toggle`

Enables or disables telemetry for a specific worker.

# `unregister_worker`

Removes a worker from telemetry streaming.

Called when a worker disconnects or terminates.

# `update_filter`

Updates event filters for a specific worker.

# `update_sampling`

Updates the sampling rate for a specific worker.

## Examples

    iex> Snakepit.Telemetry.GrpcStream.update_sampling("worker_1", 0.1)
    :ok

    iex> Snakepit.Telemetry.GrpcStream.update_sampling("worker_1", 0.5, ["python.call.*"])
    :ok

---

*Consult [api-reference.md](api-reference.md) for complete listing*
