A comprehensive schema generator for WebRTC observability that creates type-safe language bindings and data structures for monitoring and analyzing WebRTC applications.
- Overview
- Features
- Generated Projects
- Schema Structure
- Development
- Versioning
- Publishing
- Contributing
- License
ObserveRTC Schemas provides a standardized way to describe WebRTC statistics, events, and metrics across different programming languages. The schema generator processes Avro schema definitions and creates type-safe TypeScript bindings, Protocol Buffer schemas, flattened Avro schemas and Markdown documentation.
- π Comprehensive WebRTC Stats Coverage - Complete schema definitions for all WebRTC statistics
- π§ Multiple Output Formats - TypeScript type definitions, Protocol Buffer schemas, flattened Avro and Markdown documentation
- π‘οΈ Type Safety - Provides full type safety across all generated languages
- π Real-time Monitoring - Optimized for real-time WebRTC observability and monitoring
- π Version Controlled - Semantic versioning with clear upgrade paths
- ποΈ Extensible Architecture - Support for custom fields and extensions
The schema generator produces several standalone npm packages and output formats:
| Package | Description | Repository |
|---|---|---|
@observertc/schemas |
Core TypeScript/JavaScript type definitions | ./npm-samples-lib/ |
@observertc/samples-protobuf-codec |
Protobuf delta codec β smallest payload | ./npm-samples-protobuf-codec/ |
@observertc/samples-json-codec |
JSON delta codec β zero dependencies, ~2 KB | ./npm-samples-json-codec/ |
Both codecs implement the same delta: each message carries only what changed since the previous sample. They share their semantics, their error codes and their API shape, so they are interchangeable. Pick protobuf when bytes on the wire are the binding constraint, JSON when the transport already compresses and you would rather have no dependencies and a readable payload.
@observertc/samples-encoder and @observertc/samples-decoder are deprecated
and have been removed from this repository. Their last generated sources are in
git history at cc8c7f8; version 3.3.0 stays installable from npm, and its wire
format is unchanged, so an encoder or decoder already deployed still
interoperates with the codec and the two ends can migrate independently.
Use @observertc/samples-protobuf-codec, which
does both directions in one package.
| Format | Description | Location |
|---|---|---|
| TypeScript | Type definitions for every schema | outputs/typescript/ |
| Protocol Buffers | .proto files for cross-language serialization |
outputs/proto/ |
| Avro | Flattened Avro schemas, with all chunks expanded | outputs/avsc/ |
| Markdown | Field-by-field reference for every schema | schemaList.md |
The schemas are organized into several main sample types:
| Schema | Description |
|---|---|
ClientSample |
End-user client statistics and metrics |
PeerConnectionSample |
WebRTC peer connection statistics |
SfuSample |
Selective Forwarding Unit (SFU) metrics |
TurnSample |
TURN server statistics |
- RTP Statistics - Inbound/outbound RTP stream metrics
- ICE Statistics - ICE candidate and transport information
- Media Statistics - Audio/video codec and quality metrics
- Transport Statistics - Network transport layer information
- Score Fields - Quality scoring with detailed reasoning (
score+scoreReasons) - Extensible Attachments - Custom metadata support via
attachmentsfields - Timestamp Precision - High-resolution timing information
- Comprehensive Coverage - All WebRTC standard statistics
- Node.js 22+
- npm or yarn
git clone https://github.com/observertc/schemas.git
cd schemas
npm installGenerate every output format from the Avro schema definitions:
npm run generateThis will:
- Read and validate the Avro schema files in
sources/samples/ - Write flattened Avro schemas to
outputs/avsc/ - Write TypeScript type definitions to
outputs/typescript/ - Write Protocol Buffer definitions to
outputs/proto/and compile them to TypeScript withbuf - Assemble the three npm packages and bump their versions
- Write the Markdown reference to
schemaList.mdand the schema library README
The generator is a TypeScript CLI; npm run generate -- --help lists every
option and docs/GENERATOR.md documents how it works.
Useful shortcuts:
npm run generate:check # fail if the committed outputs are stale (CI)
npm run generate:dry-run # show what would change, write nothing
npm run generate:types # regenerate only the TypeScript and Avro outputs
npm run schemas:validate # validate schemas and check every field is documented
npm run schemas:list # list the discovered schemas and chunksβββ sources/ # Source Avro schema definitions
β βββ samples/ # Sample schema files (.avsc) and reusable chunks
β βββ w3c/ # W3C stats identifiers, copied into the library
β βββ version.txt # Current schema version
βββ src/ # The generator (TypeScript)
βββ outputs/ # Generated outputs
β βββ typescript/ # Generated type definitions
β βββ proto/ # Protocol Buffer files
β βββ avsc/ # Flattened Avro schemas
βββ npm-samples-lib/ # Generated core TypeScript library
βββ npm-samples-protobuf-codec/ # Protobuf delta codec (encode + decode)
βββ npm-samples-json-codec/ # JSON delta codec (encode + decode)
βββ CHANGELOG.md # Schema change history
βββ docs/GENERATOR.md # How the generator works
- Edit the appropriate
.avscfile insources/samples/ - Add documentation for the new field
- Run
npm run generateto regenerate all outputs - Test the generated code
- Update version numbers as appropriate
Protobuf field numbers are derived from field order. Inserting a field anywhere but the end of its group (repeated, then required, then optional; each sorted by name) renumbers every field after it, which breaks the wire format. Check the diff of
outputs/proto/before merging.
- All fields should have clear documentation
- Use appropriate Avro types (
nullunions for optional fields) - Follow naming conventions (camelCase for field names)
- Add
attachmentsfield for extensibility where appropriate
ObserveRTC Schemas uses Semantic Versioning with the following conventions:
- MAJOR.MINOR.PATCH format
- PATCH - Library bugfixes and improvements
- MINOR - New fields, schema updates (typically matches WebRTC draft date: YYYYMMDD)
- MAJOR - Breaking changes to schema structure
The current version lives in sources/version.txt and is stamped into every
generated artifact. See CHANGELOG.md for the release history.
Based on WebRTC Statistics API specifications and optimized for real-world WebRTC monitoring scenarios.
The three npm packages are released by GitHub Actions using npm trusted
publishing (OIDC) β there is no NPM_TOKEN. Each package needs a Trusted
Publisher registered once on npmjs.com pointing at its workflow file; the exact
settings are in docs/GENERATOR.md.
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes to the schema files in
sources/ - Run the build:
npm run generate - Run
npm run verifyand check the generated outputs - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow existing schema structure and naming conventions
- Add comprehensive documentation for new fields
- Include examples in field descriptions where helpful
- Test generated code in multiple target languages
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
ObserveRTC Schemas - The foundation for standardized WebRTC observability across languages and platforms.