Skip to content
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

[Go] Replaced local trace store with telemetry server store. #1214

Merged
merged 3 commits into from
Nov 11, 2024
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
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
Loading