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

opentelemetry tracer: add OTLP/HTTP exporter #29207

Merged
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c6ece86
Refactor gRPC exporter to use general base class we can later reuse
AlexanderEllis Jun 19, 2023
b59764e
Update OpenTelemetryConfig with HTTP-related config
AlexanderEllis Jun 20, 2023
ad99eb0
Write and wire up HTTP trace exporter
AlexanderEllis Jun 20, 2023
15fa601
Code formatting
AlexanderEllis Jun 20, 2023
8feddf1
Proto format
AlexanderEllis Jun 20, 2023
0a4f183
Add basic tests
AlexanderEllis Jun 23, 2023
5e4f9a6
code format
AlexanderEllis Jun 23, 2023
c058475
Add additional counters for http exporter and test
AlexanderEllis Jul 18, 2023
1a6d2fc
Formatting
AlexanderEllis Jul 18, 2023
bf51b6e
Coverage improvements
AlexanderEllis Jul 18, 2023
40cd7fc
Formatting
AlexanderEllis Jul 18, 2023
0a20370
Add higher level Driver test for HTTP exporting
AlexanderEllis Jul 19, 2023
a498727
More formatting
AlexanderEllis Jul 19, 2023
ccf877c
Clang tidy
AlexanderEllis Jul 19, 2023
6793f2f
Refactor config and add HTTP headers
joaopgrassi Aug 16, 2023
ab935a7
Modify tests
joaopgrassi Aug 22, 2023
03edac8
Fix lint errors
joaopgrassi Aug 23, 2023
c3e8b81
Revert oneof in proto config
joaopgrassi Sep 4, 2023
f507a0f
PR suggestions
joaopgrassi Sep 6, 2023
6815fb5
Add HttpService config type
joaopgrassi Sep 13, 2023
ec2a0d5
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Sep 13, 2023
8d1d23a
Fix format issues
joaopgrassi Sep 13, 2023
f883976
Fix lint/format/docs issues
joaopgrassi Sep 14, 2023
0b5b8bf
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Sep 14, 2023
2da074d
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Sep 18, 2023
1389804
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Sep 21, 2023
2b6b267
Hostname -> Authority
joaopgrassi Sep 21, 2023
3be83f8
Use HttpUri type
joaopgrassi Sep 27, 2023
38adbf1
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Sep 27, 2023
2a5d544
PR suggestions
joaopgrassi Oct 2, 2023
935ad0c
Improve log messages
joaopgrassi Oct 2, 2023
9ec6806
Fix format
joaopgrassi Oct 2, 2023
9b5e47a
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Oct 2, 2023
c0f39d7
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Oct 4, 2023
f852967
PR suggestions
joaopgrassi Oct 4, 2023
7ea4d0b
PR suggestions
joaopgrassi Oct 4, 2023
ba5d943
Revert stats for http exporter
joaopgrassi Oct 4, 2023
38bd4ac
Fix spelling
joaopgrassi Oct 4, 2023
3d07358
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Oct 6, 2023
ec3911b
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Oct 10, 2023
8c7ca70
Add changelog
joaopgrassi Oct 10, 2023
efcd78a
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Oct 12, 2023
e339153
Properly manage in-flight http requests in the exporter
joaopgrassi Oct 13, 2023
e7932fb
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Oct 13, 2023
aacb3f4
Add proto migrate oneof annotation
joaopgrassi Oct 16, 2023
c8f74c3
Clarify http headers do not support formatting
joaopgrassi Oct 17, 2023
e00f32b
Merge remote-tracking branch 'upstream/main' into otlp-http-exporter-…
joaopgrassi Oct 17, 2023
cb08695
Prepare headers when creating the HTTP exporter
joaopgrassi Oct 17, 2023
97f6870
Revert test change
joaopgrassi Oct 18, 2023
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
48 changes: 48 additions & 0 deletions api/envoy/config/core/v3/http_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
syntax = "proto3";

package envoy.config.core.v3;

import "envoy/config/core/v3/base.proto";

import "google/protobuf/duration.proto";

import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.config.core.v3";
option java_outer_classname = "HttpServiceProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/config/core/v3;corev3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: HTTP services]

// HTTP service configuration.
// [#next-free-field: 6]
message HttpService {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you model this on ext_authz HttpService? I notice there are a few subtle differences, e.g. use of HttpUri there.

Copy link
Contributor Author

@joaopgrassi joaopgrassi Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I didn't model based on that. I'm not sure, but I don't see a point in using the HttpUri type:

It forces defining a URI in the config, which won't be used in the OTLP exporter. In this PR, the exporter obtains an HTTP client from the thread local cluster which already has the base url configured. This was something that I noticed in @AlexanderEllis original PR and commented about it #28454 (comment). In the old PR, I could put whatever I wanted in uri: and it didn't matter.

I looked, the ext_authz seems to be doing the same https://github.com/envoyproxy/envoy/blob/main/source/extensions/filters/common/ext_authz/ext_authz_http_impl.cc#L254 and I also don't see any usage of the Uri there. It only access the cluster name, to get the thread local cluster and also get the HTTP client.

And by looking at this example https://github.com/envoyproxy/envoy/blob/main/examples/ext_authz/config/http-service.yaml#L32, unless I'm missing something, I don't see where ext_authz is coming from (used in uri), which confirms that it's just there to satisfy the field in HttpUri being required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the question I'd have is "the next time we do something similar to what ext_authz did, can we use HttpService for this?". FWIW this is not theoretical, we plan to do this for ext_proc at some point I think. @adisuissa do you have thoughts on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting… it took me a while to dig through the history of HttpUri, and found this comment thread interesting in particular while trying to understand what was the motivation behind HttpUri.uri.
Seems it was introduced to set the path, scheme and other parts of the request, while HttpUri.cluster sets the used Envoy cluster.

The 2 places I saw it is used as intended seem to be:

  1. JWKS fetcher
  2. Remote data resource

While the rest seem to be using just the cluster part.

I agree that ext-authz seems to be using it just for the cluster, and disregards the uri, but maybe it should have used it as intended (maybe in the future?).
I think it will be better to use HttpUri as is and probably try to reuse some of the code from jwks fetcher for this use-case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adisuissa I changed it to use HttpUri following the jwks fetcher example you gave 3be83f8. Looks a bit simpler now :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't request_headers_to_add a generic thing for an HTTP service? Seems a standard thing you might want to do when invoking an HTTP service, e.g. to set an auth token.

Copy link
Member

@tyxia tyxia Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From HTTP perspective, yes request_headers_to_add is generic thing.
However, what I meant is from user and practical perspective, this won't necessarily be achieved by this field in base proto here. More specifically:

In short, I don't have strong opinion here and I am just not sure about practical value of this request_headers_to_add field, as it can be easily achieved by extension specific config (and in a flexible way). This field here is probably good for simple add-header needs though.

Copy link
Contributor Author

@joaopgrassi joaopgrassi Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel request_headers_to_add here make sense for "static" header values. If there's a need for cases where a header value is not know in advance, like the client_id example, those can still be added "on the fly". I think one does not negate the other.

The GrpcService also has a headers property, so the goal was to be consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think for some simple use cases, like service specific static auth tokens, this is still reasonable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I agree with its value for simple use case.

Thanks all for discussion.

// The name of the upstream HTTP cluster. SSL credentials will be supplied
// in the :ref:`Cluster <envoy_v3_api_msg_config.cluster.v3.Cluster>` :ref:`transport_socket
// <envoy_v3_api_field_config.cluster.v3.Cluster.transport_socket>`.
string cluster_name = 1 [(validate.rules).string = {min_len: 1}];

// The path to use for the service.
// The default is an empty string.
string path = 2;

// Specifies a list of HTTP headers that should be added to each request
// handled by this virtual host.
repeated HeaderValueOption request_headers_to_add = 3
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
[(validate.rules).repeated = {max_items: 1000}];

// The timeout for the HTTP request. This is the timeout for a specific
// request.
// Sets the maximum duration in milliseconds that a response can take to arrive upon request.
google.protobuf.Duration timeout = 4 [(validate.rules).duration = {
required: true
gte {}
}];

// Specifies the hostname that should be added to the Host header to each request.
// The default is an empty string.
string hostname = 5;
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
}
9 changes: 8 additions & 1 deletion api/envoy/config/trace/v3/opentelemetry.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto3";
package envoy.config.trace.v3;

import "envoy/config/core/v3/grpc_service.proto";
import "envoy/config/core/v3/http_service.proto";

import "udpa/annotations/status.proto";

