Observability API Reference¶
This page documents Pyvider's built-in metrics for monitoring provider operations, resource lifecycle, and performance.
🤖 AI-Generated Content
This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.
Overview¶
Pyvider provides automatic metrics collection for all provider operations using the provide.foundation.metrics library, wrapped by pyvider.observability. These metrics are exported as counters and histograms that can be integrated with monitoring systems like Prometheus, CloudWatch, or Datadog.
Metrics vs Full Observability
Pyvider currently provides metrics only through the pyvider.observability wrapper module. For structured logging, use structlog or provide.foundation.logging directly in your provider code. Advanced tracing and profiling features may be added later; availability may change or be removed.
Available Metrics¶
All metrics are automatically collected by Pyvider's internal handlers. You don't need to manually instrument your provider code - these metrics are recorded as your resources, data sources, and functions execute.
Resource Lifecycle Metrics¶
Track resource operations and their outcomes:
| Python | |
|---|---|
| Metric Name | Type | Description |
|---|---|---|
pyvider.resource.operations.total |
Counter | Total number of resource operations across all types |
pyvider.resource.create.total |
Counter | Total resource create (apply) operations |
pyvider.resource.read.total |
Counter | Total resource read/refresh operations |
pyvider.resource.update.total |
Counter | Total resource update (apply) operations |
pyvider.resource.delete.total |
Counter | Total resource delete operations |
pyvider.resource.errors.total |
Counter | Total resource operation errors |
Tags: Resource metrics include tags for resource_type (e.g., mycloud_server)
Handler Performance Metrics¶
Monitor the performance of Terraform protocol handlers:
| Python | |
|---|---|
| Metric Name | Type | Description |
|---|---|---|
pyvider.handler.duration.seconds |
Histogram | Handler execution duration in seconds |
pyvider.handler.requests.total |
Counter | Total number of handler requests |
pyvider.handler.errors.total |
Counter | Total number of handler errors |
Tags: Handler metrics include tags for handler_name (e.g., ApplyResourceChange)
Discovery Metrics¶
Track component discovery performance:
| Python | |
|---|---|
| Metric Name | Type | Description |
|---|---|---|
pyvider.discovery.duration.seconds |
Histogram | Component discovery duration in seconds |
pyvider.discovery.components.total |
Counter | Total number of components discovered |
pyvider.discovery.errors.total |
Counter | Total number of discovery errors |
Tags: Discovery metrics include tags for component_type (e.g., resource, data_source)
Schema Metrics¶
Monitor schema generation and caching:
| Python | |
|---|---|
| Metric Name | Type | Description |
|---|---|---|
pyvider.schema.generation.duration.seconds |
Histogram | Schema generation duration in seconds |
pyvider.schema.cache.hits.total |
Counter | Total number of schema cache hits |
Data Source Metrics¶
Track data source operations:
| Python | |
|---|---|
| Metric Name | Type | Description |
|---|---|---|
pyvider.datasource.read.total |
Counter | Total number of data source read operations |
pyvider.datasource.errors.total |
Counter | Total number of data source errors |
Tags: Data source metrics include tags for datasource_type (e.g., mycloud_images)
Function Metrics¶
Monitor provider function calls:
| Python | |
|---|---|
| Metric Name | Type | Description |
|---|---|---|
pyvider.function.calls.total |
Counter | Total number of function calls |
pyvider.function.duration.seconds |
Histogram | Function execution duration in seconds |
pyvider.function.errors.total |
Counter | Total number of function errors |
Tags: Function metrics include tags for function_name (e.g., hash_file)
Ephemeral Resource Metrics¶
Track ephemeral resource lifecycle:
| Python | |
|---|---|
| Metric Name | Type | Description |
|---|---|---|
pyvider.ephemeral.open.total |
Counter | Total ephemeral resource open operations |
pyvider.ephemeral.renew.total |
Counter | Total ephemeral resource renew operations |
pyvider.ephemeral.close.total |
Counter | Total ephemeral resource close operations |
pyvider.ephemeral.errors.total |
Counter | Total ephemeral resource errors |
Tags: Ephemeral metrics include tags for ephemeral_type
Provider Metrics¶
Monitor provider configuration:
| Python | |
|---|---|
| Metric Name | Type | Description |
|---|---|---|
pyvider.provider.configure.total |
Counter | Total provider configure operations |
pyvider.provider.configure.errors.total |
Counter | Total provider configure errors |
Using Metrics¶
Automatic Collection¶
Metrics are automatically collected - you don't need to do anything:
Manual Metric Recording¶
If you need to record custom metrics in your provider, use provide.foundation.metrics directly:
Metrics Export¶
Prometheus Export¶
Pyvider metrics can be exported to Prometheus via the provide.foundation library. Configure your provider's metrics endpoint:
| Python | |
|---|---|
Other Exporters¶
The provide.foundation.metrics library supports multiple exporters. See the provide.foundation documentation for details on:
- CloudWatch export
- Datadog export
- StatsD export
- Custom exporters
Metric Types¶
Counter¶
Counters track cumulative totals that only increase:
| Python | |
|---|---|
Histogram¶
Histograms track distributions of values (timing, sizes, etc.):
| Python | |
|---|---|
Structured Logging¶
For structured logging in your provider, use structlog or provide.foundation.logging:
Environment Variables¶
Configure metrics behavior via environment variables:
| Bash | |
|---|---|
Related Documentation¶
- provide.foundation metrics - Underlying metrics library
- Logging Guide - Structured logging patterns
- Debugging - Debug with metrics
- Error Handling - Error tracking