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

Some logging fixes #476

Merged
merged 1 commit into from
Sep 12, 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
28 changes: 14 additions & 14 deletions dataplane/apigen/ccgen/ccgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,9 +824,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -856,9 +856,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -884,9 +884,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -906,9 +906,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -922,9 +922,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -942,9 +942,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -967,9 +967,9 @@ return msg;
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second << " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down
14 changes: 2 additions & 12 deletions dataplane/standalone/lucius/lucius.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,8 @@ func main() {
}

func getLogger() logging.Logger {
return logging.LoggerFunc(func(ctx context.Context, level logging.Level, msg string, fields ...any) {
switch level {
case logging.LevelDebug:
slog.DebugContext(ctx, msg, fields)
case logging.LevelInfo:
slog.InfoContext(ctx, msg, fields)
case logging.LevelWarn:
slog.WarnContext(ctx, msg, fields)
case logging.LevelError:
slog.ErrorContext(ctx, msg, fields)
}
return logging.LoggerFunc(func(ctx context.Context, lvl logging.Level, msg string, fields ...any) {
slog.Log(ctx, slog.Level(lvl), msg, fields...)
})
}

Expand Down Expand Up @@ -151,7 +142,6 @@ func setupOTelSDK(ctx context.Context) (func(context.Context) error, error) {
)

meterProvider := sdkmetric.NewMeterProvider(
sdkmetric.WithReader(sdkmetric.NewPeriodicReader(nil)),
sdkmetric.WithResource(res),
)

Expand Down
100 changes: 60 additions & 40 deletions dataplane/standalone/sai/acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,10 @@ sai_status_t l_create_acl_table(sai_object_id_t *acl_table_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -907,9 +908,10 @@ sai_status_t l_remove_acl_table(sai_object_id_t acl_table_id) {
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -942,9 +944,10 @@ sai_status_t l_get_acl_table_attribute(sai_object_id_t acl_table_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -1283,9 +1286,10 @@ sai_status_t l_create_acl_entry(sai_object_id_t *acl_entry_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -1308,9 +1312,10 @@ sai_status_t l_remove_acl_entry(sai_object_id_t acl_entry_id) {
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -1716,9 +1721,10 @@ sai_status_t l_set_acl_entry_attribute(sai_object_id_t acl_entry_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -1744,9 +1750,10 @@ sai_status_t l_get_acl_entry_attribute(sai_object_id_t acl_entry_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2217,9 +2224,10 @@ sai_status_t l_create_acl_counter(sai_object_id_t *acl_counter_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -2242,9 +2250,10 @@ sai_status_t l_remove_acl_counter(sai_object_id_t acl_counter_id) {
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2277,9 +2286,10 @@ sai_status_t l_set_acl_counter_attribute(sai_object_id_t acl_counter_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -2305,9 +2315,10 @@ sai_status_t l_get_acl_counter_attribute(sai_object_id_t acl_counter_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2352,9 +2363,10 @@ sai_status_t l_create_acl_range(sai_object_id_t *acl_range_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -2377,9 +2389,10 @@ sai_status_t l_remove_acl_range(sai_object_id_t acl_range_id) {
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2412,9 +2425,10 @@ sai_status_t l_get_acl_range_attribute(sai_object_id_t acl_range_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2446,9 +2460,10 @@ sai_status_t l_create_acl_table_group(sai_object_id_t *acl_table_group_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -2471,9 +2486,10 @@ sai_status_t l_remove_acl_table_group(sai_object_id_t acl_table_group_id) {
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2507,9 +2523,10 @@ sai_status_t l_get_acl_table_group_attribute(sai_object_id_t acl_table_group_id,
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2554,9 +2571,10 @@ sai_status_t l_create_acl_table_group_member(
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand All @@ -2580,9 +2598,10 @@ sai_status_t l_remove_acl_table_group_member(
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down Expand Up @@ -2617,9 +2636,10 @@ sai_status_t l_get_acl_table_group_member_attribute(
if (!status.ok()) {
auto it = context.GetServerTrailingMetadata().find("traceparent");
if (it != context.GetServerTrailingMetadata().end()) {
LOG(ERROR) << "Trace ID " << it->second << " " << status.error_message();
LOG(ERROR) << "Lucius RPC error: Trace ID " << it->second
<< " msg: " << status.error_message();
} else {
LOG(ERROR) << status.error_message();
LOG(ERROR) << "Lucius RPC error: " << status.error_message();
}
return SAI_STATUS_FAILURE;
}
Expand Down
Loading
Loading