Expand All @@ -19,9 +20,15 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE;
message OpenTelemetryConfig {
// The upstream gRPC cluster that will receive OTLP traces.
// Note that the tracer drops traces if the server does not read data fast enough.
// This field can be left empty to disable reporting traces to the collector.
// This field can be left empty to disable reporting traces to the upstream cluster.
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
// Only one of ``grpc_service``, ``http_service`` may be used.
core.v3.GrpcService grpc_service = 1;
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved

// The upstream HTTP cluster that will receive OTLP traces.
// This field can be left empty to disable reporting traces to the upstream cluster.
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
// Only one of ``grpc_service``, ``http_service`` may be used.
core.v3.HttpService http_service = 3;

// The name for the service. This will be populated in the ResourceSpan Resource attributes.
// If it is not provided, it will default to "unknown_service:envoy".
string service_name = 2;
Expand Down
1 change: 1 addition & 0 deletions docs/root/api-v3/common_messages/common_messages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Common messages
../extensions/filters/common/dependency/v3/dependency.proto
../extensions/regex_engines/v3/google_re2.proto
../config/core/v3/grpc_method_list.proto
../config/core/v3/http_service.proto
../config/core/v3/grpc_service.proto
../extensions/key_value/file_based/v3/config.proto
../config/common/key_value/v3/config.proto
Expand Down
23 changes: 19 additions & 4 deletions source/extensions/tracers/opentelemetry/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ envoy_cc_library(
"span_context.h",
"span_context_extractor.h",
"tracer.h",
"tracer_stats.h",
],
deps = [
":grpc_trace_exporter",
":trace_exporter",
"//envoy/thread_local:thread_local_interface",
"//source/common/config:utility_lib",
"//source/common/tracing:http_tracer_lib",
Expand All @@ -47,13 +48,27 @@ envoy_cc_library(
)

envoy_cc_library(
name = "grpc_trace_exporter",
srcs = ["grpc_trace_exporter.cc"],
hdrs = ["grpc_trace_exporter.h"],
name = "trace_exporter",
srcs = [
"grpc_trace_exporter.cc",
"http_trace_exporter.cc",
],
hdrs = [
"grpc_trace_exporter.h",
"http_trace_exporter.h",
"trace_exporter.h",
"tracer_stats.h",
],
deps = [
"//envoy/grpc:async_client_manager_interface",
"//envoy/upstream:cluster_manager_interface",
"//source/common/grpc:typed_async_client_lib",
"//source/common/http:async_client_utility_lib",
"//source/common/http:header_map_lib",
"//source/common/http:message_lib",
"//source/common/http:utility_lib",
"//source/common/protobuf",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
"@opentelemetry_proto//:trace_cc_proto",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "source/common/grpc/typed_async_client.h"

#include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h"
#include "trace_exporter.h"
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved

namespace Envoy {
namespace Extensions {
Expand Down Expand Up @@ -80,18 +81,16 @@ class OpenTelemetryGrpcTraceExporterClient : Logger::Loggable<Logger::Id::tracin
const Protobuf::MethodDescriptor& service_method_;
};

class OpenTelemetryGrpcTraceExporter : Logger::Loggable<Logger::Id::tracing> {
class OpenTelemetryGrpcTraceExporter : public OpenTelemetryTraceExporter {
public:
OpenTelemetryGrpcTraceExporter(const Grpc::RawAsyncClientSharedPtr& client);

bool log(const ExportTraceServiceRequest& request);
bool log(const ExportTraceServiceRequest& request) override;

private:
OpenTelemetryGrpcTraceExporterClient client_;
};

using OpenTelemetryGrpcTraceExporterPtr = std::unique_ptr<OpenTelemetryGrpcTraceExporter>;

} // namespace OpenTelemetry
} // namespace Tracers
} // namespace Extensions
Expand Down
86 changes: 86 additions & 0 deletions source/extensions/tracers/opentelemetry/http_trace_exporter.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include "http_trace_exporter.h"
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved

#include <chrono>
#include <memory>
#include <string>

#include "source/common/common/logger.h"
#include "source/common/protobuf/protobuf.h"

namespace Envoy {
namespace Extensions {
namespace Tracers {
namespace OpenTelemetry {

OpenTelemetryHttpTraceExporter::OpenTelemetryHttpTraceExporter(
Upstream::ClusterManager& cluster_manager, envoy::config::core::v3::HttpService http_service,
OpenTelemetryTracerStats& tracing_stats)
: cluster_manager_(cluster_manager), http_service_(http_service),
tracing_stats_(tracing_stats) {}

bool OpenTelemetryHttpTraceExporter::log(const ExportTraceServiceRequest& request) {

joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
std::string request_body;

const auto ok = request.SerializeToString(&request_body);
if (!ok) {
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
ENVOY_LOG(warn, "Error while serializing the binary proto ExportTraceServiceRequest.");
return false;
}

Http::RequestMessagePtr message = std::make_unique<Http::RequestMessageImpl>();
message->headers().setReferenceMethod(Http::Headers::get().MethodValues.Post);
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
message->headers().setReferenceContentType(Http::Headers::get().ContentTypeValues.Protobuf);

// If traces_path is omitted, send to /v1/traces by default
if (http_service_.path().empty()) {
message->headers().setPath(TRACES_PATH);
} else {
message->headers().setPath(http_service_.path());
}

message->headers().setHost(http_service_.hostname());

// add all custom headers to the request
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
for (const auto& header_value_option : http_service_.request_headers_to_add()) {
message->headers().setCopy(Http::LowerCaseString(header_value_option.header().key()),
header_value_option.header().value());
}

message->body().add(request_body);

const auto thread_local_cluster =
cluster_manager_.getThreadLocalCluster(http_service_.cluster_name());
if (thread_local_cluster == nullptr) {
ENVOY_LOG(warn, "Thread local cluster not found for collector.");
return false;
}

std::chrono::milliseconds timeout = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::nanoseconds(http_service_.timeout().nanos()));
Http::AsyncClient::Request* http_request = thread_local_cluster->httpAsyncClient().send(
std::move(message), *this, Http::AsyncClient::RequestOptions().setTimeout(timeout));
tracing_stats_.http_reports_sent_.inc();

return http_request;
wbpcode marked this conversation as resolved.
Show resolved Hide resolved
}

void OpenTelemetryHttpTraceExporter::onSuccess(const Http::AsyncClient::Request&,
Http::ResponseMessagePtr&& message) {
tracing_stats_.http_reports_success_.inc();
const auto response_code = message->headers().Status()->value().getStringView();
if (response_code != "200") {
ENVOY_LOG(warn, "response code: {}", response_code);
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
}
}

void OpenTelemetryHttpTraceExporter::onFailure(const Http::AsyncClient::Request&,
Http::AsyncClient::FailureReason) {
ENVOY_LOG(debug, "Request failed.");
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
tracing_stats_.http_reports_failed_.inc();
}

} // namespace OpenTelemetry
} // namespace Tracers
} // namespace Extensions
} // namespace Envoy
51 changes: 51 additions & 0 deletions source/extensions/tracers/opentelemetry/http_trace_exporter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#pragma once

#include "envoy/config/core/v3/http_service.pb.h"
#include "envoy/upstream/cluster_manager.h"

#include "source/common/common/logger.h"
#include "source/common/http/async_client_impl.h"
#include "source/common/http/async_client_utility.h"
#include "source/common/http/headers.h"
#include "source/common/http/message_impl.h"
#include "source/common/http/utility.h"

#include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h"
#include "trace_exporter.h"
#include "tracer_stats.h"
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved

namespace Envoy {
namespace Extensions {
namespace Tracers {
namespace OpenTelemetry {

/**
* Exporter for OTLP traces over HTTP.
*/
class OpenTelemetryHttpTraceExporter : public OpenTelemetryTraceExporter,
public Http::AsyncClient::Callbacks {
public:
OpenTelemetryHttpTraceExporter(Upstream::ClusterManager& cluster_manager,
envoy::config::core::v3::HttpService http_service,
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
OpenTelemetryTracerStats& tracing_stats);

// The default path to use when OpenTelemetryConfig::HttpConfig::traces_path is empty
const Http::LowerCaseString TRACES_PATH{"/v1/traces"};
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved

bool log(const ExportTraceServiceRequest& request) override;

// Http::AsyncClient::Callbacks.
void onSuccess(const Http::AsyncClient::Request&, Http::ResponseMessagePtr&&) override;
void onFailure(const Http::AsyncClient::Request&, Http::AsyncClient::FailureReason) override;
void onBeforeFinalizeUpstreamSpan(Tracing::Span&, const Http::ResponseHeaderMap*) override {}

private:
Upstream::ClusterManager& cluster_manager_;
envoy::config::core::v3::HttpService http_service_;
OpenTelemetryTracerStats& tracing_stats_;
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
};

} // namespace OpenTelemetry
} // namespace Tracers
} // namespace Extensions
} // namespace Envoy
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
#include "source/common/config/utility.h"
#include "source/common/tracing/http_tracer_impl.h"

#include "grpc_trace_exporter.h"
#include "http_trace_exporter.h"
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
#include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h"
#include "opentelemetry/proto/trace/v1/trace.pb.h"
#include "span_context.h"
#include "span_context_extractor.h"
#include "trace_exporter.h"
#include "tracer.h"
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved

namespace Envoy {
Expand All @@ -26,16 +29,26 @@ Driver::Driver(const envoy::config::trace::v3::OpenTelemetryConfig& opentelemetr
tracing_stats_{OPENTELEMETRY_TRACER_STATS(
POOL_COUNTER_PREFIX(context.serverFactoryContext().scope(), "tracing.opentelemetry"))} {
auto& factory_context = context.serverFactoryContext();

if (opentelemetry_config.has_grpc_service() && opentelemetry_config.has_http_service()) {
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
throw EnvoyException(
"OpenTelemetry Tracer cannot have both gRPC and HTTP exporters configured. "
"OpenTelemetry tracer will be disabled.");
}

// Create the tracer in Thread Local Storage.
tls_slot_ptr_->set([opentelemetry_config, &factory_context, this](Event::Dispatcher& dispatcher) {
OpenTelemetryGrpcTraceExporterPtr exporter;
OpenTelemetryTraceExporterPtr exporter;
if (opentelemetry_config.has_grpc_service()) {
Grpc::AsyncClientFactoryPtr&& factory =
factory_context.clusterManager().grpcAsyncClientManager().factoryForGrpcService(
opentelemetry_config.grpc_service(), factory_context.scope(), true);
const Grpc::RawAsyncClientSharedPtr& async_client_shared_ptr =
factory->createUncachedRawAsyncClient();
exporter = std::make_unique<OpenTelemetryGrpcTraceExporter>(async_client_shared_ptr);
} else if (opentelemetry_config.has_http_service()) {
exporter = std::make_unique<OpenTelemetryHttpTraceExporter>(
factory_context.clusterManager(), opentelemetry_config.http_service(), tracing_stats_);
}
TracerPtr tracer = std::make_unique<Tracer>(
std::move(exporter), factory_context.timeSource(), factory_context.api().randomGenerator(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "source/common/common/logger.h"
#include "source/common/singleton/const_singleton.h"
#include "source/extensions/tracers/common/factory_base.h"
#include "source/extensions/tracers/opentelemetry/grpc_trace_exporter.h"
#include "source/extensions/tracers/opentelemetry/tracer.h"

#include "tracer.h"
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved

namespace Envoy {
namespace Extensions {
Expand Down
26 changes: 26 additions & 0 deletions source/extensions/tracers/opentelemetry/trace_exporter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include "source/common/common/logger.h"

#include "opentelemetry/proto/collector/trace/v1/trace_service.pb.h"

using opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest;

namespace Envoy {
namespace Extensions {
namespace Tracers {
namespace OpenTelemetry {

class OpenTelemetryTraceExporter : public Logger::Loggable<Logger::Id::tracing> {
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
public:
virtual ~OpenTelemetryTraceExporter() = default;

virtual bool log(const ExportTraceServiceRequest& request) = 0;
joaopgrassi marked this conversation as resolved.
Show resolved Hide resolved
};

using OpenTelemetryTraceExporterPtr = std::unique_ptr<OpenTelemetryTraceExporter>;

} // namespace OpenTelemetry
} // namespace Tracers
} // namespace Extensions
} // namespace Envoy
2 changes: 1 addition & 1 deletion source/extensions/tracers/opentelemetry/tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void Span::setTag(absl::string_view name, absl::string_view value) {
*span_.add_attributes() = key_value;
}

Tracer::Tracer(OpenTelemetryGrpcTraceExporterPtr exporter, Envoy::TimeSource& time_source,
Tracer::Tracer(OpenTelemetryTraceExporterPtr exporter, Envoy::TimeSource& time_source,
Random::RandomGenerator& random, Runtime::Loader& runtime,
Event::Dispatcher& dispatcher, OpenTelemetryTracerStats tracing_stats,
const std::string& service_name)
Expand Down
Loading
Loading