Skip to content

Conversation

wrisa
Copy link
Owner

@wrisa wrisa commented Jul 15, 2025

Description

Created gen-AI APIs which can be used to produce semantic conventions compatible telemetry.
This POC demonstrates langchain instrumentation using the gen-AI API for llm invocation see callback_handler.py(on_chat_model_start and on_llm_end).
There are 2 different telemetry creations, SpanMetricExporter(no events instead content on Span) and SpanMetricEventExporter(can be selected using OTEL_INSTRUMENTATION_GENAI_EXPORTER).
Types can be defined in types.py for particular invocation which will be then created by the API(api.py) and passed to the exporter to produce semantic conventions compatible telemetry.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@wrisa wrisa changed the title Added sdk support for llm invocation Gen-AI api for llm invocation Jul 15, 2025
@wrisa wrisa changed the title Gen-AI api for llm invocation Gen-AI APIs for llm invocation(from langchain) (POC) Jul 15, 2025
@wrisa wrisa changed the title Gen-AI APIs for llm invocation(from langchain) (POC) Semantic conventions compatible gen-AI APIs(POC) Jul 15, 2025
@wrisa wrisa changed the title Semantic conventions compatible gen-AI APIs(POC) New Gen-AI APIs creating semantic conventions compatible telemetry (POC) Jul 16, 2025
Copy link

@pmcollins pmcollins left a comment

Choose a reason for hiding this comment

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

Addressing topics relating to eval/instrumentation functionality (not the Langchain instrumentor).

"opentelemetry-instrumentation ~= 0.51b0",
"opentelemetry-semantic-conventions ~= 0.51b0",
"opentelemetry-api>=1.31.0",
"opentelemetry-sdk>=1.31.0",

Choose a reason for hiding this comment

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

Can we make this package independent of the SDK (as the other instrumentors are)? If there's SDK functionality that needs to be supplied as part of this effort, it could live in a separate package (maybe even in our distro).

Choose a reason for hiding this comment

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

I'm concerned about confusion around the use of the name exporter, which has a meaning in OTel that differs from this one. Should we think of another name? Maybe something like Handler, Recorder, Adaptor, Emitter...

)
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter

from opentelemetry.sdk._events import EventLoggerProvider

Choose a reason for hiding this comment

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

Unfortunately, the events api is going away. Can this be migrated to use the logs api?

Choose a reason for hiding this comment

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

I'm concerned about confusion around the names "sdk" and "api" here as they are fundamental to OTel and have well-established, specific meanings. If the meanings here are different, that might cause confusion. For example, in OTel, the API is independent and has no knowledge of the SDK.

@wrisa wrisa changed the title New Gen-AI APIs creating semantic conventions compatible telemetry (POC) New Gen-AI utils APIs creating semantic conventions compatible telemetry (POC) Jul 28, 2025
Repository owner deleted a comment from shuningc Aug 12, 2025
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.

2 participants