From 4fc8c37376b8d52eff5bff61efdf224a4c561edd Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 30 Dec 2024 12:20:14 +0530 Subject: [PATCH] remove frontend wrapper --- integration/libs/telemetry/telemetry_test.go | 22 ++++++++------------ libs/telemetry/logger.go | 6 ++++-- libs/telemetry/logger_test.go | 8 +++---- libs/template/materialize.go | 4 +--- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/integration/libs/telemetry/telemetry_test.go b/integration/libs/telemetry/telemetry_test.go index a63279906..c08727042 100644 --- a/integration/libs/telemetry/telemetry_test.go +++ b/integration/libs/telemetry/telemetry_test.go @@ -33,23 +33,19 @@ func (wrapper *apiClientWrapper) Do(ctx context.Context, method, path string, } func TestTelemetryLogger(t *testing.T) { - events := []telemetry.FrontendLogEntry{ + events := []telemetry.DatabricksCliLog{ { - DatabricksCliLog: telemetry.DatabricksCliLog{ - CliTestEvent: &events.CliTestEvent{ - Name: events.DummyCliEnumValue1, - }, + CliTestEvent: &events.CliTestEvent{ + Name: events.DummyCliEnumValue1, }, }, { - DatabricksCliLog: telemetry.DatabricksCliLog{ - BundleInitEvent: &events.BundleInitEvent{ - Uuid: uuid.New().String(), - TemplateName: "abc", - TemplateEnumArgs: map[string]string{ - "a": "b", - "c": "d", - }, + BundleInitEvent: &events.BundleInitEvent{ + Uuid: uuid.New().String(), + TemplateName: "abc", + TemplateEnumArgs: map[string]string{ + "a": "b", + "c": "d", }, }, }, diff --git a/libs/telemetry/logger.go b/libs/telemetry/logger.go index a22abbd93..450d6e3d6 100644 --- a/libs/telemetry/logger.go +++ b/libs/telemetry/logger.go @@ -18,14 +18,16 @@ type DatabricksApiClient interface { 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) FrontendLog := FrontendLog{ // The telemetry endpoint deduplicates logs based on the FrontendLogEventID. // This it's important to generate a unique ID for each log event. FrontendLogEventID: uuid.New().String(), - Entry: event, + Entry: FrontendLogEntry{ + DatabricksCliLog: event, + }, } protoLog, err := json.Marshal(FrontendLog) diff --git a/libs/telemetry/logger_test.go b/libs/telemetry/logger_test.go index d6fc30f24..9e4116965 100644 --- a/libs/telemetry/logger_test.go +++ b/libs/telemetry/logger_test.go @@ -68,9 +68,9 @@ func TestTelemetryLoggerFlushesEvents(t *testing.T) { ctx := ContextWithLogger(context.Background()) 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}, - }}) + }) require.NoError(t, err) } @@ -102,9 +102,9 @@ func TestTelemetryLoggerFlushExitsOnTimeout(t *testing.T) { ctx := ContextWithLogger(context.Background()) 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}, - }}) + }) require.NoError(t, err) } diff --git a/libs/template/materialize.go b/libs/template/materialize.go index a2bae3559..18f08988f 100644 --- a/libs/template/materialize.go +++ b/libs/template/materialize.go @@ -124,9 +124,7 @@ func (t *Template) logTelemetry(ctx context.Context) error { }, } - return telemetry.Log(ctx, telemetry.FrontendLogEntry{ - DatabricksCliLog: event, - }) + return telemetry.Log(ctx, event) } // This function materializes the input templates as a project, using user defined