Skip to content

feat: add telemetry #354

Closed
Closed

Description

@akihikokuroda

Instrument telemetry (OpenTelemetry).

Telemetry (tracing) is useful to debug Mellea library and applications.

Activity

  1. akihikokuroda commented on Jan 23, 2026

    @akihikokuroda
    ContributorAuthor

    Here is the example (trace output is routed to the console in this):

     uv run  docs/examples/hello_world.py           
          Built mellea @ file:///Users/akihikokuroda/development/repositories/generative-computing/mellea
    Uninstalled 1 package in 2ms
    Installed 1 package in 2ms
    === 15:28:35-INFO ======
    Starting Mellea session: backend=ollama, model=granite4:micro, context=SimpleContext
      0%|                                                                                                                                                                               | 0/2 [00:00<?, ?it/s]{
        "name": "start_session",
        "context": {
            "trace_id": "0x2edc05a6e88c3d7ab29f585f44697b45",
            "span_id": "0xb65a62848709546d",
            "trace_state": "[]"
        },
        "kind": "SpanKind.INTERNAL",
        "parent_id": null,
        "start_time": "2026-01-23T20:28:35.349356Z",
        "end_time": "2026-01-23T20:28:35.549029Z",
        "status": {
            "status_code": "UNSET"
        },
        "attributes": {
            "backend": "ollama",
            "model_id": "granite4:micro",
            "context_type": "SimpleContext"
        },
        "events": [],
        "links": [],
        "resource": {
            "attributes": {
                "telemetry.sdk.language": "python",
                "telemetry.sdk.name": "opentelemetry",
                "telemetry.sdk.version": "1.38.0",
                "service.name": "mellea"
            },
            "schema_url": ""
        }
    }
    {
        "name": "generate_from_context",
        "context": {
            "trace_id": "0x846025640a571b65e619b5a508fb7664",
            "span_id": "0x82f9edab86df1943",
            "trace_state": "[]"
        },
        "kind": "SpanKind.INTERNAL",
        "parent_id": "0xcb4c373d9d59443d",
        "start_time": "2026-01-23T20:28:35.556250Z",
        "end_time": "2026-01-23T20:28:35.576410Z",
        "status": {
            "status_code": "UNSET"
        },
        "attributes": {
            "backend": "OllamaModelBackend",
            "model_id": "ibm-granite/granite-4.0-micro",
            "action_type": "Instruction",
            "context_size": "0",
            "has_format": "False",
            "tool_calls": "False"
        },
        "events": [],
        "links": [],
        "resource": {
            "attributes": {
                "telemetry.sdk.language": "python",
                "telemetry.sdk.name": "opentelemetry",
                "telemetry.sdk.version": "1.38.0",
                "service.name": "mellea"
            },
            "schema_url": ""
        }
    }
    === 15:28:42-INFO ======
    SUCCESS
      0%|                                                                                                                                                                               | 0/2 [00:06<?, ?it/s]
    Subject: Invitation for Our Upcoming Team Lunch Party
    
    Dear Interns,
    
    I hope this message finds you well. 
    
    We would like to extend a cordial invitation to all our valued interns for a special event that we are hosting - A Team Lunch Party. This will be an excellent opportunity for us to get to know each other better, discuss projects in more detail, and share some personal experiences.
    
    The date of the event is [insert date], starting at [insert start time]. We plan on having a relaxed, informal setting where everyone can mingle and enjoy a good meal together. 
    
    Please note that it's not mandatory for you to attend this event, as we understand your schedules may be quite busy with coursework or other commitments. However, we strongly encourage each of you to participate in order to enhance our collaborative spirit and the overall work environment at our company.
    
    The venue for the lunch party will be [insert location]. Please let us know if you plan on attending by replying to this email by [insert date], so that we can make necessary arrangements. 
    
    We look forward to a wonderful time together!
    
    Best Regards,
    
    [Your Name]
    [Your Position]
    {
        "name": "aact",
        "context": {
            "trace_id": "0x846025640a571b65e619b5a508fb7664",
            "span_id": "0xcb4c373d9d59443d",
            "trace_state": "[]"
        },
        "kind": "SpanKind.INTERNAL",
        "parent_id": null,
        "start_time": "2026-01-23T20:28:35.549239Z",
        "end_time": "2026-01-23T20:28:42.252668Z",
        "status": {
            "status_code": "UNSET"
        },
        "attributes": {
            "action_type": "Instruction",
            "has_requirements": "False",
            "has_strategy": "True",
            "strategy_type": "RejectionSamplingStrategy",
            "has_format": "False",
            "tool_calls": "False",
            "num_generate_logs": "1",
            "sampling_success": "True",
            "response": "Subject: Invitation for Our Upcoming Team Lunch Party\n\nDear Interns,\n\nI hope this message finds you well. \n\nWe would like to extend a cordial invitation to all our valued interns for a special event that we are hosting - A Team Lunch Party. This will be an excellent opportunity for us to get to know each other better, discuss projects in more detail, and share some personal experiences.\n\nThe date of the event is [insert date], starting at [insert start time]. We plan on having a relaxed, informa...",
            "response_length": "1157"
        },
        "events": [],
        "links": [],
        "resource": {
            "attributes": {
                "telemetry.sdk.language": "python",
                "telemetry.sdk.name": "opentelemetry",
                "telemetry.sdk.version": "1.38.0",
                "service.name": "mellea"
            },
            "schema_url": ""
        }
    }
    
  2. akihikokuroda commented on Jan 24, 2026

    @akihikokuroda
    ContributorAuthor

    I saw #277. May I keep working on it? Most of backends (OpenAI, Ollama, LiteLLM, vLLM, etc..) have integration or capable to with OpenTelemetry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions