Skip to content

Commit

Permalink
feat: sample logs
Browse files Browse the repository at this point in the history
  • Loading branch information
joschkabraun committed Aug 12, 2024
1 parent 4c44f31 commit e39e842
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type Completion = {
log_omit_inputs?: boolean;
log_omit_outputs?: boolean;
log_omit?: boolean;
log_sample_rate?: number;
experiment_uuid?: string | null;
project_uuid?: string;
};
Expand Down Expand Up @@ -164,6 +165,7 @@ export type TraceLog = EvaluatedLog & {
deployment_id?: string;
output_for_eval_metrics?: string;
apply_eval_frac?: number;
log_sample_rate?: number;
cache_hit?: boolean;
evaluation_metric_names?: string[];
feedback_score?: number;
Expand Down Expand Up @@ -197,6 +199,7 @@ export type TraceOptions = {
applyEvalFrac?: number;
deploymentId?: string;
target?: string;
logSampleRate?: number;
};

export type UpdateLog = {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/core/Trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Trace {
executionOrder: number = 0,
) {
this.evalFuncs = options?.evalFuncs || [];
const { endUserIdentifier, sessionId, deploymentId, ...opts } = options || {};
const { endUserIdentifier, sessionId, deploymentId, logSampleRate, ...opts } = options || {};

this.id = genTraceId();
this.name = name;
Expand All @@ -56,6 +56,7 @@ export class Trace {
root_trace_id: this.rootId,
children: this.children,
end_user_identifier: endUserIdentifier,
log_sample_rate: logSampleRate,
session_id: sessionId,
deployment_id: deploymentId,
...opts,
Expand Down
4 changes: 4 additions & 0 deletions src/utils/core/TraceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export class TraceManager {
options.target = parentTarget;
}

if (parentTrace && parentTrace.getLog().log_sample_rate !== options.logSampleRate) {
options.logSampleRate = parentTrace.getLog().log_sample_rate;
}

const trace = new Trace(name, options, parentId, rootId, depth, executionOrder);

if (parentTrace) {
Expand Down

0 comments on commit e39e842

Please sign in to comment.