Skip to content

Commit

Permalink
[Go] Replaced local trace store with telemetry server store. (#1214)
Browse files Browse the repository at this point in the history
  • Loading branch information
apascal07 authored Nov 11, 2024
1 parent 15ab59d commit b6cbd35
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 510 deletions.
12 changes: 4 additions & 8 deletions go/core/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"slices"
"testing"

"github.com/firebase/genkit/go/core/tracing"
"github.com/firebase/genkit/go/internal/atype"
"github.com/firebase/genkit/go/internal/registry"
)
Expand Down Expand Up @@ -97,21 +98,16 @@ func TestActionStreaming(t *testing.T) {
}

func TestActionTracing(t *testing.T) {
ctx := context.Background()
tc := tracing.NewTestOnlyTelemetryClient()
registry.Global.TracingState().WriteTelemetryImmediate(tc)
const actionName = "TestTracing-inc"
a := newAction(actionName, atype.Custom, nil, nil, inc)
if _, err := a.Run(context.Background(), 3, nil); err != nil {
t.Fatal(err)
}
// The dev TraceStore is registered by Init, called from TestMain.
ts := registry.Global.LookupTraceStore(registry.EnvironmentDev)
tds, _, err := ts.List(ctx, nil)
if err != nil {
t.Fatal(err)
}
// The same trace store is used for all tests, so there might be several traces.
// Look for this one, which has a unique name.
for _, td := range tds {
for _, td := range tc.Traces {
if td.DisplayName == actionName {
// Spot check: expect a single span.
if g, w := len(td.Spans), 1; g != w {
Expand Down
13 changes: 0 additions & 13 deletions go/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,10 @@
package core

import (
"context"

"github.com/firebase/genkit/go/core/tracing"
"github.com/firebase/genkit/go/internal/registry"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

// RegisterTraceStore uses the given trace.Store to record traces in the prod environment.
// (A trace.Store that writes to the local filesystem is always installed in the dev environment.)
// The returned function should be called before the program ends to ensure that
// all pending data is stored.
// RegisterTraceStore panics if called more than once.
func RegisterTraceStore(ts tracing.Store) (shutdown func(context.Context) error) {
registry.Global.RegisterTraceStore(registry.EnvironmentProd, ts)
return registry.Global.TracingState().AddTraceStoreBatch(ts)
}

// RegisterSpanProcessor registers an OpenTelemetry SpanProcessor for tracing.
func RegisterSpanProcessor(sp sdktrace.SpanProcessor) {
registry.Global.RegisterSpanProcessor(sp)
Expand Down
157 changes: 0 additions & 157 deletions go/core/tracing/file_store.go

This file was deleted.

138 changes: 0 additions & 138 deletions go/core/tracing/file_store_test.go

This file was deleted.

Loading

0 comments on commit b6cbd35

Please sign in to comment.