openinference_semantic_conventions/lib.rs
1//! # OpenInference Semantic Conventions for Rust
2//!
3//! This crate provides attribute constants and types for the
4//! [OpenInference semantic conventions](https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md).
5//!
6//! OpenInference is a set of conventions for instrumenting LLM applications,
7//! compatible with OpenTelemetry and designed to work with observability platforms
8//! like [Arize Phoenix](https://phoenix.arize.com/).
9//!
10//! ## Usage
11//!
12//! ```rust
13//! use openinference_semantic_conventions::{SpanKind, attributes};
14//! use opentelemetry::KeyValue;
15//!
16//! // Set the span kind
17//! let kind = KeyValue::new(attributes::OPENINFERENCE_SPAN_KIND, SpanKind::Llm.as_str());
18//!
19//! // Set LLM attributes
20//! let model = KeyValue::new(attributes::llm::MODEL_NAME, "gpt-4");
21//! let tokens = KeyValue::new(attributes::llm::token_count::TOTAL, 150i64);
22//! ```
23//!
24//! ## OTel GenAI Compatibility
25//!
26//! This crate also provides aliases for [OpenTelemetry GenAI semantic conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/)
27//! via the [`gen_ai`] module, enabling compatibility with both OpenInference and OTel backends.
28
29pub mod attributes;
30pub mod gen_ai;
31mod span_kind;
32
33pub use span_kind::SpanKind;
34
35/// Re-export commonly used items
36pub mod prelude {
37 pub use crate::attributes;
38 pub use crate::gen_ai;
39 pub use crate::SpanKind;
40}