Skip to main content

OpenTelemetry SDK for Coalex.ai with OTLP integration

Project description

Coalex SDK

A Python package for OpenTelemetry integration with Coalex.ai observability platform.

Installation

pip install coalex

Quick Start with VertexAI

from coalex.otel import register, coalex_context
from openinference.instrumentation.vertexai import VertexAIInstrumentor
from vertexai.generative_models import GenerativeModel

# Register Coalex tracing
tracer_provider = register(
    agent_id="YOUR_AGENT_ID"
)

# Instrument VertexAI with Coalex tracer
VertexAIInstrumentor().instrument(tracer_provider=tracer_provider)

# Create model instance
model = GenerativeModel("gemini-2.0-flash")

# Use coalex_context for proper span management and attribute propagation
with coalex_context(
    request_id="req_vertex_001",
    prompt_version="v1.0.0"
):
    # Generate content - this will be automatically traced with proper context
    response = model.generate_content(
        "Write a haiku about artificial intelligence.",
        generation_config={
            "max_output_tokens": 100,
            "temperature": 0.7,
        }
    )

print("Generated haiku:")
print(response.text)

Features

  • Simple Setup: One-line registration with register()
  • Coalex Integration: Default endpoint for Coalex observability platform
  • Context Management: Use coalex_context() for proper span hierarchy and attribute propagation
  • OpenInference Compatible: Works with all OpenInference instrumentors
  • Authentication: Automatic authentication using agent_id

Configuration

  • agent_id: Your unique agent identifier (required for authentication)
  • endpoint: OTLP endpoint (defaults to Coalex: https://traces.coalex.ai/v1/traces)

Example

See examples/vertexai_example.py for a complete working example including:

  • Basic content generation
  • Streaming responses
  • Proper error handling
  • Context management with coalex_context()

To run the example, install the additional dependencies:

pip install google-cloud-aiplatform openinference-instrumentation-vertexai

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

coalex-0.4.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

coalex-0.4.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file coalex-0.4.1.tar.gz.

File metadata

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

File hashes

Hashes for coalex-0.4.1.tar.gz
Algorithm Hash digest
SHA256 0080b9a5775e8fdb3aa9a488dc1933da55fb5929915b0bac14ac9e6ec94e33b9
MD5 7886fe2e4ea277bbfa0ba28c7909f55b
BLAKE2b-256 cc173f9ed39787e7e1b348a152cdd237bbc3de5593563eb6c82b87d4ce4ae196

See more details on using hashes here.

Provenance

The following attestation bundles were made for coalex-0.4.1.tar.gz:

Publisher: publish.yml on carlosmlribeiro/coalex.ai

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

File details

Details for the file coalex-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: coalex-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for coalex-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7e8391b0b0bf73e722a54d33d08516181099af0214147a994efdb11b4ce4b65
MD5 b917d8e1c49137ab17a36a34b4dade95
BLAKE2b-256 dab2c027e21e9bcacc4e1f06f09e65e4ca2181426a8508eec6ef736fabe066b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for coalex-0.4.1-py3-none-any.whl:

Publisher: publish.yml on carlosmlribeiro/coalex.ai

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