Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build instrumentation-genai/README.md #3400

Merged
merged 5 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions instrumentation-genai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

| Instrumentation | Supported Packages | Metrics support | Semconv status |
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious why only one signal type "Metrics" is listed there. Would it make sense to list all of the signal types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same format as the other instrumentations, no idea what the original intent but here we are just running the same thing on another dir.

| --------------- | ------------------ | --------------- | -------------- |
| [opentelemetry-instrumentation-google-genai](./opentelemetry-instrumentation-google-genai) | google-genai >= 1.0.0 | No | development
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not correct that the google-genai instrumentation does not include metrics. That code emits client metrics for Gen AI. See:

Copy link
Contributor Author

@xrmx xrmx Apr 3, 2025

Choose a reason for hiding this comment

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

Sorry, care to update package.py like I did for openai ? It would be faster to have me approve and merge :)

| [opentelemetry-instrumentation-openai-v2](./opentelemetry-instrumentation-openai-v2) | openai >= 1.26.0 | Yes | development
| [opentelemetry-instrumentation-vertexai](./opentelemetry-instrumentation-vertexai) | google-cloud-aiplatform >= 1.64 | No | development
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

_instruments = ("google-genai >= 1.0.0",)
Copy link
Contributor

Choose a reason for hiding this comment

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

There now appear to be multiple places where this information exists:

Is there a way to have a single source of truth for this information?

For example, can instrumentor.py be updated to load the value from package.py? Can the optional dependency in pyproject.toml somehow dynamically reference this value? Or is there some other way to keep these in sync?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is probably a way in hatch so use a dynamic value, maybe https://hatch.pypa.io/1.13/how-to/config/dynamic-metadata/

Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@


_instruments = ("openai >= 1.26.0",)

_supports_metrics = True
13 changes: 8 additions & 5 deletions scripts/generate_instrumentation_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
| --------------- | ------------------ | --------------- | -------------- |"""


def main():
root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
base_instrumentation_path = os.path.join(root_path, "instrumentation")

def main(base_instrumentation_path):
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the package.py files exist solely for the purpose of supporting this?

If so, I'm wondering if it might sense to use some other data format (e.g. metadata.yaml or something else) that will make it more obvious that it is not part of the instrumentation package and just information about the instrumentation package that is used for this kind of purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used by most of the Instrumentor classes to implement instrumentation_dependencies and so used to catch dependency conflicts.

Copy link
Member

Choose a reason for hiding this comment

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

@michaelsafyan also used by instrumentors.

table = [header]
for instrumentation in sorted(os.listdir(base_instrumentation_path)):
instrumentation_path = os.path.join(
Expand Down Expand Up @@ -85,4 +82,10 @@ def main():


if __name__ == "__main__":
main()
root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
instrumentation_path = os.path.join(root_path, "instrumentation")
main(instrumentation_path)
genai_instrumentation_path = os.path.join(
root_path, "instrumentation-genai"
)
main(genai_instrumentation_path)