Skip to main content

OpenTelemetry utilities and encapsulation of semantic naming conventions for improved integration with DataRobot.

Project description

datarobot-opentelemetry

OpenTelemetry semantic conventions and utilities for DataRobot telemetry integration.

Installation

# Install base package with semantic conventions only
pip install datarobot-opentelemetry

# Install with integration module for automatic OpenTelemetry setup
pip install datarobot-opentelemetry[integrations]

The [integrations] extra includes all OpenTelemetry dependencies needed for the configure() function.

Usage

from datarobot_opentelemetry.semconv import SpanAttributes

# Use constants as span attribute keys
span.set_attribute(SpanAttributes.GEN_AI_REQUEST_MODEL, "gpt-4o")
span.set_attribute(SpanAttributes.GEN_AI_USAGE_INPUT_TOKENS, 128)
span.set_attribute(SpanAttributes.GEN_AI_USAGE_OUTPUT_TOKENS, 64)

# DataRobot-specific attributes
span.set_attribute(SpanAttributes.DATAROBOT_TRACE_NAME, "my-agent-trace")
span.set_attribute(SpanAttributes.DATAROBOT_SESSION_ID, session_id)

Available attribute groups

Group Prefix Description
Gen AI standard gen_ai.* OpenTelemetry Gen AI semantic conventions
Server server.* Server address/port
Error error.* Error type
DataRobot datarobot.* DataRobot-specific trace metadata

All constants live in datarobot_opentelemetry.semconv.SpanAttributes.

How to use integration

The integration module provides automatic configuration of OpenTelemetry tracing, metrics, and logging to send telemetry data to DataRobot backends.

Basic setup

from datarobot_opentelemetry.integrations import configure

# Configure the OpenTelemetry integration
result = configure(
    endpoint="https://your-telemetry-endpoint.example.com",  # optional if OTEL_EXPORTER_OTLP_ENDPOINT is set
    entity_type="deployment",  # optional if DATAROBOT_ENTITY_TYPE is set
    entity_id="your-entity-id",  # optional if DATAROBOT_ENTITY_ID is set
    api_key="your-api-key",  # optional if DATAROBOT_API_TOKEN is set
)

# Check configuration results
print(f"Tracing configured: {result.tracing_configured}")
print(f"Metrics configured: {result.metrics_configured}")
print(f"Logging configured: {result.logger_configured}")

You can also configure entirely from environment variables:

export OTEL_EXPORTER_OTLP_ENDPOINT="https://your-telemetry-endpoint.example.com"
export DATAROBOT_ENTITY_TYPE="deployment"
export DATAROBOT_ENTITY_ID="your-entity-id"
export DATAROBOT_API_TOKEN="your-api-key"

or using OTEL specific environment variables that take precedence:

export OTEL_EXPORTER_OTLP_ENDPOINT="https://your-telemetry-endpoint.example.com"
export OTEL_EXPORTER_OTLP_HEADERS="X-DataRobot-Entity-Id=deployment-<your-entity-id>,X-DataRobot-Api-Key=<your-api-key>"
from datarobot_opentelemetry.integrations import configure

result = configure()

Configuration parameters

  • endpoint (optional argument, required value): OTLP HTTP endpoint URL for telemetry data. If not passed, uses OTEL_EXPORTER_OTLP_ENDPOINT.
  • entity_type (optional argument, required value): Type of entity being monitored (e.g., "deployment", "workload"). If not passed, uses DATAROBOT_ENTITY_TYPE.
  • entity_id (optional argument, required value): Unique identifier for the entity. If not passed, uses DATAROBOT_ENTITY_ID.
  • api_key (optional argument, required value): API key for authentication. If not passed, uses DATAROBOT_API_TOKEN.
  • log_level (optional): Logging level for the integration (default: logging.INFO)
  • metrics_export_interval (optional): Interval in milliseconds for exporting metrics (default: 60000)

Argument values take precedence over environment variables.

Advanced usage

After calling configure(), standard OpenTelemetry APIs work automatically:

from opentelemetry import trace, metrics

# Get tracer and record spans
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("my-operation") as span:
    span.set_attribute("custom.attribute", "value")
    # Your code here

# Get meter and record metrics  
meter = metrics.get_meter(__name__)
counter = meter.create_counter("my.counter")
counter.add(1)

Requirements

  • Python 3.10+

Release History

  • See CHANGELOG.md for version-by-version release notes.

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

datarobot_opentelemetry-0.2.1.tar.gz (67.6 kB view details)

Uploaded Source

Built Distribution

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

datarobot_opentelemetry-0.2.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file datarobot_opentelemetry-0.2.1.tar.gz.

File metadata

  • Download URL: datarobot_opentelemetry-0.2.1.tar.gz
  • Upload date:
  • Size: 67.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for datarobot_opentelemetry-0.2.1.tar.gz
Algorithm Hash digest
SHA256 fc93df54caa09e93f4e8bfbfb350f6eb42ab09f7c8dd79c44c4700d3ad3bae87
MD5 86ef9c53bcc003f127f765ff98716ca1
BLAKE2b-256 de6d5ff239617da48c4e7fa3182ac042671843ae107029ed2748a3350a66a94f

See more details on using hashes here.

Provenance

The following attestation bundles were made for datarobot_opentelemetry-0.2.1.tar.gz:

Publisher: publish-pypi.yml on datarobot-community/datarobot-opentelemetry-integration

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

File details

Details for the file datarobot_opentelemetry-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for datarobot_opentelemetry-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a84b208810cde60f5948207c2f739b8dfc4b17a6af083c5f22511175e0a2df8b
MD5 32ea2ef20f29132cb6c15d98b0213377
BLAKE2b-256 60fac693fd5417d4a2e4977d843914341a8771fddacb6440943a00e26ef7f497

See more details on using hashes here.

Provenance

The following attestation bundles were made for datarobot_opentelemetry-0.2.1-py3-none-any.whl:

Publisher: publish-pypi.yml on datarobot-community/datarobot-opentelemetry-integration

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