remove frontend wrapper

This commit is contained in:
Shreyas Goenka 2024-12-30 12:20:14 +05:30
parent 9fb2c66c4a
commit 4fc8c37376
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
4 changed files with 18 additions and 22 deletions

View File

@ -33,16 +33,13 @@ func (wrapper *apiClientWrapper) Do(ctx context.Context, method, path string,
} }
func TestTelemetryLogger(t *testing.T) { func TestTelemetryLogger(t *testing.T) {
events := []telemetry.FrontendLogEntry{ events := []telemetry.DatabricksCliLog{
{ {
DatabricksCliLog: telemetry.DatabricksCliLog{
CliTestEvent: &events.CliTestEvent{ CliTestEvent: &events.CliTestEvent{
Name: events.DummyCliEnumValue1, Name: events.DummyCliEnumValue1,
}, },
}, },
},
{ {
DatabricksCliLog: telemetry.DatabricksCliLog{
BundleInitEvent: &events.BundleInitEvent{ BundleInitEvent: &events.BundleInitEvent{
Uuid: uuid.New().String(), Uuid: uuid.New().String(),
TemplateName: "abc", TemplateName: "abc",
@ -52,7 +49,6 @@ func TestTelemetryLogger(t *testing.T) {
}, },
}, },
}, },
},
} }
assert.Equal(t, reflect.TypeOf(telemetry.DatabricksCliLog{}).NumField(), len(events), assert.Equal(t, reflect.TypeOf(telemetry.DatabricksCliLog{}).NumField(), len(events),

View File

@ -18,14 +18,16 @@ type DatabricksApiClient interface {
visitors ...func(*http.Request) error) error visitors ...func(*http.Request) error) error
} }
func Log(ctx context.Context, event FrontendLogEntry) error { func Log(ctx context.Context, event DatabricksCliLog) error {
l := fromContext(ctx) l := fromContext(ctx)
FrontendLog := FrontendLog{ FrontendLog := FrontendLog{
// The telemetry endpoint deduplicates logs based on the FrontendLogEventID. // The telemetry endpoint deduplicates logs based on the FrontendLogEventID.
// This it's important to generate a unique ID for each log event. // This it's important to generate a unique ID for each log event.
FrontendLogEventID: uuid.New().String(), FrontendLogEventID: uuid.New().String(),
Entry: event, Entry: FrontendLogEntry{
DatabricksCliLog: event,
},
} }
protoLog, err := json.Marshal(FrontendLog) protoLog, err := json.Marshal(FrontendLog)

View File

@ -68,9 +68,9 @@ func TestTelemetryLoggerFlushesEvents(t *testing.T) {
ctx := ContextWithLogger(context.Background()) ctx := ContextWithLogger(context.Background())
for _, v := range []events.DummyCliEnum{events.DummyCliEnumValue1, events.DummyCliEnumValue2, events.DummyCliEnumValue2, events.DummyCliEnumValue3} { for _, v := range []events.DummyCliEnum{events.DummyCliEnumValue1, events.DummyCliEnumValue2, events.DummyCliEnumValue2, events.DummyCliEnumValue3} {
err := Log(ctx, FrontendLogEntry{DatabricksCliLog: DatabricksCliLog{ err := Log(ctx, DatabricksCliLog{
CliTestEvent: &events.CliTestEvent{Name: v}, CliTestEvent: &events.CliTestEvent{Name: v},
}}) })
require.NoError(t, err) require.NoError(t, err)
} }
@ -102,9 +102,9 @@ func TestTelemetryLoggerFlushExitsOnTimeout(t *testing.T) {
ctx := ContextWithLogger(context.Background()) ctx := ContextWithLogger(context.Background())
for _, v := range []events.DummyCliEnum{events.DummyCliEnumValue1, events.DummyCliEnumValue2, events.DummyCliEnumValue2, events.DummyCliEnumValue3} { for _, v := range []events.DummyCliEnum{events.DummyCliEnumValue1, events.DummyCliEnumValue2, events.DummyCliEnumValue2, events.DummyCliEnumValue3} {
err := Log(ctx, FrontendLogEntry{DatabricksCliLog: DatabricksCliLog{ err := Log(ctx, DatabricksCliLog{
CliTestEvent: &events.CliTestEvent{Name: v}, CliTestEvent: &events.CliTestEvent{Name: v},
}}) })
require.NoError(t, err) require.NoError(t, err)
} }

View File

@ -124,9 +124,7 @@ func (t *Template) logTelemetry(ctx context.Context) error {
}, },
} }
return telemetry.Log(ctx, telemetry.FrontendLogEntry{ return telemetry.Log(ctx, event)
DatabricksCliLog: event,
})
} }
// This function materializes the input templates as a project, using user defined // This function materializes the input templates as a project, using user defined