DevSkin Monitor Agent - Python Instrumentation SDK
Project description
devskin-agent
DevSkin APM Agent for Python - Automatic instrumentation for Flask, Django, and FastAPI.
Installation
pip install devskin-agent
Quick Start
Flask
from flask import Flask
from devskin_agent import init, start_agent
from devskin_agent.instrumentation import flask_middleware
# Initialize agent
agent = init(
server_url='http://localhost:3000',
api_key='your-api-key',
service_name='my-flask-app',
service_version='1.0.0',
environment='production',
)
start_agent()
# Create Flask app
app = Flask(__name__)
# Add middleware
flask_middleware(app, agent)
@app.route('/api/users')
def get_users():
# Automatically traced!
return {'users': []}
if __name__ == '__main__':
app.run()
Django
Add to your settings.py:
MIDDLEWARE = [
'devskin_agent.instrumentation.DjangoMiddleware',
# ... other middleware
]
# At the end of settings.py
from devskin_agent import init, start_agent
DEVSKIN_AGENT = init(
server_url='http://localhost:3000',
api_key='your-api-key',
service_name='my-django-app',
environment='production',
)
start_agent()
FastAPI
from fastapi import FastAPI
from devskin_agent import init, start_agent
from devskin_agent.instrumentation import fastapi_middleware
# Initialize agent
agent = init(
server_url='http://localhost:3000',
api_key='your-api-key',
service_name='my-fastapi-app',
)
start_agent()
# Create FastAPI app
app = FastAPI()
# Add middleware
fastapi_middleware(app, agent)
@app.get('/api/users')
async def get_users():
# Automatically traced!
return {'users': []}
Manual Span Creation
from devskin_agent import get_agent, SpanBuilder, SpanKind
agent = get_agent()
def process_order(order_id):
span = SpanBuilder(
name='process_order',
kind=SpanKind.INTERNAL,
service_name=agent.get_config().service_name,
agent=agent
)
span.set_attribute('order.id', order_id)
try:
# Your business logic
order = fetch_order(order_id)
span.set_attribute('order.amount', order['amount'])
return order
except Exception as e:
span.record_error(e)
raise
finally:
span.end()
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
server_url |
str | required | DevSkin backend URL |
api_key |
str | required | API key for authentication |
service_name |
str | required | Name of your service |
service_version |
str | None | Version of your service |
environment |
str | None | Environment (production, staging, etc) |
enabled |
bool | True | Enable/disable agent |
sample_rate |
float | 1.0 | Sample rate (0.0 to 1.0) |
batch_size |
int | 100 | Batch size before flushing |
flush_interval |
float | 10.0 | Flush interval in seconds |
debug |
bool | False | Enable debug logging |
Environment Variables
export DEVSKIN_SERVER_URL=http://localhost:3000
export DEVSKIN_API_KEY=your-api-key
export DEVSKIN_SERVICE_NAME=my-service
export DEVSKIN_ENVIRONMENT=production
export DEVSKIN_SAMPLE_RATE=1.0
import os
from devskin_agent import init
agent = init(
server_url=os.getenv('DEVSKIN_SERVER_URL'),
api_key=os.getenv('DEVSKIN_API_KEY'),
service_name=os.getenv('DEVSKIN_SERVICE_NAME'),
environment=os.getenv('DEVSKIN_ENVIRONMENT'),
sample_rate=float(os.getenv('DEVSKIN_SAMPLE_RATE', '1.0')),
)
Features
- ✅ Automatic Flask instrumentation
- ✅ Automatic Django instrumentation
- ✅ Automatic FastAPI instrumentation
- ✅ Manual span creation
- ✅ Distributed tracing with trace ID propagation
- ✅ Error tracking and reporting
- ✅ Sampling support
- ✅ Context propagation across async operations
- ✅ Service discovery
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
devskin_agent-1.0.0.tar.gz
(13.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file devskin_agent-1.0.0.tar.gz.
File metadata
- Download URL: devskin_agent-1.0.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f22a75ff0eceb4baaf9198825e7ab50f153be799d563a0bcf507c2e149f948e
|
|
| MD5 |
89af118a2dc09deebc9af971b0d5d654
|
|
| BLAKE2b-256 |
9de5de54d9ddb9ec0b11b4b93cec1b3cb791b8df1a16aa9066a28b1eade7c7bd
|
File details
Details for the file devskin_agent-1.0.0-py3-none-any.whl.
File metadata
- Download URL: devskin_agent-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bb7515dd1c34c357d660969729e9839d5f77c501b03840940e9c5d1cbba42c2
|
|
| MD5 |
c187e3adb8545beca2ece2c3024c8323
|
|
| BLAKE2b-256 |
716fe4701dccaa7efba915a962afddbb05ec80ce18a16a2bd9f97d175b06af82
|