metering

package module
v0.0.0-...-c0cc05e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MeterAction_name = map[int32]string{
		0: "METER_ACTION_UNSPECIFIED",
		1: "METER_ACTION_RESERVE",
		2: "METER_ACTION_RELEASE",
		3: "METER_ACTION_UPDATE",
		4: "METER_ACTION_USAGE",
	}
	MeterAction_value = map[string]int32{
		"METER_ACTION_UNSPECIFIED": 0,
		"METER_ACTION_RESERVE":     1,
		"METER_ACTION_RELEASE":     2,
		"METER_ACTION_UPDATE":      3,
		"METER_ACTION_USAGE":       4,
	}
)

Enum value maps for MeterAction.

View Source
var File_metering_v1_identity_proto protoreflect.FileDescriptor
View Source
var File_metering_v1_meter_record_proto protoreflect.FileDescriptor
View Source
var File_metering_v1_snapshot_proto protoreflect.FileDescriptor
View Source
var File_metering_v1_utilization_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type DonIdentity

type DonIdentity struct {

	// The authoritative DON ID of the emitting service. For capability LOOPs this
	// is CapDONID supplied over the standardcapabilities interface; for
	// workflow-DON services (e.g. the syncer) it is the workflow DON ID.
	DonId string `protobuf:"bytes,1,opt,name=don_id,json=donId,proto3" json:"don_id,omitempty"`
	// The node's logical name (e.g. "clp-cre-wf-zone-a-1"), not the CSA public
	// key. Events will include csa key, handled by ChIP rotating signer. In the long
	// term, the ResourceIdentity + DonIdentity should be unambiguous to aggregate.
	NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
	// contains filtered or unexported fields
}

DonIdentity captures DON-only identity dimensions together so consumers can branch on message presence, not individual field permutations.

func (*DonIdentity) Descriptor deprecated

func (*DonIdentity) Descriptor() ([]byte, []int)

Deprecated: Use DonIdentity.ProtoReflect.Descriptor instead.

func (*DonIdentity) GetDonId

func (x *DonIdentity) GetDonId() string

func (*DonIdentity) GetNodeId

func (x *DonIdentity) GetNodeId() string

func (*DonIdentity) ProtoMessage

func (*DonIdentity) ProtoMessage()

func (*DonIdentity) ProtoReflect

func (x *DonIdentity) ProtoReflect() protoreflect.Message

func (*DonIdentity) Reset

func (x *DonIdentity) Reset()

func (*DonIdentity) String

func (x *DonIdentity) String() string

type MeterAction

type MeterAction int32

MeterAction identifies the billing semantics of a MeterRecord. Producers emit only METER_ACTION_UPDATE and METER_ACTION_USAGE; the action value is the durable-vs-one-off discriminator.

const (
	// Unknown / unset.
	MeterAction_METER_ACTION_UNSPECIFIED MeterAction = 0
	// Deprecated: retained for wire compatibility; producers must not emit.
	// Historical pairing semantics are void.
	MeterAction_METER_ACTION_RESERVE MeterAction = 1
	// Deprecated: retained for wire compatibility; producers must not emit.
	// Historical pairing semantics are void.
	MeterAction_METER_ACTION_RELEASE MeterAction = 2
	// A signed delta to a durable resource's level; the only action emitted for
	// durable resources. Value semantics are defined on Utilization.value.
	MeterAction_METER_ACTION_UPDATE MeterAction = 3
	// A one-off instantaneous consumption billed per occurrence; never
	// snapshotted.
	MeterAction_METER_ACTION_USAGE MeterAction = 4
)

func (MeterAction) Descriptor

func (MeterAction) Enum

func (x MeterAction) Enum() *MeterAction

func (MeterAction) EnumDescriptor deprecated

func (MeterAction) EnumDescriptor() ([]byte, []int)

Deprecated: Use MeterAction.Descriptor instead.

func (MeterAction) Number

func (x MeterAction) Number() protoreflect.EnumNumber

