https://github.com/awslabs/metrique

https://github.com/awslabs/metrique

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: awslabs
  • License: apache-2.0
  • Language: Rust
  • Default Branch: main
  • Size: 658 KB
Statistics
  • Stars: 9
  • Watchers: 1
  • Forks: 5
  • Open Issues: 12
  • Releases: 38
Created 12 months ago · Last pushed 10 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Security Notice

README.md

Metrique

A set of crates for collecting and exporting metrics, especially unit-of-work metrics.

This currently supports exporting metrics in Amazon EMF format to CloudWatch. More formats might be supported in future versions.

Getting Started

Most applications and libraries will use metrique directly and configure a writer with metrique-writer. See the examples for several examples of different common patterns.

Applications will define a metrics struct that they annotate with #[metrics]: ```rust use metrique::unitofwork::metrics;

[metrics(value(string))]

enum Operation { CountDucks, }

[metrics]

struct RequestMetrics { operation: Operation, /* you can use operation: &'static str if you prefer */ #[metrics(timestamp)] timestamp: Timestamp, numberofducks: usize, #[metrics(unit = Millisecond)] operation_time: Timer, } ```

On its own, this is just a normal struct, there is no magic. To use it as a metric, you can call .append_on_drop: rust impl RequestMetrics { // It is generally a good practice to expose a single initializer that sets up // append on drop. fn init(operation: Operation) -> RequestMetricsGuard { RequestMetrics { timestamp: Timestamp::now(), operation, number_of_ducks: 0, operation_time: Timer::start_now(), }.append_on_drop(ServiceMetrics::sink()) } }

The guard object can still be mutated via DerefMut impl: rust async fn count_ducks() { let mut metrics = RequestMetrics::init(Operation::CountDucks); metrics.number_of_ducks = 5; // metrics flushes as scope drops // timer records the total time until scope exits }

But when it drops, it will be appended to the queue to be formatted and flushed.

To control how it is written, when you start your application, you must configure a queue: ```rust pub use metrique::ServiceMetrics;

fn initializemetrics(servicelogdir: PathBuf) -> AttachHandle { ServiceMetrics::attachtostream( Emf::builder("Ns".tostring(), vec![vec![]]) .build() .outputtomakewriter(RollingFileAppender::new( Rotation::MINUTELY, &servicelogdir, "service_log.log", )), ) } ```

See metrique-writer for more information about queues and destinations.

You can either attach it to a global destination or thread the queue to the location you construct your metrics object directly. Currently, only formatters for Amazon EMF are provided, but more may be added in the future.

Glossary

  • dimension: The keys for metrics are generally of the form (name, dimensions). Metric backends have ways of aggregating metrics according to some sets of dimensions.

For example, a metric named RequestCount can be emitted with dimensions [(Status, <http status>), (Operation, <operation>)]. Then, the metric backend could allow for counting the requests with status 500 for operation Frobnicate. - entry io stream: An object that implements EntryIoStream - should be wrapped into an EntrySink before use - see the EntryIoStream docs for more details. - entry sink: An object that implements EntrySink, that normally writes entries as metric records to some entry destination outside the program. Normally a BackgroundQueue or a FlushImmediately. - guard: a Rust object that performs some action on drop. In a metrique context, normally an AppendAndCloseOnDrop that emits a metric entry when dropped. - metric: A metric is a (name, dimensions) key that can have values associated with it. Generally, a metric contains metric datapoints. - metric backend: The backend being used to aggregate metrics. metrique currently comes with support for the Amazon EMF backend, but support can be added to other backends. - metric datapoint: A single point of (name, dimensions, multiplicity, time, value), generally nor represented explicitly but rather being emitted from fields in a metric entry. Metric datapoints have a value that is an integer or floating point, and can come with some sort of multiplicity. - metric entry: something that implements Entry. Will create a metric record (e.g., an EMF JSON entry) when emitted. - metric record: the data recorded created from emitting a metric entry and sent to the metric backend. Will create metric datapoints for the included metrics - multiplicity: Is a property of a metric value, that allows it to count as a large number of datapoints with O(1) emission complexity. metrique allows users to emit metric datapoint with multiplicity. - property: In addition to metric datapoints, metric entries can also contain string-valued properties, that are normally not automatically aggregated directly by the metric backend, but can be used as keys for aggregations - for example, it is sometimes useful to include the host machine and software version as properties. - slot: A Slot, which can be used in metrique to write to a part of a metric entry from a different task or thread. A Slot can also hold a reference to a FlushGuard that can delay metric entry emission until the Slot is finalized.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

Owner

  • Name: Amazon Web Services - Labs
  • Login: awslabs
  • Kind: organization
  • Location: Seattle, WA

AWS Labs

GitHub Events

Total
  • Create event: 33
  • Release event: 15
  • Issues event: 20
  • Watch event: 3
  • Delete event: 4
  • Issue comment event: 14
  • Push event: 43
  • Pull request review comment event: 46
  • Pull request event: 60
  • Pull request review event: 75
  • Fork event: 2
Last Year
  • Create event: 33
  • Release event: 15
  • Issues event: 20
  • Watch event: 3
  • Delete event: 4
  • Issue comment event: 14
  • Push event: 43
  • Pull request review comment event: 46
  • Pull request event: 60
  • Pull request review event: 75
  • Fork event: 2

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 13
  • Total pull requests: 37
  • Average time to close issues: 6 days
  • Average time to close pull requests: about 20 hours
  • Total issue authors: 4
  • Total pull request authors: 5
  • Average comments per issue: 0.15
  • Average comments per pull request: 0.19
  • Merged pull requests: 21
  • Bot issues: 0
  • Bot pull requests: 3
Past Year
  • Issues: 13
  • Pull requests: 37
  • Average time to close issues: 6 days
  • Average time to close pull requests: about 20 hours
  • Issue authors: 4
  • Pull request authors: 5
  • Average comments per issue: 0.15
  • Average comments per pull request: 0.19
  • Merged pull requests: 21
  • Bot issues: 0
  • Bot pull requests: 3
Top Authors
Issue Authors
  • rcoh (8)
  • jlizen (3)
  • slack2450 (1)
  • arielb1 (1)
Pull Request Authors
  • arielb1 (23)
  • rcoh (9)
  • dependabot[bot] (3)
  • jlizen (1)
  • weihanglo (1)
Top Labels
Issue Labels
Pull Request Labels
dependencies (3) rust (3)

Packages

  • Total packages: 10
  • Total downloads:
    • cargo 12,302 total
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 50
  • Total maintainers: 1
crates.io: metrique-service-metrics

Library for working with unit of work metrics - writer-side interface

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 880 Total
Rankings
Dependent repos count: 20.5%
Forks count: 26.1%
Dependent packages count: 27.1%
Stargazers count: 30.1%
Average: 39.7%
Downloads: 94.6%
Maintainers (1)
Last synced: 10 months ago
crates.io: metrique-metricsrs

Library for working with unit of work metrics - metrics.rs collector

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 613 Total
Rankings
Dependent repos count: 20.4%
Dependent packages count: 27.0%
Average: 47.3%
Downloads: 94.6%
Maintainers (1)
Last synced: 10 months ago
crates.io: metrique-writer-format-emf

Library for working with unit of work metrics - Amazon CloudWatch Embedded Metric Format (EMF) formatter

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,394 Total
Rankings
Dependent repos count: 20.8%
Dependent packages count: 27.6%
Average: 47.7%
Downloads: 94.6%
Maintainers (1)
Last synced: 10 months ago
crates.io: metrique-writer

Library for working with unit of work metrics - writer-side interface

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,715 Total
Rankings
Dependent repos count: 20.8%
Dependent packages count: 27.6%
Average: 47.7%
Downloads: 94.6%
Maintainers (1)
Last synced: 10 months ago
crates.io: metrique-writer-macro

Library for working with unit of work metrics - derive(Entry) macro

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,086 Total
Rankings
Dependent repos count: 20.8%
Dependent packages count: 27.6%
Average: 47.7%
Downloads: 94.6%
Maintainers (1)
Last synced: 10 months ago
crates.io: metrique-core

Library for working with unit of work metrics - core traits

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,466 Total
Rankings
Dependent repos count: 20.8%
Dependent packages count: 27.6%
Average: 47.7%
Downloads: 94.6%
Maintainers (1)
Last synced: 10 months ago
crates.io: metrique-timesource

Utilities for mocking Instant and SystemTime (part of metrique)

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,094 Total
Rankings
Dependent repos count: 20.8%
Dependent packages count: 27.6%
Average: 47.7%
Downloads: 94.6%
Maintainers (1)
Last synced: 10 months ago
crates.io: metrique

Library for generating unit of work metrics

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,382 Total
Rankings
Dependent repos count: 20.8%
Dependent packages count: 27.6%
Average: 47.7%
Downloads: 94.6%
Maintainers (1)
Last synced: 10 months ago
crates.io: metrique-writer-core

Library for working with unit of work metrics - writer-side interface core traits

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,630 Total
Rankings
Dependent repos count: 20.8%
Dependent packages count: 27.6%
Average: 47.7%
Downloads: 94.6%
Maintainers (1)
Last synced: 10 months ago
crates.io: metrique-macro

Library for working with unit of work metrics - #[metrics] macro

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,042 Total
Rankings
Dependent repos count: 20.8%
Dependent packages count: 27.6%
Average: 47.7%
Downloads: 94.6%
Maintainers (1)
Last synced: 10 months ago

Dependencies

.github/actions/rust-build/action.yml actions
  • Swatinem/rust-cache v2 composite
  • dtolnay/rust-toolchain master composite
.github/workflows/audit.yml actions
  • actions/checkout v4 composite
  • rustsec/audit-check v2.0.0 composite
.github/workflows/build.yml actions
  • ./.github/actions/rust-build * composite
  • actions/checkout v4 composite
.github/workflows/format.yml actions
  • Swatinem/rust-cache v2 composite
  • actions/checkout v4 composite
  • dtolnay/rust-toolchain nightly composite
  • dtolnay/rust-toolchain stable composite
.github/workflows/release.yml actions
  • actions/checkout v4 composite
  • dtolnay/rust-toolchain stable composite
  • release-plz/action v0.5.102 composite
  • rust-lang/crates-io-auth-action v1 composite
Cargo.lock cargo
  • 188 dependencies
Cargo.toml cargo
metrique/Cargo.toml cargo
  • metrique-timesource 0.1.0 development
  • metrique-core 0.1.0
  • metrique-macro 0.1.0
  • metrique-timesource 0.1.0
  • metrique-writer-core 0.1.0
metrique-core/Cargo.toml cargo
  • metrique-writer-core 0.1.0
metrique-macro/Cargo.toml cargo
metrique-timesource/Cargo.toml cargo
metrique-writer/Cargo.toml cargo
  • metrique-writer-core 0.1.0
  • metrique-writer-macro 0.1.0
metrique-writer-core/Cargo.toml cargo
metrique-writer-format-emf/Cargo.toml cargo
  • metrique-writer 0.1.0
  • metrique-writer-core 0.1.0
metrique-writer-macro/Cargo.toml cargo