Skip to main content

Scavenger Agent Python (BETA)

(본 Agent는 베타 버전으로 현재 개발 환경에서만의 사용을 권장하며 상용 환경에서의 사용을 권장하지 않습니다.) Scavenger Agent의 Python 버전으로, Agent가 아닌 Server Component는 사전에 준비되어야 합니다.

개발 가이드

Scavenger Agent Python은 패키지 관리자로 Poetry를 이용합니다.

  • 의존성 설치
$ poetry install
  • 테스트
$ poetry run python -m unittest
  • 빌드
$ poetry build

자세한 내용은 Poetry Docs를 참고해주세요.

에이전트 설치 가이드

전제조건

Python >= 3.7

설치

$ pip install scavenger-agent-python --save

설정

설정은 설정 파일 scavenger.conf을 이용한 방식과 Config Instance를 직접 생성하는 두 가지 방식을 지원합니다.

  • Example of scavenger.conf
# scavenger.conf
apiKey=eb99ff0f-aaaa-bbbb-cccc-5d1ec81f6183
serverUrl=http://10.106.93.41:8081
environment=dev
appName=apiserver
packages=views
codebase=.
---
# source
config = Config.load_config()
agent = Agent(config)
  • Example of Config()
config = Config(
    api_key="eb99ff0f-aaaa-bbbb-cccc-5d1ec81f6183",
    server_url="http://10.106.93.41:8081",
    environment="dev",
    app_name="apiserver",
    packages=["views"],
    codebase=["."],
)
agent = Agent(config)

에이전트 시작

Scavenger Agent Python은 Scavenger Agent Java와 달리, Agent 시작 코드를 직접 삽입하는 방식으로 동작합니다. 수집을 시작할 함수의 모듈이 import되기 전에 Agent가 동작해야 하므로 반드시 프로그램의 시작점에 Agent 시작 코드가 삽입되어야 함을 유의하십시오.

from scavenger import Agent, Config

config = Config.load_config()
agent = Agent(config)
agent.start()

### your source code
from ...

한계

  • Graceful Shutdown에 대한 구현은 기존 프레임워크와의 충돌 가능성으로 인해 자동으로 지원하지 않습니다. 대신 아래와 같은 agent.shutdown() 함수를 지원하므로 직접 등록하여서 사용하여야 합니다.
def shutdown_gracefully(*args):
    # Shutdown your application/server first.
    agent.shutdown()
    sys.exit(0)

signal.signal(signal.SIGTERM, shutdown_gracefully)
agent.start()
  • Scavenger Python Agent는 현재 모듈/클래스의 레퍼런스를 대체하는 방식으로 동작하므로 레퍼런스를 사용하지 않고 함수를 호출하는 경우에는 동작하지 않습니다. 따라서 아래와 같이 Decorator를 이용해 함수의 레퍼런스만 따로 프레임워크에 저장해두는 경우, def hello_world()에는 동작하지 않습니다. 이는 추후 함수내 코드를 삽입하는 방식으로 변경되어 지원될 예정입니다.
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'
  • 코드를 직접 읽어서 메서드를 탐색해야 하므로 pyc 파일은 현재 지원되지 않습니다.

Metadata

Release files for scavenger-agent-python 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scavenger-agent-python 0.1.2
File Size Uploaded
scavenger_agent_python-0.1.2.tar.gz 21.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scavenger-agent-python 0.1.2
File Interpreter ABI Platform
scavenger_agent_python-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 51.1 kB

Release files / scavenger_agent_python-0.1.2.tar.gz

Download URL scavenger_agent_python-0.1.2.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a6b42053d9e6f37c0a36a2ab3456f9113a7304fc0774e8855929c9649899fc99
BLAKE2b-256 checksum
How to use checksums
4a7b4fb0063b612ecfcaca43cf8ba1dd969089511949f923e69bc0d0741d7746
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.10.9 Darwin/21.6.0

Release files / scavenger_agent_python-0.1.2-py3-none-any.whl

Download URL scavenger_agent_python-0.1.2-py3-none-any.whl
Size 30.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e439d92becb6573ebce34825ae4ada826b95bf7daaf62ecbb9a2cff59f5837e
BLAKE2b-256 checksum
How to use checksums
d4d9195fc027f125632d09ba53e7e6b7ea902aefe1f7c36ef154b5e91cc447cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.10.9 Darwin/21.6.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page