func (MeterAction) String

func (x MeterAction) String() string

func (MeterAction) Type

type MeterRecord

type MeterRecord struct {

	// Time at which the metered request/occurrence happened (a raw edge, not
	// truncated to a bucket boundary).
	Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// Structured identity of the affected resource (deployment/DON/node
	// dimensions + service + resource/resource_type + the physical resource_id).
	Identity *ResourceIdentity `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"`
	// Billing semantics of this record: METER_ACTION_UPDATE (signed level delta)
	// or METER_ACTION_USAGE (one-off consumption).
	Action MeterAction `protobuf:"varint,3,opt,name=action,proto3,enum=metering.v1.MeterAction" json:"action,omitempty"`
	// One or more utilization quantities for this event (e.g. multiple billing
	// units affected by the same request).
	Utilizations []*Utilization `protobuf:"bytes,4,rep,name=utilizations,proto3" json:"utilizations,omitempty"`
	// contains filtered or unexported fields
}

MeterRecord is a durable, first-class billing event. Each record captures one signed delta: the level change of one request for a durable resource (METER_ACTION_UPDATE) or one instantaneous occurrence of consumption (METER_ACTION_USAGE). Records give the consumer precise request-time edges and the audit trail. The periodic absolute level of each active resource — and the only lifecycle-cleanup signal — is carried by MeterSnapshot; the two streams are complementary load-bearing billing data.

Bucket semantics: An org draws down credits in a time bucket if the bucket contains any positive-delta UPDATE record, any USAGE record, or any nonzero snapshot for a resource attributed to that org. A +N and -N cancelling within one bucket still triggers drawdown via the positive delta.

func (*MeterRecord) Descriptor deprecated

func (*MeterRecord) Descriptor() ([]byte, []int)

Deprecated: Use MeterRecord.ProtoReflect.Descriptor instead.

func (*MeterRecord) GetAction

func (x *MeterRecord) GetAction() MeterAction

func (*MeterRecord) GetIdentity

func (x *MeterRecord) GetIdentity() *ResourceIdentity

func (*MeterRecord) GetTimestamp

func (x *MeterRecord) GetTimestamp() *timestamppb.Timestamp

func (*MeterRecord) GetUtilizations

func (x *MeterRecord) GetUtilizations() []*Utilization

func (*MeterRecord) ProtoMessage

func (*MeterRecord) ProtoMessage()

func (*MeterRecord) ProtoReflect

func (x *MeterRecord) ProtoReflect() protoreflect.Message

func (*MeterRecord) Reset

func (x *MeterRecord) Reset()

func (*MeterRecord) String

func (x *MeterRecord) String() string

type MeterSnapshot

type MeterSnapshot struct {

	// Time at which the snapshot was taken (the interval boundary it covers).
	Timestamp *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	// Full identity of the one resource this snapshot covers: the six coarse
	// dimensions (product, environment, zone, don_id, node_id, service) plus
	// resource, resource_type, and resource_id.
	Identity *ResourceIdentity `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"`
	// Utilization of this one resource. value is the current level; the
	// per-interval increment is value over the interval below.
	Utilization []*Utilization `protobuf:"bytes,3,rep,name=utilization,proto3" json:"utilization,omitempty"`
	// Nominal period this snapshot covers, for staleness detection and for
	// computing the per-interval increment by the consumer.
	Interval *durationpb.Duration `protobuf:"bytes,4,opt,name=interval,proto3" json:"interval,omitempty"`
	// contains filtered or unexported fields
}

MeterSnapshot is the ACTION-LESS periodic absolute level of EXACTLY ONE active durable resource, uniquely identified by its ResourceIdentity (including resource_id). It is load-bearing billing data: it provides the level and the only lifecycle-cleanup signal, giving liveness and level reconciliation that bounds drift in the delta-based MeterRecord stream. It is also the magnitude the billing median-across-nodes reducer consumes.

