Skip to content

ElasticSearch exporter does not give the possibility to add custom headers (auth headers for instance) #3080

@MaxLeb

Description

@MaxLeb

Describe your environment

Using a manually built version of OpenTelemetry 1.16.1 on macOS with :

-DWITH_EXAMPLES=OFF
-DWITH_OTLP_HTTP=ON
-DBUILD_TESTING=OFF
-DWITH_OTLP_GRPC=OFF
-DWITH_LOGS_PREVIEW=ON
-DOPENTELEMETRY_INSTALL=ON
-DBUILD_SHARED_LIBS=OFF
-DWITH_ASYNC_EXPORT_PREVIEW=ON
-DCMAKE_CXX_STANDARD=17
-DWITH_ELASTICSEARCH=ON

Steps to reproduce

The usage is pretty simple:

First an init of the exporter with a single log record processor:

opentelemetry::exporter::logs::ElasticsearchExporterOptions opts(
,
9200,
"logs",
30,
true);

auto elkExporter = std::make_uniqueopentelemetry::exporter::logs::ElasticsearchLogRecordExporter(opts);

auto elkProcessor = opentelemetry::sdk::logs::SimpleLogRecordProcessorFactory::Create(std::move(elkExporter));

std::shared_ptropentelemetry::logs::LoggerProvider provider = opentelemetry::sdk::logs::LoggerProviderFactory::Create(
std::move(elkProcessor), resource);

opentelemetry::logs::Provider::SetLoggerProvider(provider);

m_Logger = provider->GetLogger("MyLogger", SOURCE_NAME);
Then, when logs needs to be sent a call to m_Logger.EmitLogRecord(xxx)

What is the expected behavior?
Since the ELK endpoint requires a basic auth, the call is rejected with a 401 error as we cannot set any custom headers to the request.

What is the actual behavior?
Add possibility to add custom headers (probably more of a feature request than an actual bug).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions