From 2ecc349d723c33210c9affd71295ec20549e2daf Mon Sep 17 00:00:00 2001 From: Maxime Leblanc Date: Fri, 18 Oct 2024 10:55:00 +0200 Subject: [PATCH] EXPORTERS]: elastic search recorable constructor sets `ecs.version` field to 8.11.0 According to ECS guidelines this field is mandatory https://www.elastic.co/guide/en/ecs/8.11/ecs-guidelines.html Refs #3091 --- .../exporters/elasticsearch/es_log_recordable.h | 2 ++ exporters/elasticsearch/src/es_log_recordable.cc | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h index af4ccb16ef..52d24cada6 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h @@ -42,6 +42,8 @@ class ElasticSearchRecordable final : public sdk::logs::Recordable void WriteValue(const opentelemetry::common::AttributeValue &value, const std::string &name); public: + ElasticSearchRecordable() noexcept; + /** * Returns a JSON object contain the log information */ diff --git a/exporters/elasticsearch/src/es_log_recordable.cc b/exporters/elasticsearch/src/es_log_recordable.cc index cb0c78ade9..77be233953 100644 --- a/exporters/elasticsearch/src/es_log_recordable.cc +++ b/exporters/elasticsearch/src/es_log_recordable.cc @@ -197,6 +197,11 @@ void ElasticSearchRecordable::WriteValue(const opentelemetry::common::AttributeV } } +ElasticSearchRecordable::ElasticSearchRecordable() noexcept : sdk::logs::Recordable() +{ + json_["ecs"]["version"] = "8.11.0"; +} + nlohmann::json ElasticSearchRecordable::GetJSON() noexcept { return json_;