One MeterSnapshot covers one resource; the resource manager emits a separate MeterSnapshot per active resource each interval. There is no batch and no sequence number: each snapshot stands alone, keyed by its ResourceIdentity and timestamp. A resource that stops being snapshotted is released — this absence is the only lifecycle-cleanup mechanism. MeterAction does NOT apply to snapshots.

func (*MeterSnapshot) Descriptor deprecated

func (*MeterSnapshot) Descriptor() ([]byte, []int)

Deprecated: Use MeterSnapshot.ProtoReflect.Descriptor instead.

func (*MeterSnapshot) GetIdentity

func (x *MeterSnapshot) GetIdentity() *ResourceIdentity

func (*MeterSnapshot) GetInterval

func (x *MeterSnapshot) GetInterval() *durationpb.Duration

func (*MeterSnapshot) GetTimestamp

func (x *MeterSnapshot) GetTimestamp() *timestamppb.Timestamp

func (*MeterSnapshot) GetUtilization

func (x *MeterSnapshot) GetUtilization() []*Utilization

func (*MeterSnapshot) ProtoMessage

func (*MeterSnapshot) ProtoMessage()

func (*MeterSnapshot) ProtoReflect

func (x *MeterSnapshot) ProtoReflect() protoreflect.Message

func (*MeterSnapshot) Reset

func (x *MeterSnapshot) Reset()

func (*MeterSnapshot) String

func (x *MeterSnapshot) String() string

type ResourceIdentity

type ResourceIdentity struct {

	// Deployment product, e.g. "cre". One of the deployment+DON+node
	// dimensions used for coarse billing rollup.
	Product string `protobuf:"bytes,1,opt,name=product,proto3" json:"product,omitempty"`
	// Deployment tenant name, e.g. "mainline" or "enterprise". This is the
	// human-readable tenant label (not the numeric tenant ID).
	Tenant string `protobuf:"bytes,2,opt,name=tenant,proto3" json:"tenant,omitempty"`
	// Numeric tenant identifier as used by Accounts/Linking/registry/Vault DON.
	// This is a numbered identifier represented as a string.
	NumericTenantId string `protobuf:"bytes,3,opt,name=numeric_tenant_id,json=numericTenantId,proto3" json:"numeric_tenant_id,omitempty"`
	// Deployment environment, e.g. "production", "staging". A coarse
	// billing-rollup dimension.
	Environment string `protobuf:"bytes,4,opt,name=environment,proto3" json:"environment,omitempty"`
	// Deployment zone, e.g. "wf-zone-a". A coarse billing-rollup dimension.
	Zone string `protobuf:"bytes,5,opt,name=zone,proto3" json:"zone,omitempty"`
	// DON-specific identity dimensions. Present only for DON emitters. Web2 or
	// other non-DON emitters leave this unset instead of sending empty IDs.
	Don *DonIdentity `protobuf:"bytes,6,opt,name=don,proto3,oneof" json:"don,omitempty"`
	// Stable service constant identifying the emitting service (the old
	// `entity`), e.g. "cron-trigger", "http-trigger", "evm-log-trigger",
	// "workflow-syncer-v2". A coarse billing-rollup dimension.
	Service string `protobuf:"bytes,7,opt,name=service,proto3" json:"service,omitempty"`
	// Resource pool the action applies to, e.g. "trigger_registrations",
	// "log_filters", "workflow_storage". Human friendly name
	ResourcePool string `protobuf:"bytes,8,opt,name=resource_pool,json=resourcePool,proto3" json:"resource_pool,omitempty"`
	// optionality to add a level of hierarchy within the resource_pool, or
	// UID a resource_pool
	ResourcePoolId string `protobuf:"bytes,9,opt,name=resource_pool_id,json=resourcePoolId,proto3" json:"resource_pool_id,omitempty"`
	// contains filtered or unexported fields
}

ResourceIdentity is the structured, first-class identity of a durable resource. It is embedded by every metering message (MeterRecord and Snapshot) so downstream aggregators, analytics, and UI can treat each dimension as a discrete column rather than parsing a dotted string or carrying values out-of-band on telemetry.

