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

Add OTLP log endpoint to convert log events to span annotations #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

making
Copy link
Collaborator

@making making commented Dec 23, 2024

This is the first pull request that fixes gh-21.
More use case tests, optimizations and options will be added later.

How to check UI locally

# Build the docker image
build-bin/docker/docker_build openzipkin-contrib/zipkin-otel:test
# Run the docker image
docker run --rm -p 9411:9411 docker.io/openzipkin-contrib/zipkin-otel:test

Run the example script using OpenAI+Python

cd collector-http/src/test/resources/python

python3 -m venv .venv
source .venv/bin/activate
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:9411
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true
export OPENAI_API_KEY=sk-YOUR_API_KEY
./run.sh
cd -

Run the example script using OpenAI+NodeJs

cd collector-http/src/test/resources/nodejs

export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:9411
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true
export OPENAI_API_KEY=sk-YOUR_API_KEY
./run.sh
cd -

a screenshot and trace data is attached here

@@ -0,0 +1,3130 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is just an example, maybe add .npmrc with "package-lock=false"?

Copy link
Contributor

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

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

pretty cool to do real integration tests (with python and js), though maybe it could be less maintenance to send these signals directly in the integration test with otel java libs.

I don't recall the current state of java and the otel logs api, but yeah pretty sure it can be done directly.

This sort of change is optional until maintaining the examples becomes troublesome. Also, we can drop one of the example languages if the other becomes a problem.

Aside: one configuration I would expect to come quickly is to use solely the "event.name" as the annotation value, so like probably via ENV.

Finally, seems like this is really getting to the point where we need a README, to describe how each signal is translated. e.g. traces (translated) metrics (dropped) logs (recorded as annotations if have a span context and event name)

@Consumes("application/json")
@Produces("application/json")
public Map<String, Object> handleChatCompletion(String requestBody) {
Map<String, Object> response = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure it works, but prefer Map.of stuff if it is usable. that or just a multi-line json literal. We can use a later JDK in tests than we do for the compiled binary (floor JRE version). This can be done later.

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.

Add OTLP log endpoint to convert log events to span annotations
2 participants