Skip to content

Commit

Permalink
Fix code reviews
Browse files Browse the repository at this point in the history
Signed-off-by: owentou <owentou@tencent.com>
  • Loading branch information
owent committed Oct 29, 2021
1 parent f588e6b commit 8f738aa
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ inline const std::string GetOtlpDefaultHttpEndpoint()
auto endpoint = opentelemetry::sdk::common::GetEnvironmentVariable(kOtlpTracesEndpointEnv);
if (endpoint.empty())
{
endpoint = opentelemetry::sdk::common::GetEnvironmentVariable(kOtlpEndpointEnv);
endpoint = opentelemetry::sdk::common::GetEnvironmentVariable(kOtlpEndpointEnv) + "/v1/traces";
}
return endpoint.size() ? endpoint : kOtlpEndpointDefault;
}
Expand Down Expand Up @@ -219,24 +219,24 @@ inline OtlpHeaders GetOtlpDefaultHeaders()

inline const std::string GetOtlpDefaultHttpLogEndpoint()
{
constexpr char kOtlpTracesEndpointEnv[] = "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT";
constexpr char kOtlpEndpointEnv[] = "OTEL_EXPORTER_OTLP_ENDPOINT";
constexpr char kOtlpEndpointDefault[] = "http://localhost:4318/v1/logs";
constexpr char kOtlpLogsEndpointEnv[] = "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT";
constexpr char kOtlpEndpointEnv[] = "OTEL_EXPORTER_OTLP_ENDPOINT";
constexpr char kOtlpEndpointDefault[] = "http://localhost:4318/v1/logs";

auto endpoint = opentelemetry::sdk::common::GetEnvironmentVariable(kOtlpTracesEndpointEnv);
auto endpoint = opentelemetry::sdk::common::GetEnvironmentVariable(kOtlpLogsEndpointEnv);
if (endpoint.empty())
{
endpoint = opentelemetry::sdk::common::GetEnvironmentVariable(kOtlpEndpointEnv);
endpoint = opentelemetry::sdk::common::GetEnvironmentVariable(kOtlpEndpointEnv) + "/v1/logs";
}
return endpoint.size() ? endpoint : kOtlpEndpointDefault;
}

inline const std::chrono::system_clock::duration GetOtlpDefaultLogTimeout()
{
constexpr char kOtlpTracesTimeoutEnv[] = "OTEL_EXPORTER_OTLP_LOGS_TIMEOUT";
constexpr char kOtlpTimeoutEnv[] = "OTEL_EXPORTER_OTLP_TIMEOUT";
constexpr char kOtlpLogsTimeoutEnv[] = "OTEL_EXPORTER_OTLP_LOGS_TIMEOUT";
constexpr char kOtlpTimeoutEnv[] = "OTEL_EXPORTER_OTLP_TIMEOUT";

auto timeout = opentelemetry::sdk::common::GetEnvironmentVariable(kOtlpTracesTimeoutEnv);
auto timeout = opentelemetry::sdk::common::GetEnvironmentVariable(kOtlpLogsTimeoutEnv);
if (timeout.empty())
{
timeout = opentelemetry::sdk::common::GetEnvironmentVariable(kOtlpTimeoutEnv);
Expand All @@ -246,15 +246,15 @@ inline const std::chrono::system_clock::duration GetOtlpDefaultLogTimeout()

inline OtlpHeaders GetOtlpDefaultLogHeaders()
{
constexpr char kOtlpTracesHeadersEnv[] = "OTEL_EXPORTER_OTLP_LOGS_HEADERS";
constexpr char kOtlpHeadersEnv[] = "OTEL_EXPORTER_OTLP_HEADERS";
constexpr char kOtlpLogsHeadersEnv[] = "OTEL_EXPORTER_OTLP_LOGS_HEADERS";
constexpr char kOtlpHeadersEnv[] = "OTEL_EXPORTER_OTLP_HEADERS";

OtlpHeaders result;
std::unordered_set<std::string> trace_remove_cache;
DumpOtlpHeaders(result, kOtlpHeadersEnv, trace_remove_cache);
std::unordered_set<std::string> log_remove_cache;
DumpOtlpHeaders(result, kOtlpHeadersEnv, log_remove_cache);

trace_remove_cache.clear();
DumpOtlpHeaders(result, kOtlpTracesHeadersEnv, trace_remove_cache);
log_remove_cache.clear();
DumpOtlpHeaders(result, kOtlpLogsHeadersEnv, log_remove_cache);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class OtlpLogRecordable final : public opentelemetry::sdk::logs::Recordable
proto::logs::v1::LogRecord &log_record() noexcept { return log_record_; }
const proto::logs::v1::LogRecord &log_record() const noexcept { return log_record_; }

/** Dynamically converts the resource of this span into a proto. */
/** Dynamically converts the resource of this log into a proto. */
proto::resource::v1::Resource ProtoResource() const noexcept;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class OtlpRecordableUtils

#ifdef ENABLE_LOGS_PREVIEW
static void PopulateRequest(
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &spans,
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &logs,
proto::collector::logs::v1::ExportLogsServiceRequest *request) noexcept;
#endif
};
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/src/otlp_http_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ std::unique_ptr<opentelemetry::sdk::logs::Recordable> OtlpHttpLogExporter::MakeR
}

opentelemetry::sdk::common::ExportResult OtlpHttpLogExporter::Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &spans) noexcept
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &logs) noexcept
{
proto::collector::logs::v1::ExportLogsServiceRequest service_request;
OtlpRecordableUtils::PopulateRequest(spans, &service_request);
OtlpRecordableUtils::PopulateRequest(logs, &service_request);
return http_client_.Export(service_request);
}

Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/src/otlp_recordable_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,15 @@ void OtlpRecordableUtils::PopulateRequest(

#ifdef ENABLE_LOGS_PREVIEW
void OtlpRecordableUtils::PopulateRequest(
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &spans,
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &logs,
proto::collector::logs::v1::ExportLogsServiceRequest *request) noexcept
{
if (nullptr == request)
{
return;
}

for (auto &recordable : spans)
for (auto &recordable : logs)
{
auto resource_logs = request->add_resource_logs();
auto instrumentation_lib = resource_logs->add_instrumentation_library_logs();
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/trace/tracer_provider_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ TEST(TracerProvider, GetTracer)
#ifdef RTTI_ENABLED
auto sdkTracer3 = dynamic_cast<Tracer *>(t3.get());
#else
auto sdkTracer3 = dynamic_cast<Tracer *>(t3.get());
auto sdkTracer3 = static_cast<Tracer *>(t3.get());
#endif
auto instrumentation_library3 = sdkTracer3->GetInstrumentationLibrary();
ASSERT_EQ(instrumentation_library3.GetName(), "different");
Expand Down

0 comments on commit 8f738aa

Please sign in to comment.