Skip to main content

Runtime monitoring plugin for fasteval with async sampling and structured logging

Project description

fasteval-observe

Runtime monitoring plugin for fasteval with async sampling and structured logging.

Installation

pip install fasteval-core fasteval-observe

Quick Start

import fasteval as fe
from fasteval_observe import observe
from fasteval_observe.sampling import FixedRateSamplingStrategy

# Monitor 5% of agent calls with structured logging
@observe(sampling=FixedRateSamplingStrategy(rate=0.05))
async def my_agent(query: str) -> str:
    response = await llm.invoke(query)
    return response

# Combine with fasteval evaluation metrics
@observe(
    sampling=FixedRateSamplingStrategy(rate=0.05),
    run_evaluations=True  # Run @fe.* metrics in background
)
@fe.correctness(threshold=0.8)
async def evaluated_agent(query: str) -> str:
    response = await llm.invoke(query)
    return response

Sampling Strategies

Built-in Strategies

  • NoSamplingStrategy - Sample every call (development/debugging)
  • FixedRateSamplingStrategy - Fixed rate sampling (e.g., 1 in N calls)
  • ProbabilisticSamplingStrategy - Random probability-based sampling
  • AdaptiveSamplingStrategy - Adjust rate based on latency/errors
  • TokenBudgetSamplingStrategy - Sample based on token cost
  • ComposableSamplingStrategy - Combine multiple strategies

Custom Strategies

from fasteval_observe.sampling import BaseSamplingStrategy

class MyCustomStrategy(BaseSamplingStrategy):
    def should_sample(self, function_name, args, kwargs, context):
        # Custom logic
        return True

@observe(sampling=MyCustomStrategy())
async def my_agent(query: str) -> str:
    return await process(query)

Configuration

from fasteval_observe import configure_observe, ObserveConfig, set_logger
import logging

configure_observe(ObserveConfig(
    enabled=True,
    flush_interval_seconds=5.0,
    max_queue_size=10000,
    include_inputs=False,  # Privacy: don't log inputs
    include_outputs=False,
))

# Optional: Use custom logger for file output, cloud logging, etc.
my_logger = logging.getLogger("my_app.observations")
my_logger.addHandler(logging.FileHandler("/var/log/observations.jsonl"))
set_logger(my_logger)

Structured Logging

Observations are logged as JSON for easy collection by Kubernetes sidecars, Fluentd, etc:

{
  "timestamp": "2026-02-03T10:15:30.123Z",
  "source": "fasteval_observe",
  "function_name": "my_agent",
  "execution_time_ms": 1234.56,
  "sampling_strategy": "FixedRateSamplingStrategy",
  "metrics": {
    "latency_ms": 1234.56,
    "success": true
  }
}

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fasteval_observe-1.0.0a1.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fasteval_observe-1.0.0a1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file fasteval_observe-1.0.0a1.tar.gz.

File metadata

  • Download URL: fasteval_observe-1.0.0a1.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fasteval_observe-1.0.0a1.tar.gz
Algorithm Hash digest
SHA256 fcea78acf5f8c6639e0cee9c2ee9031d9b417624c8d84513262dc733b491e6ff
MD5 057d5cde2c3e833ac7233254dd385648
BLAKE2b-256 4d7088f883035bf51999e8a2144b03153086af3a779e834e747c553a06ca4f44

See more details on using hashes here.

File details

Details for the file fasteval_observe-1.0.0a1-py3-none-any.whl.

File metadata

  • Download URL: fasteval_observe-1.0.0a1-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fasteval_observe-1.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae05525b957df7ca18b1d824254c5f583509c4a5f2bf1fd0f9ee14c78a25ee30
MD5 67720b7115f3fd48cf5cc97c6756c30d
BLAKE2b-256 4f54ba96d3393cc44deb096870ea4c8675e8c051407da6bf0c0ed32adf504c51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page