Skip to main content

Juntai Observability Python

简体中文

juntai-observability is Juntai's side-effect-free Python integration for standard OpenTelemetry logs, metrics, traces, and W3C propagation. It owns bootstrap, correlation conventions, redaction, bounded metric attributes, and deterministic test utilities. It does not own telemetry storage, queries, dashboards, backend credentials, product health semantics, or usage metering.

Install and configure

python -m pip install 'juntai-observability>=2,<3'

Configure exactly once at the application composition root. Importing the package does not install providers, replace logging classes, register exporters, start threads, or register shutdown hooks.

from juntai.observability import ObservabilityConfig, configure_observability

observability = configure_observability(
    ObservabilityConfig.from_env(
        service_namespace="juntai.axiom",
        service_name="driver",
        service_version="2.4.1",
        metric_attribute_allowlist={
            "axiom.execution.requests": {"result", "mode"},
        },
    )
)

logger = observability.logger(__name__)
tracer = observability.tracer(__name__)
meter = observability.meter(__name__)

try:
    run_service()
finally:
    observability.shutdown(timeout=5.0)

Repeated identical configuration returns the same runtime. A conflicting configuration or configuration after shutdown raises ObservabilityConfigurationError during startup.

Environment contract

  • OTEL_EXPORTER_OTLP_ENDPOINT normally points to the platform sidecar at http://127.0.0.1:4318.
  • OTEL_EXPORTER_OTLP_PROTOCOL is http/protobuf or grpc.
  • OTEL_SERVICE_NAME is the registered service name.
  • OTEL_RESOURCE_ATTRIBUTES supplies service.namespace, service.version, deployment.environment.name, and optionally service.instance.id and juntai.artifact.digest.
  • OTEL_TRACES_SAMPLER and OTEL_TRACES_SAMPLER_ARG come from the environment profile.

Application containers do not receive central backend credentials. Kubernetes resource attributes are added by the Collector, not accepted from application environment parsing.

Logging and correlation

ObservabilityRuntime.logger(name) returns a standard logging.Logger with an OpenTelemetry handler attached only to that logger. Active trace_id and span_id are supplied by OpenTelemetry. Structured extras are redacted and bounded before export.

from juntai.observability import bind_context

with bind_context(
    tenant_id=verified_tenant_id,
    tenant_verified=True,
    application_id=application_id,
    workflow_id=workflow_id,
    execution_id=execution_id,
):
    with tracer.start_as_current_span("axiom.execute"):
        logger.info("execution completed", extra={"execution.result": "succeeded"})

Only approved correlation baggage is injected or extracted. Tenant context must be explicitly verified. Secret-like keys and values, connection strings, credentials, and oversized values are removed or bounded before export.

Metrics

Meters and instruments implement standard OpenTelemetry interfaces. Metric points are dropped without failing the business operation when they contain prohibited high-cardinality keys, undeclared keys for a configured instrument, oversized values, too many labels, or more distinct attribute sets than the configured bound.

requests = meter.create_counter(
    "axiom.execution.requests",
    unit="{request}",
    description="Execution requests accepted by the driver",
)
requests.add(1, {"result": "accepted", "mode": "batch"})

Do not use tenant, user, application, workflow, execution, request, trace, raw URL, exception message, or free-form text values as metric attributes.

Deterministic tests

InMemoryObservability uses real SDK providers with in-memory exporters and no network or process-global mutation.

from juntai.observability import InMemoryObservability

telemetry = InMemoryObservability(
    service_namespace="juntai.axiom",
    service_name="driver",
)

with telemetry.tracer("test").start_as_current_span("axiom.execute"):
    telemetry.logger("test").warning("completed")

assert telemetry.logs[0].trace_id == telemetry.spans[0].trace_id
telemetry.shutdown()

The machine-readable convention is conventions/observability.v1.json. See DEVELOPMENT.md for build, contract, and real Collector acceptance commands.

Compatibility and ownership

Generic v1 imports from juntai.core.observability_tools remain as an explicit, deprecated adapter for one release. The adapter never replaces the process-wide logger class. Usage APIs are not compatible exports; install juntai-usage.

Raw telemetry is explored with the selected backend's native interfaces. Product domains own dashboards, alert interpretation, durable business state, and health actions.

Download files

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

Source Distribution

juntai_observability-2.0.5.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

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

juntai_observability-2.0.5-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file juntai_observability-2.0.5.tar.gz.

File metadata

  • Download URL: juntai_observability-2.0.5.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for juntai_observability-2.0.5.tar.gz
Algorithm Hash digest
SHA256 daddd48734b0fe3089657f8ad7248fc1695bd97fca91aab7c87f4cb339764aa1
MD5 2c6872ac8161357e0cd54495c480d8bb
BLAKE2b-256 92e8399b08f1706e0f2cf790fcbda5f510aa4206c11f44e317a098a5f4926eda

See more details on using hashes here.

Provenance

The following attestation bundles were made for juntai_observability-2.0.5.tar.gz:

Publisher: publish.yml on zephytiju/JuntaiObservabilityTools

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

File details

Details for the file juntai_observability-2.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for juntai_observability-2.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 55802c0464a7655ddd9ba5f5d7f40f55164c809194b641d2a1643f7a6638bda8
MD5 f9c42cedf623c50942a949373df4d9d7
BLAKE2b-256 00a9432f1839df3d514e9282f27116e84bff238eb213525694096bc45473fc5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for juntai_observability-2.0.5-py3-none-any.whl:

Publisher: publish.yml on zephytiju/JuntaiObservabilityTools

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

Release history Release notifications | RSS feed

This release

2.0.5 This release

2 files

2.0.4

2 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