autometrics
Easily add metrics to your code that actually help you spot and debug issues in production. Built on Prometheus and OpenTelemetry.
3.0.0
4.2M downloads/mo
#4928 most downloaded on crates.io
autometrics-dev/autometrics-rs
What this package is like to depend on
Last release 11 months ago
18 Sep 2025
Ships unpredictably
gaps range from 8 days to 1.2 years
Most releases are documented
notes for 15 of 18 stable releases
1 version withdrawn
withdrawn after publishing
4 years old
19 releases · first in 2023
1 release in the last 12 months
see the full history below
Release timeline
19 releases · Jan 2023 to Sep 2025Releases
latest 19-
3.0.018 Sep 2025Release notes
Open source →What's Changed
- update grpc-http example to autometrics 2.0 by @mellowagain in #182
- Update metrics to 0.24 by @miniduikboot in #183
- fix metrics 0.24 by @mellowagain in #188
- Update prometheus to 0.14 by @killzoner in #187
- Update deps for prometheus by @killzoner in #189
- bump version to v3.0.0 by @mellowagain in #190
New Contributors
- @miniduikboot made their first contribution in #183
- @killzoner made their first contribution in #187
Full Changelog: v2.0.0...v3.0.0
Release notes
Open source →Breaking changes
metricshas been updated to v0.24 (#183) New feature flag:metrics-0_24Removed feature flag:metrics-0_21prometheushas been updated to v0.14 (#187) New feature flag:prometheus-0_14Removed feature flag:prometheus-0_13- No more
prometheus-exporterwithopentelemetry, use standard otlp exporter (see https://github.com/open-telemetry/opentelemetry-rust/pull/2831) - Update
opentelemetryto v0.30
-
2.0.025 Jul 2024Release notes
Open source →What's Changed
- update to opentelemetry 0.24 by @mellowagain in #179
- bump version to v2.0.0 by @mellowagain in #180
Full Changelog: v1.0.1...v2.0.0
Release notes
Open source →Breaking changes
opentelemetryhas been updated to v0.24 (#179)
New feature flags:opentelemetry-0_24,exemplars-tracing-opentelemetry-0_25
Removed feature flags:opentelemetry-0_21,exemplars-tracing-opentelemetry-0_22
If you are using these metrics library separately in your application in addition to Autometrics, ensure that you match the version that Autometrics uses.
-
1.0.112 Feb 2024Release notes
Open source →What's Changed
- Added gRPC telemetry instrumentation example. by @marvin-hansen in #163
- update to http 1.0 and axum 0.7 by @mellowagain in #167
- add default values for
timeoutandperiodin otel push exporter by @mellowagain in #168 - Report error locus within instrumented code by @gagbo in #170
- Fix: #139 by @Archisman-Mridha in #171
- add missing feature flag for otlp push exporter by @mellowagain in #172
- bump version to v1.0.1 by @mellowagain in #173
New Contributors
- @marvin-hansen made their first contribution in #163
- @Archisman-Mridha made their first contribution in #171
Full Changelog: v1.0.0...v1.0.1
Release notes
Open source →- Update
httpto1.0. This fixes compatibility withaxum 0.7(#167) - Explicitly set default timeout and period for the OTEL push exporter (#168)
- Fix a regression that made all compilation errors in instrumented code appear as located in
the
#[autometrics]annotation instead of the original location (#170) - Add missing feature flag for otel-push-exporter (#172)
-
1.0.001 Dec 2023Release notes
Open source →What's Changed
- add otel push exporter by @mellowagain in #137
- Fix a minor typo by @paultag in #138
- feat: support for 'tracing-opentelemetry:0.21' by @woshilapin in #147
- Update to syn v2 by @aumetra in #145
- add better error message when using
async-traitby @mellowagain in #149 - update changelog for #149 by @mellowagain in #150
- Add changelog message for PR #147 by @hatchan in #148
- add missing feature flag to opentelemetry_otlp for otel-push-exporter-http by @mellowagain in #151
- [autometrics 1.0 compliance] add repo url and provider by @mellowagain in #152
- [autometrics 1.0 compliance] add
autometrics.versiontobuild_infoby @mellowagain in #154 - [autometrics 1.0 compliance] allow setting repo url and provider at runtime by @mellowagain in #156
- update opentelemetry to 0.21 without backwards compatibility by @mellowagain in #159
- add full support for
async-traitby @mellowagain in #161 - fix
#[async_trait]attribute not being correctly detected when its re-exported from another crate by @mellowagain in #164 - bump version to v1.0.0 by @mellowagain in #165
New Contributors
- @paultag made their first contribution in #138
- @woshilapin made their first contribution in #147
- @hatchan made their first contribution in #148
Full Changelog: v0.6.0...v1.0.0
Release notes
Open source →Breaking changes
opentelemetryhas been updated to v0.21 (#159)
New feature flags:opentelemetry-0_21,exemplars-tracing-opentelemetry-0_22
Removed feature flags:opentelemetry-0_20,exemplars-tracing-opentelemetry-0_20,exemplars-tracing-opentelemetry-0_21prometheus-clienthas been updated to v0.22 (#160)
New feature flag:prometheus-client-0_22
Removed feature flag:prometheus-client-0_21
If you are using these metrics separately in your application in addition to Autometrics, ensure that you match the version that Autometrics uses.
General changes
- New exporter,
otel_push_exporteris now available in addition to the existingprometheus_exporter. It can be used to push metrics in the OTEL format via HTTP or gRPC to a OTEL-collector-(compatible) server. - Update to
synv2 (#145) - Add support for tracing-opentelemetry v0.21 (#147)
- Error messages when using
#[autometrics]together with#[async_trait]has been improved (#149) - Fixed missing feature flag for
opentelemetry-otlpwhen autometrics featureotel-push-exporteris enabled - Fixed incorrect duration being recorded when using
#[async_trait]together with#[autometrics](#161)
Please note that the#[autometrics]macro needs to be defined BEFORE#[async_trait]. - Fixed value of the
resultlabel being empty when the function is annotated with#[async_trait](#161) - Fixed
#[async_trait]not being correctly detected if its re-exported in another crate (#164)
Autometrics 1.0 compliance
The Autometrics specification v1.0.0 has been released. The following changes are made in order to bring the release in compliance with the spec:
- Added
repository.urlandrepository.providerasbuild_infolabels. They can be configured either through environment variables or automatically based on yourCargo.tomlpackage.repositoryvalue (only GitHub, GitLab and BitBucket) (#152) - Added
autometrics.versionasbuild_infolabel, specifying the autometrics spec version that we are targeting. It is currently hardcoded to1.0.0(#154) - Environment variables for
repository.urlandrepository.providerwill now be read at both compile time and runtime (#156)
-
0.6.008 Aug 2023Release notes
Open source →What's Changed
- Use #[cfg(feature = ...)] directly for public features by @emschwartz in #109
- Minor doc tweaks by @emschwartz in #110
- Add benchmark by @emschwartz in #111
- Split out advanced features from benefits section by @emschwartz in #112
- OTLP push controller example by @egtwp in #113
- Add the
service.namelabel to all metrics by @emschwartz in #116 - Rename metrics to be in line with OpenTelemetry/OpenMetrics specs by @emschwartz in #118
- Initialize counters to zero in debug builds by @emschwartz in #119
- add
actix-webexample by @mellowagain in #120 - fix compile error on generic
impltraits within types by @mellowagain in #122 - Add references to the Autometrics CLI in the README by @keturiosakys in #124
- Include the struct name in the function name by @emschwartz in #126
- Replace caller label with caller.function and caller.module by @emschwartz in #127
- Remove deprecated global functions by @emschwartz in #128
- Include crate version in backend feature flags by @emschwartz in #129
- Support customizing global Autometrics settings by @emschwartz in #130
- Fix OpenTelemetry tests by @emschwartz in #133
- Make the metrics registry configurable by @emschwartz in #134
- Fix typo in latency alert error query by @gagbo in #132
- Upgrade to opentelemetry 0.20 by @emschwartz in #135
- Reorganize docs.rs main page by @emschwartz in #136
New Contributors
- @egtwp made their first contribution in #113
- @mellowagain made their first contribution in #120
- @keturiosakys made their first contribution in #124
Full Changelog: v0.5.0...v0.6.0
Release notes
Open source →Added
- Autometrics settings can now be configured via
settings::AutometricsSettings::builder() - A custom
Registrycan be used to collect metrics. This may be used to add custom metrics alongside those produced by Autometrics, as well as to export the metrics without using the providedprometheus_exporter - All metrics now have a
service.namelabel attached. This is set via the settings, via runtime environment variable (AUTOMETRICS_SERVICE_NAMEorOTEL_SERVICE_NAME), or it falls back to the crate name defined in theCargo.toml - Function counters are initialized to zero in debug builds. This exposes details of instrumented functions to Prometheus and visualization tools built on top of it, before the functions have been called.
- Basic benchmarking
Changed
- Renamed the
function.calls.countmetric tofunction.calls(which is exported to Prometheus asfunction_calls_total) to be in line with OpenTelemetry and OpenMetrics naming conventions. Dashboards and alerting rules must be updated. - When the
function.calls.durationhistogram is exported to Prometheus, it now includes the units (function_calls_duration_seconds) to be in line with Prometheus/OpenMetrics naming conventions. Dashboards and alerting rules must be updated. - Struct methods now have the struct name as part of the
functionlabel on the metrics (for example,MyStruct::my_method) - The
callerlabel on thefunction.callsmetric was replaced withcaller.functionandcaller.module - The
custom-objective-latencyfeature can now be used with theprometheus-exporter, as well as with theprometheusandprometheus-clientcrates, because the histogram buckets can now be configured via the settings - Upgraded
opentelemetryto v0.20
Deprecated
metricsfeature flag (replaced withmetrics-0_21)opentelemetryfeature flag (replaced withopentelemetry-0_20)prometheusfeature flag (replaced withprometheus-0_13)prometheus-clientfeature flag (replaced withprometheus-client-0_21)exemplars-tracing-opentelemetryfeature flag (replaced withexemplars-tracing-opentelemetry-0_20)
Removed
encode_global_metricswas removed and replaced byprometheus_exporter::encode_to_stringglobal_metrics_exporterwas removed and replaced byprometheus_exporter::initbackends::prometheus_client::REGISTRYwas removed. TheRegistryused with theprometheus-clientbackend can now be accessed viaAutometricsSettings::prometheus_client_registry
Fixed
- Return types on functions annotated with
#[autometrics]containing genericimpltypes in their type arguments (fn() -> Result<impl ToString, impl std::error::Error>) no longer fail to compile.
-
0.5.002 Jun 2023Release notes
Open source →What's Changed
- Add changelog by @emschwartz in #83
- Clarify that autometrics isn't tied to axum or vergen by @emschwartz in #84
- Allow specifying result labels for enum variants by @gagbo in #61
- Fix links in readme on crates.io by @emschwartz in #86
- Link to docs for generated metrics by @emschwartz in #87
- Run clippy by @emschwartz in #96
- Update to opentelemetry 0.19 by @emschwartz in #93
- Add support for the
prometheus-clientcrate by @emschwartz in #88 - Remove opentelemetry as the default metrics library by @emschwartz in #97
- Add exemplar support by @emschwartz in #100
- Disable doc generation when AUTOMETRICS_DISABLE_DOCS env var is present by @emschwartz in #104
- Fix generated queries to work with _total suffix by @emschwartz in #103
- Move
prometheus_exporterfunctions to dedicated module by @emschwartz in #102 - Support OpenTelemetry span context for exemplars by @emschwartz in #105
- Use prometheus-client by default with prometheus-exporter by @emschwartz in #107
- Simplify + split out readmes by @emschwartz in #108
Full Changelog: v0.4.1...v0.5.0
Release notes
Open source →Added
- Support the official
prometheus-clientcrate for producing metrics - Support exemplars when using the feature flags
exemplars-tracingorexemplars-tracing-opentelemetry. Autometrics can now extract fields from the current span and attach them as exemplars on the counter and histogram metrics ResultLabelsderive macro allows to specify on an enum whether variants should always be "ok", or "error" for the success rate metrics of functions using them. (#61)- The
prometheus_exportermodule contains all functions related to theprometheus-exporterfeature prometheus_exporter::encode_http_responsefunction returns anhttp::Responsewith the metrics. This is especially recommended when using exemplars, because it automatically uses the OpenMetricsContent-Typeheader, which is required for Prometheus to scrape metrics with exemplarsAUTOMETRICS_DISABLE_DOCSenvironment variable can be set to disable doc comment generation (this is mainly for use with editor extensions that generate doc comments themselves)
Changed
- Users must configure the metrics library they want to use autometrics with, unless the
prometheus-exporterfeature is enabled. In that case, the officialprometheus-clientwill be used - Metrics library feature flags are now mutually exclusive (previously,
autometricswould only produce metrics using a single metrics library if multiple feature flags were enabled, using a prioritization order defined internally) GetLabelstrait (publicly exported but meant for internal use) changed the signature of its function to accomodate the newResultLabelsmacro. This change is not significant if you never importedautometrics::__privatemanually (#61)- When using the
opentelemetrytogether with theprometheus-exporter, it will no longer use the default registry provided by theprometheuscrate. It will instead use a new registry - Updated
opentelemetrydependencies to v0.19. This means that users using autometrics withopentelemetrybut not using theprometheus-exportermust update theopentelemetryto use v0.19.
Deprecated
global_metrics_exporterandencode_global_metricshave been deprecated and replaced byprometheus_exporter::initandprometheus_exporter::encode_to_string, respectively
Removed
opentelemetryis no longer used by defaultGetLabelsForResulttrait (publicly exported but meant for internal use) was removed to accomodate the newResultLabelsmacro. This change is not significant if you never importedautometrics::__privatemanually (#61)
Fixed
#[autometrics]now works on functions that use type inference in their return statement (#74, #61)
-
0.4.105 May 2023Release notes
Open source →What's Changed
- Use vergen with git CLI in example by @emschwartz in #78
- Add percentile_latency label to latency query by @emschwartz in #79
- Overhaul docs + add quickstart by @emschwartz in #82
Full Changelog: v0.4.0...v0.4.1
Release notes
Open source →Changed
- Overhaul documentation
Fixed
- Generated latency query needs additional labels to show lines for 95th and 99th percentiles
-
0.4.026 Apr 2023Release notes
Open source →What's Changed
- Handle when counter has _total suffix by @emschwartz in #64
- Bump metrics-exporter-prometheus from 0.11 to 0.12 by @adamchalmers in #67
- Bump
metricsversion from 0.20 to 0.21 by @aumetra in #68 - Add build_info metric & use it in generated queries by @emschwartz in #69
- Add branch label to build_info metric by @emschwartz in #72
- Fix error rate query order of operations by @emschwartz in #73
- Fix regex syntax when generating queries using optional _total by @emschwartz in #75
- Once's should be static, not const by @emschwartz in #76
- Use last_over_time to fix build info query by @emschwartz in #77
New Contributors
- @adamchalmers made their first contribution in #67
- @aumetra made their first contribution in #68
Full Changelog: v0.3.3...v0.4.0
Release notes
Open source →Added
build_infometric tracks software version and commit- Queries now use
build_infometric to correlate version info with problems
Fixed
- Prometheus rules handle when the counter metric name has a
_totalsuffix
-
0.3.314 Apr 2023Release notes
Open source →What's Changed
- Fix latency SLO total query by @emschwartz in #54
- Minor doc tweaks by @emschwartz in #55
- Fix error in latency query by @gagbo in #56
- Add minimum traffic threshold to alerts by @gagbo in #58
- Add tests by @emschwartz in #60
- Move alerting rules to autometrics-shared by @emschwartz in #62
- Explain that the recording rules need to be configured in prometheus by @brettimus in #63
- More detailed top-line description by @emschwartz in #65
New Contributors
- @gagbo made their first contribution in #56
- @brettimus made their first contribution in #63
Full Changelog: v0.3.2...v0.3.3
Release notes
Open source →Added
- Alerts have minimum traffic threshold of 1 request / minute
Fixed
- Latency SLO total query in alerting rules
-
0.3.222 Mar 2023 -
0.3.121 Mar 2023Release notes
Open source →Added
custom-objective-latencyandcustom-objective-percentilefeature flags
Changed
- Use the OpenTelemetry default histogram buckets
Removed
- Remove the latency objective values for 150, 200, and 350 milliseconds
custom-objectivesfeature flag
-
0.3.014 Mar 2023 withdrawnRelease notes
Open source →Added
- Support defining Service-Level Objectives (SLOs) in code
- CLI to generate Sloth file, which is then used to generate Prometheus alerting rules
#[skip_autometrics]annotation when applying autometrics to animplblockok_ifanderror_ifautometrics parameters
-
0.2.408 Feb 2023 -
0.2.331 Jan 2023 -
0.2.231 Jan 2023Nothing published for this version
-
0.2.131 Jan 2023Nothing published for this version
-
0.2.031 Jan 2023Release notes
Open source →Added
- Support
opentelemetryandmetricscrates for tracking metrics - Support applying autometrics to an
implblock
Changed
- Tracking function concurrency is optional
- Support
-
0.1.127 Jan 2023Release notes
Open source →Added
- Track concurrent requests
- Add return types as labels
- Separate function call counter
callerlabel
Changed
- Use OpenTelemetry metric naming conventions
-
0.1.027 Jan 2023Nothing published for this version