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.4.tar.gz (26.0 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.4-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: juntai_observability-2.0.4.tar.gz
  • Upload date:
  • Size: 26.0 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.4.tar.gz
Algorithm Hash digest
SHA256 e68b8ff5ebb192f46268276f18bf752ddacb93d0c2605a5a057e1234985a3fd7
MD5 a01ea477cad3a44be7550eb7f1171d1e
BLAKE2b-256 242502708072d6540d2814f906ad74af56a7b68e5ebd68d89331851361baf043

See more details on using hashes here.

Provenance

The following attestation bundles were made for juntai_observability-2.0.4.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.4-py3-none-any.whl.

File metadata

File hashes

Hashes for juntai_observability-2.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d51a63c155f9ddb3f36480e0d2ff178cb1221a92d588659938fb3b23ec6791c9
MD5 037e2c3d4c2084b10d5102cfa2620934
BLAKE2b-256 b5a0762584ded2e90840275fdc37effdabe279ef654141923213c5d44a9697be

See more details on using hashes here.

Provenance

The following attestation bundles were made for juntai_observability-2.0.4-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

2.0.5

2 files

This release

2.0.4 This release

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