ContractSpec docs

OSS-first docs

These docs teach the open system first: contracts, generated surfaces, runtimes, governance, and incremental adoption. Studio shows up as the operating layer on top, not as the source of truth.

metrics

Usage metering, metric definitions, and threshold alerting

  • Type: feature
  • Version: 1.0.0
  • Stability: stable
  • Owners: @platform.metering
  • Tags: metering, usage, billing, thresholds
  • File: packages/libs/metering/src/metering.feature.ts
  • field.key.label
    metrics
    field.version.label
    1.0.0
    field.type.label
    feature
    field.title.label
    metrics
    field.description.label

    Usage metering, metric definitions, and threshold alerting

  • Type: feature
  • Version: 1.0.0
  • Stability: stable
  • Owners: @platform.metering
  • Tags: metering, usage, billing, thresholds
  • File: packages/libs/metering/src/metering.feature.ts
  • field.tags.label
    metering,usage,billing,thresholds
    field.owners.label
    @platform.metering
    field.stability.label
    stable

    Usage metering, metric definitions, and threshold alerting

    Operations (13)

    `metric.define` (v1.0.0)

    `metric.update` (v1.0.0)

    `metric.delete` (v1.0.0)

    `metric.get` (v1.0.0)

    `metric.list` (v1.0.0)

    `usage.record` (v1.0.0)

    `usage.recordBatch` (v1.0.0)

    `usage.get` (v1.0.0)

    `usage.getSummary` (v1.0.0)

    `threshold.create` (v1.0.0)

    `threshold.update` (v1.0.0)

    `threshold.delete` (v1.0.0)

    `threshold.list` (v1.0.0)

    Events (9)

    `metric.defined` (v1.0.0)

    `metric.updated` (v1.0.0)

    `usage.recorded` (v1.0.0)

    `usage.batch_recorded` (v1.0.0)

    `usage.aggregated` (v1.0.0)

    `threshold.created` (v1.0.0)

    `threshold.exceeded` (v1.0.0)

    `threshold.approaching` (v1.0.0)

    `model.selected` (v1.0.0)

    Source Definition

    /**
     * Metering Feature Module Specification
     *
     * Defines the feature module for usage metering and threshold management.
     */
    import { defineFeature } from '@lssm-tech/lib.contracts-spec';
    
    /**
     * Metering feature module that bundles usage tracking,
     * metrics definitions, and billing capabilities.
     */
    export const MeteringFeature = defineFeature({
    	meta: {
    		key: 'metrics',
    		version: '1.0.0',
    		title: 'Usage Metering',
    		description: 'Usage metering, metric definitions, and threshold alerting',
    		domain: 'platform',
    		owners: ['@platform.metering'],
    		tags: ['metering', 'usage', 'billing', 'thresholds'],
    		stability: 'stable',
    	},
    
    	// All contract operations included in this feature
    	operations: [
    		// Metric operations
    		{ key: 'metric.define', version: '1.0.0' },
    		{ key: 'metric.update', version: '1.0.0' },
    		{ key: 'metric.delete', version: '1.0.0' },
    		{ key: 'metric.get', version: '1.0.0' },
    		{ key: 'metric.list', version: '1.0.0' },
    
    		// Usage operations
    		{ key: 'usage.record', version: '1.0.0' },
    		{ key: 'usage.recordBatch', version: '1.0.0' },
    		{ key: 'usage.get', version: '1.0.0' },
    		{ key: 'usage.getSummary', version: '1.0.0' },
    
    		// Threshold operations
    		{ key: 'threshold.create', version: '1.0.0' },
    		{ key: 'threshold.update', version: '1.0.0' },
    		{ key: 'threshold.delete', version: '1.0.0' },
    		{ key: 'threshold.list', version: '1.0.0' },
    	],
    
    	// Events emitted by this feature
    	events: [
    		// Metric events
    		{ key: 'metric.defined', version: '1.0.0' },
    		{ key: 'metric.updated', version: '1.0.0' },
    
    		// Usage events
    		{ key: 'usage.recorded', version: '1.0.0' },
    		{ key: 'usage.batch_recorded', version: '1.0.0' },
    		{ key: 'usage.aggregated', version: '1.0.0' },
    
    		// Threshold events
    		{ key: 'threshold.created', version: '1.0.0' },
    		{ key: 'threshold.exceeded', version: '1.0.0' },
    		{ key: 'threshold.approaching', version: '1.0.0' },
    		{ key: 'model.selected', version: '1.0.0' },
    	],
    
    	// No presentations for this library feature
    	presentations: [],
    	opToPresentation: [],
    	presentationsTargets: [],
    
    	// Capability definitions
    	capabilities: {
    		provides: [
    			{ key: 'metering', version: '1.0.0' },
    			{ key: 'thresholds', version: '1.0.0' },
    		],
    		requires: [],
    	},
    });