geeViz.eeAuth.monitoring

Earth Engine usage monitoring — Cloud Monitoring poller.

Reads the earthengine.googleapis.com/project/cpu/usage_time metric from Cloud Monitoring, aggregates at a caller-chosen bucket size (grouping_seconds, default 3600 = hourly), and returns per-workload_tag rows. Attribution is not this module’s concern — it returns the raw tag string; the caller joins it to whatever storage they maintain (tag → parts mapping table, users table, etc.) to recover human-readable identity.

Design constraint: reversible tag encoding within EE’s 63-char workload_tag limit turns out to be infeasible for realistic attribution tuples (see comments in geeViz/eeAuth/tags.py). Rather than half-solve the reversibility problem, this module cleanly stops at “here are the tags and their EECU consumption” — everything upstream (mint the tag from parts + store the mapping) and everything downstream (join back for display, feed a billing ledger) stays with the caller.

Typical wiring:

from geeViz.eeAuth.monitoring import EEUsageMonitor

monitor = EEUsageMonitor(project="my-gcp-project",
                          cost_per_eecu_hour=0.40)
rows = monitor.poll(start_time=..., end_time=...)
# rows: [{workload_tag, bucket_start, eecu_seconds,
#         eecu_hours, cost_usd}, ...]
for row in rows:
    parts = my_tag_store.lookup(row["workload_tag"])
    my_db.upsert_ee_bucket(**row, **parts)

Cost model: cost_per_eecu_hour × eecu_hours. Google’s public commercial rate is $0.40/EECU-hour; non-commercial projects bill at 0. The monitor is agnostic — pass whatever your billing agreement says.

Classes

EEUsageMonitor(project[, ...])

Cloud Monitoring poller for EE workload consumption.