-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into upgrade-cmake-grpc
- Loading branch information
Showing
18 changed files
with
228 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "THttpTransport.h" | ||
#include "opentelemetry/ext/http/client/http_client_factory.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace exporter | ||
{ | ||
namespace jaeger | ||
{ | ||
|
||
THttpTransport::THttpTransport(std::string endpoint, ext::http::client::Headers extra_headers) | ||
: endpoint(std::move(endpoint)), | ||
headers(std::move(extra_headers)), | ||
client(ext::http::client::HttpClientFactory::CreateSync()) | ||
{ | ||
headers.insert({{"Content-Type", "application/vnd.apache.thrift.binary"}}); | ||
} | ||
|
||
THttpTransport::~THttpTransport() {} | ||
|
||
bool THttpTransport::isOpen() const | ||
{ | ||
return true; | ||
} | ||
|
||
uint32_t THttpTransport::read(uint8_t *buf, uint32_t len) | ||
{ | ||
(void)buf; | ||
(void)len; | ||
return 0; | ||
} | ||
|
||
void THttpTransport::write(const uint8_t *buf, uint32_t len) | ||
{ | ||
request_buffer.insert(request_buffer.end(), buf, buf + len); | ||
} | ||
|
||
bool THttpTransport::sendSpans() | ||
{ | ||
auto result = client->Post(endpoint, request_buffer, headers); | ||
request_buffer.clear(); | ||
|
||
// TODO: Add logging once global log handling is available. | ||
if (!result) | ||
{ | ||
return false; | ||
} | ||
|
||
if (result.GetResponse().GetStatusCode() >= 400) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
} // namespace jaeger | ||
} // namespace exporter | ||
OPENTELEMETRY_END_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <opentelemetry/ext/http/client/http_client.h> | ||
#include <opentelemetry/version.h> | ||
|
||
#include <thrift/transport/TVirtualTransport.h> | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace exporter | ||
{ | ||
namespace jaeger | ||
{ | ||
|
||
class THttpTransport : public apache::thrift::transport::TVirtualTransport<THttpTransport> | ||
{ | ||
public: | ||
THttpTransport(std::string endpoint, ext::http::client::Headers extra_headers); | ||
~THttpTransport() override; | ||
|
||
bool isOpen() const override; | ||
|
||
uint32_t read(uint8_t *buf, uint32_t len); | ||
|
||
void write(const uint8_t *buf, uint32_t len); | ||
|
||
bool sendSpans(); | ||
|
||
private: | ||
std::string endpoint; | ||
ext::http::client::Headers headers; | ||
std::shared_ptr<ext::http::client::HttpClientSync> client; | ||
std::vector<uint8_t> request_buffer; | ||
}; | ||
|
||
} // namespace jaeger | ||
} // namespace exporter | ||
OPENTELEMETRY_END_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "http_transport.h" | ||
|
||
#include <thrift/protocol/TBinaryProtocol.h> | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace exporter | ||
{ | ||
namespace jaeger | ||
{ | ||
|
||
using TBinaryProtocol = apache::thrift::protocol::TBinaryProtocol; | ||
using TTransport = apache::thrift::transport::TTransport; | ||
|
||
HttpTransport::HttpTransport(std::string endpoint, ext::http::client::Headers headers) | ||
{ | ||
endpoint_transport_ = std::make_shared<THttpTransport>(std::move(endpoint), std::move(headers)); | ||
protocol_ = std::shared_ptr<TProtocol>(new TBinaryProtocol(endpoint_transport_)); | ||
} | ||
|
||
int HttpTransport::EmitBatch(const thrift::Batch &batch) | ||
{ | ||
batch.write(protocol_.get()); | ||
|
||
if (!endpoint_transport_->sendSpans()) | ||
{ | ||
return 0; | ||
} | ||
|
||
return static_cast<int>(batch.spans.size()); | ||
} | ||
|
||
} // namespace jaeger | ||
} // namespace exporter | ||
OPENTELEMETRY_END_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "THttpTransport.h" | ||
#include "transport.h" | ||
|
||
#include <thrift/protocol/TProtocol.h> | ||
#include <thrift/transport/TTransport.h> | ||
#include <memory> | ||
#include <string> | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace exporter | ||
{ | ||
namespace jaeger | ||
{ | ||
|
||
using TProtocol = apache::thrift::protocol::TProtocol; | ||
|
||
class HttpTransport : public Transport | ||
{ | ||
public: | ||
HttpTransport(std::string endpoint, ext::http::client::Headers headers); | ||
|
||
int EmitBatch(const thrift::Batch &batch) override; | ||
|
||
uint32_t MaxPacketSize() const override | ||
{ | ||
// Default to 4 MiB POST body size. | ||
return 1 << 22; | ||
} | ||
|
||
private: | ||
std::shared_ptr<THttpTransport> endpoint_transport_; | ||
std::shared_ptr<TProtocol> protocol_; | ||
}; | ||
|
||
} // namespace jaeger | ||
} // namespace exporter | ||
OPENTELEMETRY_END_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.