JunjoOtelExporter
junjo.telemetry.junjo_otel_exporter.JunjoOtelExporter
Kind: Class
SDK version: 0.69.0
Documentation channel: Stable release
Signature
Section titled “Signature”JunjoOtelExporter(endpoint: str, api_key: str, insecure: bool = False)Configure Junjo AI Studio trace export for an existing OpenTelemetry setup.
Junjo is designed to be compatible with existing OpenTelemetry configurations by adding a span processor instead of creating or replacing the application’s tracer provider.
Junjo AI Studio currently accepts OTLP traces only. This exporter therefore
exposes a span_processor and does not create a meter provider,
metric reader, or periodic metric-export worker. Applications that export
metrics to another OpenTelemetry destination should configure that metric
pipeline independently.
In normal applications, the tracer provider remains the top-level owner of
shutdown. Call TracerProvider.shutdown() when the process is
terminating.
flush is available for a manual local queue drain when you truly
need it, such as in short-lived scripts or tests. shutdown is a
wrapper-local helper that shuts down only the Junjo-owned span processor.
Parameters
Section titled “Parameters”| Name | Type | Description | Default |
|---|---|---|---|
endpoint |
str |
The OTLP/gRPC endpoint for Junjo AI Studio, including the port, such as localhost:26155. |
|
api_key |
str |
The API key for the Junjo AI Studio. | |
insecure |
bool |
Whether to allow insecure connections to the Junjo AI Studio. Defaults to False. |
False |
Local Development
To send telemetry to a local Junjo AI Studio instance, such as one running through Docker Compose:
import osfrom junjo.telemetry.junjo_otel_exporter import JunjoOtelExporterfrom opentelemetry import tracefrom opentelemetry.sdk.resources import Resourcefrom opentelemetry.sdk.trace import TracerProvider
# Retrieve API key from environmentJUNJO_AI_STUDIO_API_KEY = os.getenv("JUNJO_AI_STUDIO_API_KEY")resource = Resource.create({"service.name": "my-ai-workflow"})
# Application running directly on the local machinejunjo_exporter = JunjoOtelExporter( endpoint="localhost:26155", api_key=JUNJO_AI_STUDIO_API_KEY, insecure=True,)
# If the application instead runs on Studio's Docker network, replace# the block above with this endpoint (localhost resolves to the app# container itself):# junjo_exporter = JunjoOtelExporter(# endpoint="ingestion:26155",# api_key=JUNJO_AI_STUDIO_API_KEY,# insecure=True,# )
# Add Junjo AI Studio trace export to your tracer providertracer_provider = TracerProvider(resource=resource)tracer_provider.add_span_processor(junjo_exporter.span_processor)trace.set_tracer_provider(tracer_provider)
# On application shutdown:tracer_provider.shutdown()Production Deployment
For a production environment with TLS enabled, such as one behind a reverse proxy like Caddy:
import osfrom junjo.telemetry.junjo_otel_exporter import JunjoOtelExporterfrom opentelemetry import tracefrom opentelemetry.sdk.resources import Resourcefrom opentelemetry.sdk.trace import TracerProvider
# Retrieve API key from environmentJUNJO_AI_STUDIO_API_KEY = os.getenv("JUNJO_AI_STUDIO_API_KEY")resource = Resource.create({"service.name": "my-ai-workflow"})
junjo_exporter_prod = JunjoOtelExporter( endpoint="ingestion.junjo.example.com:443", api_key=JUNJO_AI_STUDIO_API_KEY, insecure=False, # TLS enabled)
# Add Junjo AI Studio trace export to your tracer providertracer_provider = TracerProvider(resource=resource)tracer_provider.add_span_processor(junjo_exporter_prod.span_processor)trace.set_tracer_provider(tracer_provider)
# On application shutdown:tracer_provider.shutdown()Constructor
Section titled “Constructor”Initializes the JunjoOtelExporter.
Members
Section titled “Members”span_processor
Section titled “span_processor”span_processor: BatchSpanProcessorReturns the configured span processor.
shutdown
Section titled “shutdown”shutdown() -> boolShut down the Junjo-owned span processor.
In most applications, the preferred terminal lifecycle is to shut down
the owning TracerProvider. This helper is provided for cases where
you need to shut down only the Junjo-owned span processor directly.
Returns
Section titled “Returns”bool:Trueif the span processor shuts down cleanly,Falseif shutdown raises. Failures are logged through thejunjo.telemetrylogger.
flush(timeout_millis: float = 120000) -> boolRequest a manual drain of pending local telemetry.
Use it only when a short-lived script or test needs to ask the local batch processor to drain before normal provider shutdown.
OpenTelemetry’s batch processor does not propagate collector acceptance
or durability through force_flush(). A True result therefore
confirms only that the processor reported its local drain complete; it
is not proof that Studio accepted or persisted the spans. Verify remote
delivery through Studio’s query APIs when that guarantee matters. The
installed OpenTelemetry processor may also apply its timeout as a best-
effort budget rather than a strict deadline.
In normal applications, shut down the owning TracerProvider instead
of using flush as the standard exit path.
Parameters
Section titled “Parameters”| Name | Type | Description | Default |
|---|---|---|---|
timeout_millis |
float |
Best-effort local processor budget requested for the drain, in milliseconds. The installed OpenTelemetry processor may not enforce it as a strict deadline. Defaults to 120000ms (120 seconds). |
120000 |
Returns
Section titled “Returns”bool:Trueif the span processor reports its local drain complete,Falseif it refuses or raises. This does not attest collector acceptance. Surfaced failures are logged through thejunjo.telemetrylogger.