mirror of https://github.com/databricks/cli.git
remove frontend wrapper
This commit is contained in:
parent
9fb2c66c4a
commit
4fc8c37376
|
@ -33,23 +33,19 @@ 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",
|
TemplateEnumArgs: map[string]string{
|
||||||
TemplateEnumArgs: map[string]string{
|
"a": "b",
|
||||||
"a": "b",
|
"c": "d",
|
||||||
"c": "d",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue