Skip to content

Instantly share code, notes, and snippets.

View lmolkova's full-sized avatar

Liudmila Molkova lmolkova

View GitHub Profile
@lmolkova
lmolkova / GenAIEventsILogger.cs
Last active October 16, 2024 22:50
.NET events
private string GetFinishReason(ChatFinishReason finishReason) => finishReason switch
{
ChatFinishReason.Stop => "stop",
ChatFinishReason.Length => "length",
ChatFinishReason.ToolCalls => "tool_calls",
// ...
_ => finishReason.ToString(),
};
private void LogChoice(ChatCompletion message)
import json
import os
import time
from typing import override
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
#HTTPXClientInstrumentor().instrument()
from openai import AssistantEventHandler
from openai.types.beta.threads.runs import RunStep
public class Main {
public static void main(String[] args) throws IOException {
var logProvider = SdkLoggerProvider.builder()
.addLogRecordProcessor(SimpleLogRecordProcessor.create(OtlpGrpcLogRecordExporter.getDefault())).build();
EventLoggerProvider eventLoggerProvider = SdkEventLoggerProvider.create(logProvider);
var logger = eventLoggerProvider.get("test-logger");
var event = new GenAIChoice()
.setId(1)
let get_role = (event_name:string) {
iff(event_name == "gen_ai.choice", "assistant", split(event_name, ".")[1])
};
let gen_ai_spans = dependencies
| where isnotnull(customDimensions["gen_ai.system"])
| project
operation_ParentId,
operation_Id,
id,
duration,
@lmolkova
lmolkova / openai_try_events.py
Created August 28, 2024 00:48
Python events openai
# set OPENAI_API_KEY
# install otel-api and otel-sdk from main
# install opentelemetry-instrumentation-openai from https://github.com/lmolkova/opentelemetry-python-contrib/tree/openai-events
from time import time_ns
from openai import OpenAI
from typing import Optional
from opentelemetry import trace, _logs, _events
import opentelemetry.sdk
@lmolkova
lmolkova / README.md
Last active June 3, 2024 21:39
Writing log-based event with Python logging API

Prereqs

  • opentelemetry-sdk, azure-monitor-opentelemetry-exporter
  • set APPLICATIONINSIGHTS_CONNECTION_STRING (or remove AzMon exporter)

Result

image
@lmolkova
lmolkova / micrometer_questions.md
Last active April 16, 2024 01:29
Micrometer question

What's Micrometer story for library owners

  • Which one to use Otel or Micrometer. Why?
  • Semantic conventions - how users can pick which ones they want? will libs need to provide all possible options?
  • What's the story in other languages/ecosystems? I need my python messaging consumer to be consistent with my java messaging producer.
  • Which libraries beyond Spring are all-in on Micrometer?
  • How do you prioritize features? What if something is missing? (E.g. structured events on spans, adding link after span creation, etc)
    • is Micrometer targeting feature-parity with OTel specification? Will micrometer introduce profling API?
  • How big is the community? Are there community calls? Who makes decisions?
@lmolkova
lmolkova / eh_forwarding_performance.md
Last active February 13, 2024 02:29
Load testing event fan-out scenario with Azure Event Hubs SDK for Java
@lmolkova
lmolkova / sb_perf_binder.md
Last active January 3, 2024 20:54
ServiceBus binder processor perf testing

Checking ServiceBusProcessorClient performance (via Spring binder)

Setup

Tested processor performance in the following setup:

image

Sender sends up to 4k messages per second in batches. Message size is 12 bytes.