Skip to content

I cannot successfully get metric using the Java SDK. #18

Description

@CainGao

Hello, I am currently using the service of version v3.148.0. I want to obtain the metric information such as totalTokens, totalObservations, totalTraces through the Java SDK. However, I cannot successfully get it using the Java SDK. Could you please write a simple example for me? How should I implement this?

like : http://langfuse.eaydu.com/api/trpc/users.metrics?input=

response:
{"result":{"data":{"json":[{"userId":"rtnpe","environment":"default","firstTrace":"2026-01-21T03:56:27.184Z","lastTrace":"2026-01-21T07:39:59.604Z","totalPromptTokens":"5513","totalCompletionTokens":"528","totalTokens":"6041","totalObservations":"12","totalTraces":"7","sumCalculatedTotalCost":6569},{"userId":"test","environment":"default","firstTrace":"2026-01-23T03:48:03.822Z","lastTrace":"2026-01-23T07:04:11.190Z","totalPromptTokens":"0","totalCompletionTokens":"0","totalTokens":"0","totalObservations":"4","totalTraces":"2","sumCalculatedTotalCost":0},{"userId":"agent-evaluator","environment":"default","firstTrace":"2026-01-16T10:47:30.394Z","lastTrace":"2026-01-16T10:47:37.402Z","totalPromptTokens":"23912","totalCompletionTokens":"653","totalTokens":"24565","totalObservations":"4","totalTraces":"2","sumCalculatedTotalCost":25218},{"userId":"agentFrameGO","environment":"default","firstTrace":"2026-01-16T11:15:30.637Z","lastTrace":"2026-01-23T07:07:20.554Z","totalPromptTokens":"85764","totalCompletionTokens":"127","totalTokens":"85891","totalObservations":"16","totalTraces":"11","sumCalculatedTotalCost":86018}],"meta":{"values":{"0.firstTrace":["Date"],"0.lastTrace":["Date"],"0.totalPromptTokens":["bigint"],"0.totalCompletionTokens":["bigint"],"0.totalTokens":["bigint"],"0.totalObservations":["bigint"],"0.totalTraces":["bigint"],"1.firstTrace":["Date"],"1.lastTrace":["Date"],"1.totalPromptTokens":["bigint"],"1.totalCompletionTokens":["bigint"],"1.totalTokens":["bigint"],"1.totalObservations":["bigint"],"1.totalTraces":["bigint"],"2.firstTrace":["Date"],"2.lastTrace":["Date"],"2.totalPromptTokens":["bigint"],"2.totalCompletionTokens":["bigint"],"2.totalTokens":["bigint"],"2.totalObservations":["bigint"],"2.totalTraces":["bigint"],"3.firstTrace":["Date"],"3.lastTrace":["Date"],"3.totalPromptTokens":["bigint"],"3.totalCompletionTokens":["bigint"],"3.totalTokens":["bigint"],"3.totalObservations":["bigint"],"3.totalTraces":["bigint"]},"referentialEqualities":{"1.totalPromptTokens":["1.totalCompletionTokens","1.totalTokens"],"1.totalObservations":["2.totalObservations"],"1.totalTraces":["2.totalTraces"]}}}}}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions