Skip to content

howieleung/tracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Let's say we have this function

function post(request: Request): Response {
    return getClient().post(request);
}

To add tracing with request.model and response.result as span attributes, we will do this:

function post(request: Request): Response {

    const impl = () => getClient().post(request);

    // the mappers are optional.
    return trace(arguments, impl, requestMapper, responseMapper);
}

function requestMapper(args: IArguments): Map<string, any> {
    const map = new Map<string, any>();
    map.set("gen.ai.request.model", args[0].model);
    return map;
}

function responseMapper(response: Response): Map<string, any> {
    const map = new Map<string, any>();
    map.set("gen.ai.request.result", response.result);
    return map;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published