Apply gci import order changes

This commit is contained in:
github-actions[bot]
2025-09-11 09:57:50 +00:00
parent 5ea3c4ace6
commit cb1d274074
6 changed files with 82 additions and 82 deletions

View File

@ -70,7 +70,7 @@ type ConfigNode struct {
// Otel specifies the OpenTelemetry tracing configuration
// Optional field
Otel otel.Config `json:"otel"`
// OtelTraceSQLEnabled enables OpenTelemetry tracing for SQL operations
// Deprecated: Use Otel.TraceSQLEnabled instead. This field is kept for backward compatibility.
// Optional field

View File

@ -81,11 +81,11 @@ func (c *Core) traceSpanEnd(ctx context.Context, span trace.Span, sql *Sql) {
}
}
events = append(events, attribute.String(traceEventDbExecutionType, string(sql.Type)))
// Add SQL statement to tracing if enabled
if c.db.GetConfig().IsOtelTraceSQLEnabled() {
events = append(events, attribute.String(traceEventDbExecutionSQL, sql.Format))
}
span.AddEvent(traceEventDbExecution, trace.WithAttributes(events...))
}

View File

@ -20,7 +20,7 @@ func Test_OTEL_SQLTracing_Default(t *testing.T) {
Type: "sqlite",
Name: ":memory:",
}
// By default, SQL tracing should be disabled
t.Assert(config.IsOtelTraceSQLEnabled(), false)
t.Assert(config.OtelTraceSQLEnabled, false)
@ -31,11 +31,11 @@ func Test_OTEL_SQLTracing_Default(t *testing.T) {
func Test_OTEL_SQLTracing_Configuration(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
config := gdb.ConfigNode{
Type: "sqlite",
Name: ":memory:",
Type: "sqlite",
Name: ":memory:",
OtelTraceSQLEnabled: true,
}
// SQL tracing should be configurable using legacy field
t.Assert(config.IsOtelTraceSQLEnabled(), true)
t.Assert(config.OtelTraceSQLEnabled, true)
@ -52,7 +52,7 @@ func Test_OTEL_SQLTracing_NewConfiguration(t *testing.T) {
TraceSQLEnabled: true,
},
}
// SQL tracing should be configurable using new configuration
t.Assert(config.IsOtelTraceSQLEnabled(), true)
t.Assert(config.OtelTraceSQLEnabled, false)
@ -63,11 +63,11 @@ func Test_OTEL_SQLTracing_NewConfiguration(t *testing.T) {
func Test_OTEL_SQLTracing_Enabled(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
config := gdb.ConfigNode{
Type: "mysql",
Name: "test_db",
Type: "mysql",
Name: "test_db",
OtelTraceSQLEnabled: true,
}
// Test that the configuration field can be set and retrieved using legacy field
t.Assert(config.IsOtelTraceSQLEnabled(), true)
})
@ -76,15 +76,15 @@ func Test_OTEL_SQLTracing_Enabled(t *testing.T) {
func Test_OTEL_SQLTracing_BothFieldsEnabled(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
config := gdb.ConfigNode{
Type: "mysql",
Name: "test_db",
Type: "mysql",
Name: "test_db",
OtelTraceSQLEnabled: false,
Otel: otel.Config{
TraceSQLEnabled: true,
},
}
// New field should take precedence over legacy field
t.Assert(config.IsOtelTraceSQLEnabled(), true)
})
}
}