Conversation
src/otel/exporter.ts
Outdated
| await this.shutdown(); | ||
| } | ||
|
|
||
| private completeFlowLog(spanId: string) { |
There was a problem hiding this comment.
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.
src/otel/helpers.ts
Outdated
| */ | ||
| export function generateSpanId(): string { | ||
| return uuidv4(); | ||
| return span.name.startsWith("humanloop."); |
src/otel/processor.ts
Outdated
| 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.
"humanloop.flow" should be a const
src/otel/processor.ts
Outdated
| // All children/ instrumentor spans have arrived, we can process the | ||
| // All instrumentor spans have arrived, we can process the | ||
| // Humanloop parent span owning them | ||
| if (span.name === "humanloop.flow") { |
src/utilities/flow.ts
Outdated
| 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.
do these not need to be unique?
(should be a const)
There was a problem hiding this comment.
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
|
|
||
| // @ts-ignore | ||
| return opentelemetryTracer.startActiveSpan(generateSpanId(), async (span) => { | ||
| return opentelemetryTracer.startActiveSpan("humanloop.prompt", async (span) => { |
There was a problem hiding this comment.
humanloop.prompt should be a const
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.
what's the tsignore doing?
There was a problem hiding this comment.
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.
noob question - why notifySpanUploaded and not e.g. markSpanCompleted. Is notify OT jargon?
There was a problem hiding this comment.
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.
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.
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
olehvell-h
left a comment
There was a problem hiding this comment.
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.promptorhumanloop.flow. This is also more dogmatic with how OT does things