func (*ResourceIdentity) Descriptor deprecated

func (*ResourceIdentity) Descriptor() ([]byte, []int)

Deprecated: Use ResourceIdentity.ProtoReflect.Descriptor instead.

func (*ResourceIdentity) GetDon

func (x *ResourceIdentity) GetDon() *DonIdentity

func (*ResourceIdentity) GetEnvironment

func (x *ResourceIdentity) GetEnvironment() string

func (*ResourceIdentity) GetNumericTenantId

func (x *ResourceIdentity) GetNumericTenantId() string

func (*ResourceIdentity) GetProduct

func (x *ResourceIdentity) GetProduct() string

func (*ResourceIdentity) GetResourcePool

func (x *ResourceIdentity) GetResourcePool() string

func (*ResourceIdentity) GetResourcePoolId

func (x *ResourceIdentity) GetResourcePoolId() string

func (*ResourceIdentity) GetService

func (x *ResourceIdentity) GetService() string

func (*ResourceIdentity) GetTenant

func (x *ResourceIdentity) GetTenant() string

func (*ResourceIdentity) GetZone

func (x *ResourceIdentity) GetZone() string

func (*ResourceIdentity) ProtoMessage

func (*ResourceIdentity) ProtoMessage()

func (*ResourceIdentity) ProtoReflect

func (x *ResourceIdentity) ProtoReflect() protoreflect.Message

func (*ResourceIdentity) Reset

func (x *ResourceIdentity) Reset()

func (*ResourceIdentity) String

func (x *ResourceIdentity) String() string

type Utilization

type Utilization struct {

	// Signed base-10 integer string ("-3" is valid). For METER_ACTION_UPDATE it is
	// the level delta; for METER_ACTION_USAGE it is the consumed quantity; for
	// MeterSnapshot it is the current absolute level (always >= 0).
	Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	// The type of utilization that value measures.
	// e.g. RESOURCE_TYPE_COMPUTE
	ResourceType string `protobuf:"bytes,2,opt,name=resource_type,json=resourceType,proto3" json:"resource_type,omitempty"`
	// primarily valuable for workflow receipts where you could have workflowID.
	// persistant storage with a pre-allocated slice has a resource_id
	// to identify it.
	ResourceId string `protobuf:"bytes,3,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"`
	// Unique for MeterRecords, generated by the emitting resource manager;
	// the consumer-side dedup key for at-least-once delivery.
	EventId string `protobuf:"bytes,4,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"`
	// Resolved at emission time from the stored workflow owner; may lag an owner
	// org link/unlink by at most the resolver cache TTL.
	OrgId string `protobuf:"bytes,5,opt,name=org_id,json=orgId,proto3" json:"org_id,omitempty"`
	// contains filtered or unexported fields
}

Utilization quantifies one billed unit for a metered action (MeterRecord) or the periodic level of one active resource dimension (MeterSnapshot). The resource itself is identified entirely by the accompanying ResourceIdentity; Utilization carries no identifying metadata of its own.

func (*Utilization) Descriptor deprecated

func (*Utilization) Descriptor() ([]byte, []int)

Deprecated: Use Utilization.ProtoReflect.Descriptor instead.

func (*Utilization) GetEventId

func (x *Utilization) GetEventId() string

func (*Utilization) GetOrgId

func (x *Utilization) GetOrgId() string

func (*Utilization) GetResourceId

func (x *Utilization) GetResourceId() string

func (*Utilization) GetResourceType

func (x *Utilization) GetResourceType() string

func (*Utilization) GetValue

func (x *Utilization) GetValue() string

func (*Utilization) ProtoMessage

func (*Utilization) ProtoMessage()

func (*Utilization) ProtoReflect

func (x *Utilization) ProtoReflect() protoreflect.Message

func (*Utilization) Reset

func (x *Utilization) Reset()

func (*Utilization) String

func (x *Utilization) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL