Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#70742 feat(newrelic-node): Add type def ne…
Browse files Browse the repository at this point in the history
…wrelic node by @saileshtummepalli

Co-authored-by: saileshtummepalli <[email protected]>
  • Loading branch information
saileshtummepalli and saileshtummepalli authored Oct 11, 2024
1 parent 8437174 commit a488123
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions types/newrelic/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,3 +552,23 @@ export interface TraceMetadata {
*/
spanId?: string | undefined;
}
/**
* Run a function with the passed in LLM context as the active context and return its return value.
*
* See documentation for `withLlmCustomAttributes` for more information on setting custom attributes.
*/

export function withLlmCustomAttributes<T>(
attrs: Record<string, number | string | boolean>,
cb: (...args: any[]) => T,
): T;

/**
* Registers a callback which will be used for calculating token counts on Llm events when they are not available.
*
* See documentation for `setLlmTokenCountCallback` for more information on setting custom attributes.
*/

export function setLlmTokenCountCallback<T>(
cb: (...args: any[]) => T,
): T;
3 changes: 3 additions & 0 deletions types/newrelic/newrelic-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,6 @@ newrelic.setLambdaHandler((event: unknown, context: unknown) => ({ statusCode: 2
newrelic.setLambdaHandler({ some: "object" });

newrelic.obfuscateSql("SELECT * FROM USERS", "postgres"); // $ExpectType string
newrelic.withLlmCustomAttributes({ task: "question" }, () => void 0);

newrelic.setLlmTokenCountCallback(() => void 0);

0 comments on commit a488123

Please sign in to comment.