Skip to main content

OpenTelemetry exporter for AIP integrity checkpoints and AAP verification results

Project description

aip-otel-exporter

PyPI License

OpenTelemetry exporter for AIP integrity checkpoints and AAP verification results.

Python companion to @mnemom/aip-otel-exporter.

Installation

pip install aip-otel-exporter[otel]    # with OpenTelemetry SDK
pip install aip-otel-exporter[auto]    # with auto-instrumentation support
pip install aip-otel-exporter[all]     # all optional dependencies

Quick Start

Manual API

from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, ConsoleSpanExporter

from aip_otel_exporter import AIPOTelRecorder

# Set up OTel
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))

# Create recorder
recorder = AIPOTelRecorder(tracer_provider=provider)

# After an AIP integrity check:
recorder.record_integrity_check(signal)

# After an AAP verification:
recorder.record_verification(result)

# After an AAP coherence check:
recorder.record_coherence(result)

# After AAP drift detection:
recorder.record_drift(alerts, traces_analyzed=50)

Auto-instrumentation

from aip_otel_exporter import AIPInstrumentor

# Automatically wraps AIP/AAP functions to record spans
AIPInstrumentor().instrument()

# Now AIP/AAP calls are automatically traced:
# from aip import AIPClient
# signal = client.check(thinking_block, card)
# ^^^ span is recorded automatically

Direct Functions

For fine-grained control, use the recording functions directly:

from opentelemetry import trace
from aip_otel_exporter.manual import (
    record_integrity_check,
    record_verification,
    record_coherence,
    record_drift,
)

tracer = trace.get_tracer("my-app")
record_integrity_check(tracer, signal)
record_verification(tracer, result)

Span Hierarchy

Spans are created as children of the current active span:

your_application_span
  ├── aip.integrity_check
  │    ├── event: aip.concern (one per concern)
  │    └── event: aip.drift_alert (when drift active)
  ├── aap.verify_trace
  │    └── event: aap.violation (one per violation)
  ├── aap.check_coherence
  └── aap.detect_drift
       └── event: aap.drift_alert (one per alert)

Attributes

aip.integrity_check span — 22 attributes + 2 GenAI SIG aliases

Attribute Type Description
aip.integrity.checkpoint_id string Checkpoint ID
aip.integrity.verdict string clear / review_needed / boundary_violation
aip.integrity.proceed boolean Whether to proceed
aip.integrity.recommended_action string Recommended action
aip.integrity.concerns_count int Number of concerns
aip.integrity.agent_id string Agent ID
aip.integrity.card_id string Alignment Card ID
aip.integrity.session_id string Session ID
aip.integrity.thinking_hash string SHA-256 of thinking block
aip.integrity.analysis_model string Analysis LLM model
aip.integrity.analysis_duration_ms float Analysis duration
aip.integrity.thinking_tokens int Original thinking tokens
aip.integrity.truncated boolean Whether thinking was truncated
aip.integrity.extraction_confidence float Extraction confidence
aip.conscience.consultation_depth string surface / standard / deep
aip.conscience.values_checked_count int Values checked count
aip.conscience.conflicts_count int Conflicts count
aip.window.size int Window size
aip.window.integrity_ratio float Integrity ratio (0.0–1.0)
aip.window.drift_alert_active boolean Drift alert active
gen_ai.evaluation.verdict string GenAI SIG forward-compat alias
gen_ai.evaluation.score float GenAI SIG forward-compat alias

aap.verify_trace span — 8 attributes

Attribute Type
aap.verification.result boolean
aap.verification.similarity_score float
aap.verification.violations_count int
aap.verification.warnings_count int
aap.verification.trace_id string
aap.verification.card_id string
aap.verification.duration_ms float
aap.verification.checks_performed string (comma-separated)

aap.check_coherence span — 5 attributes

Attribute Type
aap.coherence.compatible boolean
aap.coherence.score float
aap.coherence.proceed boolean
aap.coherence.matched_count int
aap.coherence.conflict_count int

aap.detect_drift span — 2 attributes

Attribute Type
aap.drift.alerts_count int
aap.drift.traces_analyzed int

Metrics

from aip_otel_exporter.metrics import (
    create_aip_metrics,
    record_integrity_metrics,
    record_verification_metrics,
    record_coherence_metrics,
    record_drift_metrics,
)

metrics = create_aip_metrics(meter_provider)
record_integrity_metrics(metrics, signal)
Metric Type Labels
aip.integrity_checks.total Counter verdict, agent_id
aip.concerns.total Counter category, severity
aip.analysis.duration_ms Histogram verdict
aip.window.integrity_ratio Histogram
aip.drift_alerts.total Counter
aap.verifications.total Counter verified
aap.violations.total Counter type, severity
aap.verification.duration_ms Histogram
aap.coherence.score Histogram compatible

Requirements

  • Python >= 3.9
  • OpenTelemetry SDK >= 1.20.0 (for [otel] extra)

License

Apache 2.0

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

aip_otel_exporter-0.1.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aip_otel_exporter-0.1.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file aip_otel_exporter-0.1.0.tar.gz.

File metadata

  • Download URL: aip_otel_exporter-0.1.0.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aip_otel_exporter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 20983ff4e5ad4d55846711bdd091b66d6ed523c64720a12fc7d59dc67d7d8544
MD5 7cd37e3a7780ff3c118c83146f3a1dec
BLAKE2b-256 8909306289dd7cf3013555c5ec62f521e6390f6a6d1e9009b782f1ff1c21a8c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for aip_otel_exporter-0.1.0.tar.gz:

Publisher: ci.yml on mnemom/aip-otel-exporter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aip_otel_exporter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aip_otel_exporter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8e1c2df73ebba6fee3039360d739f90f028ac763d3a8859f48eeb0b9e689ede
MD5 bcbc73c686cc125f170b6529a16e9614
BLAKE2b-256 8e6ea12e2aec5b13b47713b0309bc8aa056970558f4c16a0fd991e1507e9b775

See more details on using hashes here.

Provenance

The following attestation bundles were made for aip_otel_exporter-0.1.0-py3-none-any.whl:

Publisher: ci.yml on mnemom/aip-otel-exporter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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