Metadata-Version: 2.4
Name: monium-sdk
Version: 1.1.0
Summary: Описание вашей утилиты
Author-email: ivan13821 <safarovi670@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/ivan13821/Monium
Project-URL: Repository, https://github.com/ivan13821/Monium
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohappyeyeballs>=2.7.1
Requires-Dist: aiohttp>=3.14.3
Requires-Dist: aiosignal>=1.4.0
Requires-Dist: attrs>=26.1.0
Requires-Dist: certifi>=2026.7.22
Requires-Dist: cffi>=2.1.1
Requires-Dist: charset-normalizer>=3.5.1
Requires-Dist: cryptography>=50.0.1
Requires-Dist: Deprecated>=1.3.1
Requires-Dist: frozenlist>=1.8.0
Requires-Dist: googleapis-common-protos>=1.75.2
Requires-Dist: grpcio>=1.83.0
Requires-Dist: grpcio-tools>=1.81.1
Requires-Dist: idna>=3.19
Requires-Dist: multidict>=6.7.1
Requires-Dist: opentelemetry-api>=1.44.0
Requires-Dist: opentelemetry-exporter-otlp>=1.44.0
Requires-Dist: opentelemetry-exporter-otlp-proto-common>=1.44.0
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.44.0
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.44.0
Requires-Dist: opentelemetry-proto>=1.44.0
Requires-Dist: opentelemetry-sdk>=1.44.0
Requires-Dist: opentelemetry-semantic-conventions>=0.65b0
Requires-Dist: propcache>=0.5.2
Requires-Dist: protobuf>=6.33.6
Requires-Dist: pycparser>=3.0
Requires-Dist: PyJWT>=2.13.0
Requires-Dist: requests>=2.34.2
Requires-Dist: setuptools>=84.0.0
Requires-Dist: six>=1.17.0
Requires-Dist: typing_extensions>=4.16.0
Requires-Dist: urllib3>=2.7.0
Requires-Dist: wrapt>=2.3.0
Requires-Dist: yandexcloud>=0.404.0
Requires-Dist: yarl>=1.24.5
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Dynamic: license-file

# Monium
This library is designed for working with Monium from Yandex Cloud. It provides a simplified way to write logs and metrics. Internally, it uses the OpenTelemetry protocol.


## Performance
- The library uses asynchronous calls to obtain IAM tokens and API keys. Renewal and deletion are also performed asynchronously.
- API keys are cached. If any existing key contains the required set of roles, that key is returned. In other words, the role set of an existing key must include the role set of the requested key.
- Token validation runs as a background process, so it does not block the main execution flow.

## Security
Several security measures are implemented:
1. IAM token rotation. Tokens have a short lifespan — 1 hour by default — after which they become invalid and are automatically renewed.
2. API key rotation. Each API key is created with the minimum required permissions requested by the user. When the key expires, it is deleted from the cloud and a new one is created.
3. Automatic metadata detection. If the program is running on a Yandex Cloud VM, the library automatically obtains the IAM token from the VM metadata.

## Usage
First, configure the class for token management:

```python
from monium_sdk.security import ServiceAccountConfigData, Tokens

config = ServiceAccountConfigData(
    service_account_id="Service account ID",
    private_key="Private key for the service account",
    key_id="Key ID"
)

# If you are using a file downloaded from Yandex Cloud, you can specify it:

config_path = ServiceAccountConfigData(
    patch="path/to/file"
)

Tokens.service_account_config = config_path
```

After that, you can use all the library's functionality:
```python
import asyncio
from monium_sdk import Telemetry

async def test():
    
    # Set configuration for log collection
    Telemetry.project = "folder__*****"
    Telemetry.service = "your service"
    Telemetry.cluster = "test"
    
    # Start the background process to refresh local providers.
    # This is needed to update keys and tokens.
    Telemetry.init()
    
    # Collect logs
    Telemetry.log.info("msg")
    Telemetry.log.error("msg for error")
    
    # Collect metrics
    Telemetry.metric.add_to_counter()


if __name__ == "__main__":
    # An active event loop is required for the library to work
    asyncio.run(test())
```
