Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions go/core/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"github.com/firebase/genkit/go/core/logger"
"github.com/firebase/genkit/go/core/tracing"
"github.com/firebase/genkit/go/gtime"
"github.com/firebase/genkit/go/internal"
"github.com/google/uuid"
otrace "go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -172,7 +171,7 @@ type flowState[I, O any] struct {
FlowID string `json:"flowId,omitempty"`
FlowName string `json:"name,omitempty"`
// start time in milliseconds since the epoch
StartTime gtime.Milliseconds `json:"startTime,omitempty"`
StartTime tracing.Milliseconds `json:"startTime,omitempty"`
Input I `json:"input,omitempty"`

mu sync.Mutex
Expand All @@ -189,7 +188,7 @@ func newFlowState[I, O any](id, name string, input I) *flowState[I, O] {
FlowID: id,
FlowName: name,
Input: input,
StartTime: gtime.ToMilliseconds(time.Now()),
StartTime: tracing.ToMilliseconds(time.Now()),
Cache: map[string]json.RawMessage{},
Operation: &operation[O]{
FlowID: id,
Expand Down Expand Up @@ -352,7 +351,7 @@ func (f *Flow[I, O, S]) execute(ctx context.Context, state *flowState[I, O], dis
}()
ctx = flowContextKey.NewContext(ctx, fctx)
exec := &flowExecution{
StartTime: gtime.ToMilliseconds(time.Now()),
StartTime: tracing.ToMilliseconds(time.Now()),
}
state.mu.Lock()
state.Executions = append(state.Executions, exec)
Expand Down
8 changes: 4 additions & 4 deletions go/core/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package core

import "github.com/firebase/genkit/go/gtime"
import "github.com/firebase/genkit/go/core/tracing"

type flowError struct {
Error string `json:"error,omitempty"`
Expand All @@ -25,8 +25,8 @@ type flowError struct {

type flowExecution struct {
// end time in milliseconds since the epoch
EndTime gtime.Milliseconds `json:"endTime,omitempty"`
EndTime tracing.Milliseconds `json:"endTime,omitempty"`
// start time in milliseconds since the epoch
StartTime gtime.Milliseconds `json:"startTime,omitempty"`
TraceIDs []string `json:"traceIds,omitempty"`
StartTime tracing.Milliseconds `json:"startTime,omitempty"`
TraceIDs []string `json:"traceIds,omitempty"`
}
6 changes: 3 additions & 3 deletions go/core/schemas.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file holds configuration for the genkit-schema.json file
# generated by the npm export:schemas script.

core import github.com/firebase/genkit/go/gtime
core import github.com/firebase/genkit/go/core/tracing

# DocumentData type was hand-written.
DocumentData omit
Expand Down Expand Up @@ -67,8 +67,8 @@ FlowInvokeEnvelopeMessageRunScheduled omit
Operation omit

FlowStateExecution name flowExecution
FlowStateExecution.startTime type gtime.Milliseconds
FlowStateExecution.endTime type gtime.Milliseconds
FlowStateExecution.startTime type tracing.Milliseconds
FlowStateExecution.endTime type tracing.Milliseconds

FlowError name flowError

Expand Down
2 changes: 1 addition & 1 deletion go/gtime/gtime.go → go/core/tracing/milliseconds.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

// Package gtime provides time functionality for Go Genkit.
package gtime
package tracing

import "time"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package gtime
package tracing

import (
"testing"
Expand Down
11 changes: 5 additions & 6 deletions go/core/tracing/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"errors"

"github.com/firebase/genkit/go/gtime"
)

// A Store stores trace information.
Expand Down Expand Up @@ -61,8 +60,8 @@ type Query struct {
type Data struct {
TraceID string `json:"traceId"`
DisplayName string `json:"displayName"`
StartTime gtime.Milliseconds `json:"startTime"`
EndTime gtime.Milliseconds `json:"endTime"`
StartTime Milliseconds `json:"startTime"`
EndTime Milliseconds `json:"endTime"`
Spans map[string]*SpanData `json:"spans"`
}

Expand All @@ -75,8 +74,8 @@ type SpanData struct {
SpanID string `json:"spanId"`
TraceID string `json:"traceId,omitempty"`
ParentSpanID string `json:"parentSpanId,omitempty"`
StartTime gtime.Milliseconds `json:"startTime"`
EndTime gtime.Milliseconds `json:"endTime"`
StartTime Milliseconds `json:"startTime"`
EndTime Milliseconds `json:"endTime"`
Attributes map[string]any `json:"attributes,omitempty"`
DisplayName string `json:"displayName"`
Links []*Link `json:"links,omitempty"`
Expand All @@ -97,7 +96,7 @@ type BoolValue struct {
}

type TimeEvent struct {
Time gtime.Milliseconds `json:"time,omitempty"`
Time Milliseconds `json:"time,omitempty"`
Annotation Annotation `json:"annotation,omitempty"`
}

Expand Down
7 changes: 3 additions & 4 deletions go/core/tracing/trace_store_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"errors"
"strings"

"github.com/firebase/genkit/go/gtime"
"go.opentelemetry.io/otel/attribute"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
otrace "go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -89,8 +88,8 @@ func convertSpan(span sdktrace.ReadOnlySpan) *SpanData {
sd := &SpanData{
SpanID: sc.SpanID().String(),
TraceID: sc.TraceID().String(),
StartTime: gtime.ToMilliseconds(span.StartTime()),
EndTime: gtime.ToMilliseconds(span.EndTime()),
StartTime: ToMilliseconds(span.StartTime()),
EndTime: ToMilliseconds(span.EndTime()),
Attributes: attributesToMap(span.Attributes()),
DisplayName: span.Name(),
Links: convertLinks(span.Links()),
Expand Down Expand Up @@ -140,7 +139,7 @@ func convertEvents(evs []sdktrace.Event) []TimeEvent {
var tes []TimeEvent
for _, e := range evs {
tes = append(tes, TimeEvent{
Time: gtime.ToMilliseconds(e.Time),
Time: ToMilliseconds(e.Time),
Annotation: Annotation{
Description: e.Name,
Attributes: attributesToMap(e.Attributes),
Expand Down
7 changes: 3 additions & 4 deletions go/core/tracing/trace_store_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"testing"
"time"

"github.com/firebase/genkit/go/gtime"
"github.com/google/go-cmp/cmp"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
Expand Down Expand Up @@ -90,11 +89,11 @@ func TestConvertSpan(t *testing.T) {
SpanID: spanID1,
ParentSpanID: spanID2,
SpanKind: "INTERNAL",
StartTime: gtime.Milliseconds(1e3),
EndTime: gtime.Milliseconds(2e3),
StartTime: Milliseconds(1e3),
EndTime: Milliseconds(2e3),
Attributes: map[string]any{"k": "v"},
TimeEvents: TimeEvents{TimeEvent: []TimeEvent{{
Time: gtime.Milliseconds(3e3),
Time: Milliseconds(3e3),
Annotation: Annotation{
Attributes: map[string]any{"k2": "v2"},
Description: "ename",
Expand Down