Closed gyliu513 closed 10 months ago
@gyliu513 I've found a way to resolve this, by optimizing the instrumentation code, now only 2 lines of code are required. https://github.com/gyliu513/langX101/blob/37bc0a990b558d331f0269ccc78f8b56ba2a9c21/otel/opentelemetry-instrumentation-langchain/opentelemetry/instrumentation/langchain/watsonx-langchain-simplify.py#L7-L18
Basically instead of letting the end user to perform those opentelemetry tracing/metering related routine code, I now use our Instrumentor to do it.
@huang-cn can we use decorate for this code?
@gyliu513 as we've discussed this morning, using the decorator to wrap customer method/function is difficult for us to capture useful information because the feature/input/output of the customer method are unknown.
If you take a look at langSmith https://docs.smith.langchain.com/ , it is using decorator to enable tracing.
For the otel code here https://github.com/gyliu513/langX101/blob/main/otel/watsonx-programatic/watsonx-instrument.py#L1-L52 , we also need a decorator to enable customer do not need to always write those preparation code but use decorator to enable tracing with otel.