Introduction
Welcome to the InfraStack AI Python SDK! This SDK is designed to help developers and development teams integrate advanced observability capabilities into their applications. InfraStack AI provides next-generation observability tools that allow you to ship high-quality code and gain actionable insights in milliseconds.
Capabilities
Currently, this SDK supports:
- Flask Instrumentation: Easily instrument your Flask applications to monitor and trace requests and performance.
- Logging: Send logs to InfraStack AI for centralized log management and analysis.
- Tracing: Create and manage traces to monitor the performance and behavior of your application.
We are actively working on adding support for Django FastAPI and LLM's, so stay tuned for more updates!
Installation
pip3 install infrastack
Integrations
Flask Instrument
To instrument your Flask application with InfraStack AI, use the following code snippet:
from infrastack import FlaskInstrument
from flask import Flask
app = Flask(__name__)
FlaskInstrument("your_service_name", app, infrastackai_api_key="your_infrastack_api_key")
@app.route('/')
def hello_world():
return 'Hello, World!'
if __name__ == '__main__':
app.run()
Logging
To send logs to InfraStack AI, use the following code snippet:
from infrastack import LogHandler
import logging
logger = logging.getLogger(__name__)
LogHandler("your_service_name", logger, infrastackai_api_key="your_infrastack_api_key")
logger.info("TEST")
Tracing
To create and use a tracer with InfraStack AI, use the following code snippet:
from infrastack import CreateTracer
my_tracer = CreateTracer("your_service_name", "trace_name", infrastackai_api_key="your_infrastack_api_key")
with my_tracer.start_span("scope-create-version") as span:
span.set_attribute("version", "0.0.0")
span.set_attribute("scope", "create-version")
span.set_attribute("author", "Your Name")
print("hi")
OpenAI Instrument
To instrument your OpenAI API calls with InfraStack AI, use the following code snippet:
from infrastack import OpenAIInstrument
from openai import OpenAI
# Initialize OpenAIInstrument
instrument = OpenAIInstrument("your_service_name", catch_content=False, infrastackai_api_key="your_infrastack_api_key")
# Example OpenAI API call
client = OpenAI(api_key="your_openai_api_key")
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": [{"type": "text", "text": "Hi"}]}
]
)
print(response)
Note on API Key Configuration
The InfraStack AI SDK provides two methods for configuring your API key:
-
Passing it as a Parameter: You can directly pass the
infrastackai_api_keyas a parameter when initializing the Flask instrument, log handler, or tracer. -
Environment Variable (.env): Alternatively, you can set the
INFRASTACKAI_API_KEYas an environment variable. If this environment variable is set, the SDK will automatically use it, and you do not need to pass the API key as a parameter.
Contributing
We welcome contributions! Please submit a pull request or open an issue to get started.
Metadata
Release files for infrastack 0.2.0
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 |
|---|---|---|---|---|
| infrastack-0.2.0.tar.gz | 5.5 kB | Without provenance | Details for infrastack-0.2.0.tar.gz |
Release files / infrastack-0.2.0.tar.gz
| Download URL | infrastack-0.2.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4db1957bcef58019d4213530e5ef41294a1040d62adbaf5d91acfdb9b525ab3a
|
|
BLAKE2b-256 checksum How to use checksums |
f3ae8bdd8cfd90b9b525b464f6fb24dbdc8c44008f921dc305ed054a1db4b901
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.8.18
|
Security for infrastack 0.2.0
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.