Selise Blocks LMT
Selise Blocks LMT (Logging, Monitoring, and Tracing) library for Selise Blocks applications. It sends logs and traces to Azure Service Bus for centralized processing.
Installation
Using pip:
pip install seliseblocks-lmt
Using uv:
uv add seliseblocks-lmt
Add to pyproject.toml:
[project]
dependencies = [
"seliseblocks-lmt>=0.0.1",
]
Complete Example
import logging
from fastapi import FastAPI, Request
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from blocks_lmt.log_config import configure_logger
from blocks_lmt.tracing import configure_tracing
from blocks_lmt.activity import Activity
app = FastAPI(title="Example Service with LMT")
FastAPIInstrumentor.instrument_app(app)
configure_logger(
x_blocks_key="default-tenant",
blocks_service_id="example-service",
connection_string="Endpoint=sb://your-namespace.servicebus.windows.net/;..."
)
configure_tracing(
x_blocks_key="default-tenant",
blocks_service_id="example-service",
connection_string="Endpoint=sb://your-namespace.servicebus.windows.net/;..."
)
logger = logging.getLogger(__name__)
@app.get("/")
async def root():
logger.info("Root endpoint called")
with Activity.start("handle_root_request") as activity:
activity.set_property("endpoint", "/")
return {"message": "Hello World"}
@app.get("/health")
async def health(request: Request):
logger.info("Health endpoint called")
Activity.set_current_properties({
"http.query": str(dict(request.query_params)),
"http.headers": str(dict(request.headers))
})
return {"status": "healthy"}
Activity API Reference
Context Manager
with Activity.start("operation_name") as activity:
activity.set_property("key", "value")
activity.set_properties({"key1": "val1", "key2": "val2"})
Status Handling
from opentelemetry.trace import StatusCode
Activity.set_current_status(StatusCode.ERROR, "Error message")
Best Practices
- Always instrument FastAPI:
FastAPIInstrumentor.instrument_app(app)
- Use context managers for activities to ensure proper cleanup:
with Activity.start("operation"):
...
- Log inside active spans to maintain trace correlation:
logger.info("This log is trace-correlated")
- Add meaningful properties to activities:
activity.set_property("user_id", user_id)
Dependencies
azure-servicebus = ">=7.14.2"
opentelemetry-api = ">=1.33.1"
opentelemetry-sdk = ">=1.33.1"
opentelemetry-instrumentation-fastapi = ">=0.54b1"
Metadata
Release files for seliseblocks-lmt 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| seliseblocks_lmt-0.0.4.tar.gz | 49.9 kB | Without provenance | Details for seliseblocks_lmt-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| seliseblocks_lmt-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for seliseblocks_lmt-0.0.4-py3-none-any.whl |
Total release size: 70.8 kB
Release files / seliseblocks_lmt-0.0.4.tar.gz
| Download URL | seliseblocks_lmt-0.0.4.tar.gz |
|---|---|
| Size | 49.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8325a5027a2f1a2f6ad1cd68f3e9a456ed05532fe4c262601719a20dfbf0471f
|
|
BLAKE2b-256 checksum How to use checksums |
8272d692264f37eb5a8b24c85a9a89e1955fe1d23beddebf0c4cf8ae9cb05efb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.12
|
Release files / seliseblocks_lmt-0.0.4-py3-none-any.whl
| Download URL | seliseblocks_lmt-0.0.4-py3-none-any.whl |
|---|---|
| Size | 20.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f905907ba285f97867d3b2d0157c34981bd5e279e35f804e9735babb1b62f612
|
|
BLAKE2b-256 checksum How to use checksums |
d71f112b60e4e72c50ce684f5155cb8ca7f6d89f08a868539954a34507f17088
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.12
|
Security for seliseblocks-lmt 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.