Metadata-Version: 2.4
Name: cryptography-suite-opentelemetry
Version: 4.0.0rc1
Summary: OpenTelemetry metrics and span events for cryptography-suite v4 envelope encryption (pre-release; not independently audited).
Author: Mojtaba Zaferanloo
License-Expression: MIT
Project-URL: Homepage, https://github.com/Psychevus/cryptography-suite
Project-URL: Documentation, https://psychevus.github.io/cryptography-suite
Project-URL: Source, https://github.com/Psychevus/cryptography-suite/tree/main/packages/cryptography-suite-opentelemetry
Project-URL: Changelog, https://github.com/Psychevus/cryptography-suite/blob/main/CHANGELOG.md
Project-URL: Tracker, https://github.com/Psychevus/cryptography-suite/issues
Keywords: opentelemetry,metrics,observability,envelope-encryption,cryptography
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Security :: Cryptography
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: cryptography-suite==4.0.0rc1
Provides-Extra: otel
Requires-Dist: opentelemetry-api>=1.20; extra == "otel"

# cryptography-suite-opentelemetry

OpenTelemetry metrics and span events for
[cryptography-suite](https://github.com/Psychevus/cryptography-suite), the
policy-driven envelope encryption SDK.
Pre-release; not independently audited.

## Install

```console
python -m pip install "cryptography-suite-opentelemetry[otel]"
```

## Use

```python
from opentelemetry import metrics, trace

from cryptography_suite import Protector
from cryptography_suite.audit.chain import AuditChain
from cryptography_suite.audit.fanout import FanOutAuditSink
from cryptography_suite_opentelemetry import OpenTelemetryAuditSink

telemetry = OpenTelemetryAuditSink(
    metrics.get_meter("payments"),
    span_source=trace.get_current_span,  # optional span events
)
protector = Protector(
    ...,
    audit_sink=FanOutAuditSink(
        AuditChain(writer, signing_key, chain_id="prod.payments"), telemetry
    ),
)
```

You pass your `Meter`; the package does not import OpenTelemetry itself.

## Signals

| Signal | Kind | Attributes |
| --- | --- | --- |
| `cryptosuite.operations` | Counter of completed operations | `cryptosuite.operation`, `cryptosuite.outcome`, `cryptosuite.provider_id`, `error.type` |
| `cryptosuite.operation.duration` | Histogram, seconds | the same |
| `cryptosuite.<operation>.<outcome>` | Span event on the current span | the same, plus `cryptosuite.operation_id` and `cryptosuite.policy_id` |

- Metric attributes are low-cardinality: no operation, event, key, or
  envelope identifiers.
- Nothing secret is recorded: the sink sees only the allowlisted, redacted
  `cs-audit/1` event fields.
- `FanOutAuditSink` delivers each event to every sink even if one fails, so
  a metrics outage never costs a signed audit record.

## Documentation

- [Audit and observability](https://github.com/Psychevus/cryptography-suite/blob/main/docs/guide/audit-and-observability.md)
- [Security policy](https://github.com/Psychevus/cryptography-suite/blob/main/SECURITY.md)
