langfuse / langfuse/langfuse-java

I cannot successfully get metric using the Java SDK.

Open
#18 1 comment 0 reactions 1 assignee View on GitHub

@Steffen911 is already working on this.

Since Jan 23, 2026.

Dominant language
Java
Stars
73
Forks
14
Avg merge
13h 54m
Merged PRs (30d)
3

Description

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"]}}}}}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.