Skip to content

Commit

Permalink
Simple the error message
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Mar 22, 2024
1 parent 0ff8047 commit 2797725
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,8 @@ option(WITH_OTLP_GRPC "Whether to include the OTLP gRPC exporter in the SDK"
option(WITH_OTLP_HTTP "Whether to include the OTLP http exporter in the SDK"
OFF)

option(WITH_OTLP_FILE_PREVIOUS
"Whether to include the OTLP file exporter in the SDK" OFF)
set(WITH_OTLP_FILE ${WITH_OTLP_FILE_PREVIOUS})
option(WITH_OTLP_FILE "Whether to include the OTLP file exporter in the SDK"
OFF)
option(
WITH_OTLP_HTTP_COMPRESSION
"Whether to include gzip compression for the OTLP http exporter in the SDK"
Expand Down
24 changes: 9 additions & 15 deletions exporters/otlp/src/otlp_file_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender
{
break;
}
file_->background_thread_waker_cv.notify_one();
file_->background_thread_waker_cv.notify_all();
}

// Wait result
Expand Down Expand Up @@ -1259,24 +1259,18 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender
static_cast<int32_t>(FileSystemUtil::LinkOption::kForceRewrite));
if (res != 0)
{
# if !defined(__CYGWIN__) && defined(_WIN32)
// We can use FormatMessage to get error message.But it may be unicode and may not be
// printed correctly. See
// https://learn.microsoft.com/en-us/windows/win32/debug/retrieving-the-last-error-code for
// more details
OTEL_INTERNAL_LOG_ERROR("[OTLP FILE Client] Link " << file_->file_path << " to "
<< alias_file_path
<< " failed, errno: " << res);
# if !defined(__CYGWIN__) && defined(_WIN32)
OTEL_INTERNAL_LOG_ERROR(
"[OTLP FILE Client] you can use FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | "
"FORMAT_MESSAGE_FROM_SYSTEM"
<< " | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, " << res
<< ", MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), "
<< "(LPTSTR) &lpMsgBuf, 0, nullptr) to get the error message, see "
<< "https://docs.microsoft.com/en-us/windows/desktop/api/WinBase/"
"nf-winbase-formatmessage and "
<< "https://docs.microsoft.com/en-us/windows/desktop/Debug/"
"retrieving-the-last-error-code for more "
"details");
# else
OTEL_INTERNAL_LOG_ERROR("[OTLP FILE Client] you can use strerror("
<< res << ") to get the error message");
OTEL_INTERNAL_LOG_ERROR("[OTLP FILE Client] Link "
<< file_->file_path << " to " << alias_file_path
<< " failed, errno: " << res << ", message: " << strerror(res));
# endif
return file_->current_file;
}
Expand Down

0 comments on commit 2797725

Please sign in to comment.