-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow complete fix #9
Conversation
src/otel/exporter.ts
Outdated
@@ -69,6 +72,19 @@ export class HumanloopSpanExporter implements SpanExporter { | |||
await this.shutdown(); | |||
} | |||
|
|||
private completeFlowLog(spanId: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs more comments and a docstring.
this is doing a lot - mutating this.prerequisite
's values, conditionally doing many things (the delete and the update). hard to follow/check if there are bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack fixed
src/otel/helpers.ts
Outdated
*/ | ||
export function generateSpanId(): string { | ||
return uuidv4(); | ||
return span.name.startsWith("humanloop."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be a const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
src/otel/processor.ts
Outdated
} | ||
|
||
async forceFlush(): Promise<void> {} | ||
|
||
onStart(span: Span, _: Context): void { | ||
const spanId = span.spanContext().spanId; | ||
const parentSpanId = span.parentSpanId; | ||
if (span.name === "humanloop.flow") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"humanloop.flow" should be a const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
src/otel/processor.ts
Outdated
// Humanloop parent span owning them | ||
if (span.name === "humanloop.flow") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be a const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
src/utilities/flow.ts
Outdated
@@ -39,30 +38,9 @@ export function flowUtilityFactory<I, M, O>( | |||
const parentSpanContextKey = createContextKey(HUMANLOOP_PARENT_SPAN_CTX_KEY); | |||
const flowMetadataKey = createContextKey(HUMANLOOP_TRACE_FLOW_CTX_KEY); | |||
// @ts-ignore | |||
return opentelemetryTracer.startActiveSpan(generateSpanId(), async (span) => { | |||
return opentelemetryTracer.startActiveSpan("humanloop.flow", async (span) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do these not need to be unique?
(should be a const)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've realized it's not necessary. The name is supposed to hint at the type of span you're looking at, which I'm leveraging in the processor-exporter to complete the trace.
https://opentelemetry.io/docs/specs/semconv/http/http-spans/#name
src/utilities/prompt.ts
Outdated
@@ -61,28 +60,9 @@ export function promptUtilityFactory<I, M, O>( | |||
const flowMetadataKey = createContextKey(HUMANLOOP_TRACE_FLOW_CTX_KEY); | |||
|
|||
// @ts-ignore | |||
return opentelemetryTracer.startActiveSpan(generateSpanId(), async (span) => { | |||
return opentelemetryTracer.startActiveSpan("humanloop.prompt", async (span) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
humanloop.prompt should be a const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
src/utilities/prompt.ts
Outdated
output = await func(inputs, messages); | ||
} catch (err: any) { | ||
console.error(`Error calling ${func.name}:`, err); | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the tsignore doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to be a leftover, removed
src/otel/exporter.ts
Outdated
* | ||
* @param spanId - The ID of the span that has been uploaded. | ||
*/ | ||
private notifySpanUploaded(spanId: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noob question - why notifySpanUploaded
and not e.g. markSpanCompleted
. Is notify OT jargon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair point will change - no OT jargon, just bad taste on my side
if (span.name === HUMANLOOP_FLOW_SPAN_NAME) { | ||
this.prerequisites.set(spanId, []); | ||
} | ||
if (parentSpanId !== undefined && isHumanloopSpan(span)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noob question - (parentSpanId !== undefined && isHumanloopSpan(span))
this is to check if it's a span from flow child ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep - i am building a flat list of all logs found inside a trace. this list is passed as an attribute on the flow log span to the expoter. when they're all uploaded, the flow log is also marked as complete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good... to the extent of my OT knowledge 😅
Side point: We as a team (and I personally), need a bit of learning on OT. It takes mental energy to understand OT-specific jargon and details before focusing on code-related matters.
Thank you for writing PR description and " Please assign yourself as a reviewer if you have the time." - like this bit
humanloop.prompt
orhumanloop.flow
. This is also more dogmatic with how OT does things