Skip to main content

Empowering Developers with AI-First DevTools

Project description

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:

  1. Flask Instrumentation: Easily instrument your Flask applications to monitor and trace requests and performance.
  2. Logging: Send logs to InfraStack AI for centralized log management and analysis.
  3. 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_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_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_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")

Note on API Key Configuration

The InfraStack AI SDK provides two methods for configuring your API key:

  1. Passing it as a Parameter: You can directly pass the infrastackai_api_key as a parameter when initializing the Flask instrument, log handler, or tracer.

  2. Environment Variable (.env): Alternatively, you can set the INFRASTACKAI_API_KEY as 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

infrastack-0.1.1.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file infrastack-0.1.1.tar.gz.

File metadata

  • Download URL: infrastack-0.1.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.18

File hashes

Hashes for infrastack-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6e789eac40cb2f62a25013391e7883597972aac6ede1e91ae1d2b68a41bc6dfc
MD5 81ee454c9189f77a73d13377b26ac3d4
BLAKE2b-256 72564e809e7f8ea7951be04fef642059a1efef9ece5a4fec269773e3788b28c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page