Skip to content

Conversation

@kxzk
Copy link
Contributor

@kxzk kxzk commented Nov 7, 2025

Summary

  • Implements comprehensive type definitions for Langfuse observations and traces
  • Adds attribute classes with validation and serialization support
  • Provides constants for observation types and severity levels

Changes

  • New: lib/langfuse/types.rb (335 lines)

    • OBSERVATION_TYPES constant: 10 observation types (span, generation, event, embedding, agent, tool, chain, retriever, evaluator, guardrail)
    • LEVELS constant: 4 severity levels (DEBUG, DEFAULT, WARNING, ERROR)
    • SpanAttributes class: Base class with 7 configurable attributes
    • GenerationAttributes class: Extends SpanAttributes with 6 LLM-specific fields
    • EmbeddingAttributes class: Extends GenerationAttributes for embedding calls
    • TraceAttributes class: 11 trace-level attributes
    • Aliases for 7 other observation types (Event, Agent, Tool, Chain, Retriever, Evaluator, Guardrail)
  • New: spec/langfuse/types_spec.rb (379 lines)

    • Complete test coverage for all type definitions
    • Tests for initialization, attribute access, and serialization
    • Tests for inheritance and aliasing
  • Modified: lib/langfuse.rb - Added require for types module

  • Modified: .gitignore - Added internal dev files

Design

All attribute classes follow a consistent pattern:

  • Keyword argument initialization
  • Accessor methods for all fields
  • #to_h method that excludes nil values (for clean API payloads)

Test Coverage

100% coverage of types module (379 lines of specs testing all classes, constants, and methods)

References

Closes #6

@kxzk kxzk marked this pull request as ready for review November 7, 2025 12:55
Copilot AI review requested due to automatic review settings November 7, 2025 12:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a comprehensive type system for the Langfuse Ruby SDK, adding attribute classes and constants for observations and traces. The implementation follows Ruby best practices with proper inheritance, documentation, and comprehensive test coverage.

  • Adds Langfuse::Types module with observation type and severity level constants
  • Introduces attribute classes (SpanAttributes, GenerationAttributes, EmbeddingAttributes, TraceAttributes) with proper inheritance
  • Provides extensive test coverage for all new types and their behaviors

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
lib/langfuse/types.rb Core implementation of the Types module with constants and attribute classes for spans, generations, embeddings, and traces
spec/langfuse/types_spec.rb Comprehensive test coverage for all type constants and attribute classes including inheritance and serialization
lib/langfuse.rb Updated to require the new types module
.gitignore Added entries to ignore development artifacts (langfuse-js/, AGENTS.md)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kxzk kxzk force-pushed the feature/type-definitions branch from c270a93 to 4dfc09b Compare November 7, 2025 12:57
@kxzk kxzk force-pushed the feature/type-definitions branch from c7c1b95 to 7177439 Compare November 7, 2025 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Langfuse::Types module with observation types and attribute classes

1 participant