-
Notifications
You must be signed in to change notification settings - Fork 509
[CONFIGURATION] File configuration - configuration example #3573
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,35 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include "opentelemetry/sdk/common/global_log_handler.h" | ||
| #include "opentelemetry/sdk/logs/read_write_log_record.h" | ||
| #include "opentelemetry/sdk/logs/recordable.h" | ||
|
|
||
| #include "custom_log_record_exporter.h" | ||
|
|
||
| std::unique_ptr<opentelemetry::sdk::logs::Recordable> | ||
| CustomLogRecordExporter::MakeRecordable() noexcept | ||
| { | ||
| auto recordable = std::make_unique<opentelemetry::sdk::logs::ReadWriteLogRecord>(); | ||
| return recordable; | ||
| } | ||
|
|
||
| opentelemetry::sdk::common::ExportResult CustomLogRecordExporter::Export( | ||
| const opentelemetry::nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> | ||
| & /* records */) noexcept | ||
| { | ||
| OTEL_INTERNAL_LOG_ERROR("CustomLogRecordExporter::Export(): YOUR CODE HERE"); | ||
| return opentelemetry::sdk::common::ExportResult::kSuccess; | ||
| } | ||
|
|
||
| bool CustomLogRecordExporter::ForceFlush(std::chrono::microseconds /* timeout */) noexcept | ||
| { | ||
| OTEL_INTERNAL_LOG_ERROR("CustomLogRecordExporter::ForceFlush(): YOUR CODE HERE"); | ||
| return false; | ||
| } | ||
|
|
||
| bool CustomLogRecordExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept | ||
| { | ||
| OTEL_INTERNAL_LOG_ERROR("CustomLogRecordExporter::Shutdown(): YOUR CODE HERE"); | ||
| return false; | ||
| } | ||
This file contains hidden or 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,34 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <chrono> | ||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "opentelemetry/nostd/span.h" | ||
| #include "opentelemetry/sdk/common/exporter_utils.h" | ||
| #include "opentelemetry/sdk/logs/exporter.h" | ||
| #include "opentelemetry/sdk/logs/recordable.h" | ||
|
|
||
| class CustomLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExporter | ||
| { | ||
| public: | ||
| CustomLogRecordExporter(const std::string & /* comment */) {} | ||
| CustomLogRecordExporter(CustomLogRecordExporter &&) = delete; | ||
| CustomLogRecordExporter(const CustomLogRecordExporter &) = delete; | ||
| CustomLogRecordExporter &operator=(CustomLogRecordExporter &&) = delete; | ||
| CustomLogRecordExporter &operator=(const CustomLogRecordExporter &other) = delete; | ||
| ~CustomLogRecordExporter() override = default; | ||
|
|
||
| std::unique_ptr<opentelemetry::sdk::logs::Recordable> MakeRecordable() noexcept override; | ||
|
|
||
| opentelemetry::sdk::common::ExportResult Export( | ||
| const opentelemetry::nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> | ||
| &records) noexcept override; | ||
|
|
||
| bool ForceFlush(std::chrono::microseconds timeout) noexcept override; | ||
|
|
||
| bool Shutdown(std::chrono::microseconds timeout) noexcept override; | ||
| }; |
31 changes: 31 additions & 0 deletions
31
examples/configuration/custom_log_record_exporter_builder.cc
This file contains hidden or 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,31 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/document_node.h" | ||
| #include "opentelemetry/sdk/configuration/extension_log_record_exporter_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/registry.h" | ||
| #include "opentelemetry/sdk/logs/exporter.h" | ||
|
|
||
| #include "custom_log_record_exporter.h" | ||
| #include "custom_log_record_exporter_builder.h" | ||
|
|
||
| std::unique_ptr<opentelemetry::sdk::logs::LogRecordExporter> CustomLogRecordExporterBuilder::Build( | ||
| const opentelemetry::sdk::configuration::ExtensionLogRecordExporterConfiguration *model) const | ||
| { | ||
| // Read yaml attributes | ||
| std::string comment = model->node->GetRequiredString("comment"); | ||
|
|
||
| auto sdk = std::make_unique<CustomLogRecordExporter>(comment); | ||
|
|
||
| return sdk; | ||
| } | ||
|
|
||
| void CustomLogRecordExporterBuilder::Register(opentelemetry::sdk::configuration::Registry *registry) | ||
| { | ||
| auto builder = std::make_unique<CustomLogRecordExporterBuilder>(); | ||
| registry->SetExtensionLogRecordExporterBuilder("my_custom_log_record_exporter", | ||
| std::move(builder)); | ||
| } |
22 changes: 22 additions & 0 deletions
22
examples/configuration/custom_log_record_exporter_builder.h
This file contains hidden or 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,22 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/extension_log_record_exporter_builder.h" | ||
| #include "opentelemetry/sdk/configuration/extension_log_record_exporter_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/registry.h" | ||
| #include "opentelemetry/sdk/logs/exporter.h" | ||
|
|
||
| class CustomLogRecordExporterBuilder | ||
| : public opentelemetry::sdk::configuration::ExtensionLogRecordExporterBuilder | ||
| { | ||
| public: | ||
| static void Register(opentelemetry::sdk::configuration::Registry *registry); | ||
|
|
||
| std::unique_ptr<opentelemetry::sdk::logs::LogRecordExporter> Build( | ||
| const opentelemetry::sdk::configuration::ExtensionLogRecordExporterConfiguration *model) | ||
| const override; | ||
| }; |
This file contains hidden or 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,36 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include <utility> | ||
|
|
||
| #include "opentelemetry/sdk/common/global_log_handler.h" | ||
| #include "opentelemetry/sdk/logs/read_write_log_record.h" | ||
| #include "opentelemetry/sdk/logs/recordable.h" | ||
|
|
||
| #include "custom_log_record_processor.h" | ||
|
|
||
| std::unique_ptr<opentelemetry::sdk::logs::Recordable> | ||
| CustomLogRecordProcessor::MakeRecordable() noexcept | ||
| { | ||
| auto recordable = std::make_unique<opentelemetry::sdk::logs::ReadWriteLogRecord>(); | ||
| return recordable; | ||
| } | ||
|
|
||
| void CustomLogRecordProcessor::OnEmit( | ||
| std::unique_ptr<opentelemetry::sdk::logs::Recordable> &&span) noexcept | ||
| { | ||
| OTEL_INTERNAL_LOG_ERROR("CustomLogRecordProcessor::OnEnd(): YOUR CODE HERE"); | ||
| auto unused = std::move(span); | ||
| } | ||
|
|
||
| bool CustomLogRecordProcessor::ForceFlush(std::chrono::microseconds /* timeout */) noexcept | ||
| { | ||
| OTEL_INTERNAL_LOG_ERROR("CustomLogRecordProcessor::ForceFlush(): YOUR CODE HERE"); | ||
| return false; | ||
| } | ||
|
|
||
| bool CustomLogRecordProcessor::Shutdown(std::chrono::microseconds /* timeout */) noexcept | ||
| { | ||
| OTEL_INTERNAL_LOG_ERROR("CustomLogRecordProcessor::Shutdown(): YOUR CODE HERE"); | ||
| return false; | ||
| } |
This file contains hidden or 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,33 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <chrono> | ||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "opentelemetry/sdk/logs/processor.h" | ||
| #include "opentelemetry/sdk/logs/recordable.h" | ||
|
|
||
| class CustomLogRecordProcessor : public opentelemetry::sdk::logs::LogRecordProcessor | ||
| { | ||
| public: | ||
| CustomLogRecordProcessor(const std::string &comment) : m_comment(comment) {} | ||
| CustomLogRecordProcessor(CustomLogRecordProcessor &&) = delete; | ||
| CustomLogRecordProcessor(const CustomLogRecordProcessor &) = delete; | ||
| CustomLogRecordProcessor &operator=(CustomLogRecordProcessor &&) = delete; | ||
| CustomLogRecordProcessor &operator=(const CustomLogRecordProcessor &other) = delete; | ||
| ~CustomLogRecordProcessor() override = default; | ||
|
|
||
| std::unique_ptr<opentelemetry::sdk::logs::Recordable> MakeRecordable() noexcept override; | ||
|
|
||
| void OnEmit(std::unique_ptr<opentelemetry::sdk::logs::Recordable> &&record) noexcept override; | ||
|
|
||
| bool ForceFlush(std::chrono::microseconds timeout) noexcept override; | ||
|
|
||
| bool Shutdown(std::chrono::microseconds timeout) noexcept override; | ||
|
|
||
| private: | ||
| std::string m_comment; | ||
| }; |
33 changes: 33 additions & 0 deletions
33
examples/configuration/custom_log_record_processor_builder.cc
This file contains hidden or 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,33 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/document_node.h" | ||
| #include "opentelemetry/sdk/configuration/extension_log_record_processor_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/registry.h" | ||
| #include "opentelemetry/sdk/logs/processor.h" | ||
|
|
||
| #include "custom_log_record_processor.h" | ||
| #include "custom_log_record_processor_builder.h" | ||
|
|
||
| std::unique_ptr<opentelemetry::sdk::logs::LogRecordProcessor> | ||
| CustomLogRecordProcessorBuilder::Build( | ||
| const opentelemetry::sdk::configuration::ExtensionLogRecordProcessorConfiguration *model) const | ||
| { | ||
| // Read yaml attributes | ||
| std::string comment = model->node->GetRequiredString("comment"); | ||
|
|
||
| auto sdk = std::make_unique<CustomLogRecordProcessor>(comment); | ||
|
|
||
| return sdk; | ||
| } | ||
|
|
||
| void CustomLogRecordProcessorBuilder::Register( | ||
| opentelemetry::sdk::configuration::Registry *registry) | ||
| { | ||
| auto builder = std::make_unique<CustomLogRecordProcessorBuilder>(); | ||
| registry->SetExtensionLogRecordProcessorBuilder("my_custom_log_record_processor", | ||
| std::move(builder)); | ||
| } |
22 changes: 22 additions & 0 deletions
22
examples/configuration/custom_log_record_processor_builder.h
This file contains hidden or 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,22 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/extension_log_record_processor_builder.h" | ||
| #include "opentelemetry/sdk/configuration/extension_log_record_processor_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/registry.h" | ||
| #include "opentelemetry/sdk/logs/processor.h" | ||
|
|
||
| class CustomLogRecordProcessorBuilder | ||
| : public opentelemetry::sdk::configuration::ExtensionLogRecordProcessorBuilder | ||
| { | ||
| public: | ||
| static void Register(opentelemetry::sdk::configuration::Registry *registry); | ||
|
|
||
| std::unique_ptr<opentelemetry::sdk::logs::LogRecordProcessor> Build( | ||
| const opentelemetry::sdk::configuration::ExtensionLogRecordProcessorConfiguration *model) | ||
| const override; | ||
| }; |
This file contains hidden or 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,31 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include "opentelemetry/sdk/common/global_log_handler.h" | ||
|
|
||
| #include "custom_pull_metric_exporter.h" | ||
|
|
||
| opentelemetry::sdk::metrics::AggregationTemporality | ||
| CustomPullMetricExporter::GetAggregationTemporality( | ||
| opentelemetry::sdk::metrics::InstrumentType /* instrument_type */) const noexcept | ||
| { | ||
| OTEL_INTERNAL_LOG_ERROR("CustomPullMetricExporter::GetAggregationTemporality(): YOUR CODE HERE"); | ||
| return opentelemetry::sdk::metrics::AggregationTemporality::kCumulative; | ||
| } | ||
|
|
||
| bool CustomPullMetricExporter::OnForceFlush(std::chrono::microseconds /* timeout */) noexcept | ||
| { | ||
| OTEL_INTERNAL_LOG_ERROR("CustomPullMetricExporter::OnForceFlush(): YOUR CODE HERE"); | ||
| return true; | ||
| } | ||
|
|
||
| bool CustomPullMetricExporter::OnShutDown(std::chrono::microseconds /* timeout */) noexcept | ||
| { | ||
| OTEL_INTERNAL_LOG_ERROR("CustomPullMetricExporter::OnShutDown(): YOUR CODE HERE"); | ||
| return true; | ||
| } | ||
|
|
||
| void CustomPullMetricExporter::OnInitialized() noexcept | ||
| { | ||
| OTEL_INTERNAL_LOG_ERROR("CustomPullMetricExporter::OnInitialized(): YOUR CODE HERE"); | ||
| } |
This file contains hidden or 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,30 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <chrono> | ||
| #include <string> | ||
|
|
||
| #include "opentelemetry/sdk/metrics/instruments.h" | ||
| #include "opentelemetry/sdk/metrics/metric_reader.h" | ||
|
|
||
| class CustomPullMetricExporter : public opentelemetry::sdk::metrics::MetricReader | ||
| { | ||
| public: | ||
| CustomPullMetricExporter(const std::string & /* comment */) {} | ||
| CustomPullMetricExporter(CustomPullMetricExporter &&) = delete; | ||
| CustomPullMetricExporter(const CustomPullMetricExporter &) = delete; | ||
| CustomPullMetricExporter &operator=(CustomPullMetricExporter &&) = delete; | ||
| CustomPullMetricExporter &operator=(const CustomPullMetricExporter &other) = delete; | ||
| ~CustomPullMetricExporter() override = default; | ||
|
|
||
| opentelemetry::sdk::metrics::AggregationTemporality GetAggregationTemporality( | ||
| opentelemetry::sdk::metrics::InstrumentType instrument_type) const noexcept override; | ||
|
|
||
| bool OnForceFlush(std::chrono::microseconds timeout) noexcept override; | ||
|
|
||
| bool OnShutDown(std::chrono::microseconds timeout) noexcept override; | ||
|
|
||
| void OnInitialized() noexcept override; | ||
| }; |
32 changes: 32 additions & 0 deletions
32
examples/configuration/custom_pull_metric_exporter_builder.cc
This file contains hidden or 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,32 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/document_node.h" | ||
| #include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/registry.h" | ||
| #include "opentelemetry/sdk/metrics/metric_reader.h" | ||
|
|
||
| #include "custom_pull_metric_exporter.h" | ||
| #include "custom_pull_metric_exporter_builder.h" | ||
|
|
||
| std::unique_ptr<opentelemetry::sdk::metrics::MetricReader> CustomPullMetricExporterBuilder::Build( | ||
| const opentelemetry::sdk::configuration::ExtensionPullMetricExporterConfiguration *model) const | ||
| { | ||
| // Read yaml attributes | ||
| std::string comment = model->node->GetRequiredString("comment"); | ||
|
|
||
| auto sdk = std::make_unique<CustomPullMetricExporter>(comment); | ||
|
|
||
| return sdk; | ||
| } | ||
|
|
||
| void CustomPullMetricExporterBuilder::Register( | ||
| opentelemetry::sdk::configuration::Registry *registry) | ||
| { | ||
| auto builder = std::make_unique<CustomPullMetricExporterBuilder>(); | ||
| registry->SetExtensionPullMetricExporterBuilder("my_custom_pull_metric_exporter", | ||
| std::move(builder)); | ||
| } |
22 changes: 22 additions & 0 deletions
22
examples/configuration/custom_pull_metric_exporter_builder.h
This file contains hidden or 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,22 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_builder.h" | ||
| #include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_configuration.h" | ||
| #include "opentelemetry/sdk/configuration/registry.h" | ||
| #include "opentelemetry/sdk/metrics/metric_reader.h" | ||
|
|
||
| class CustomPullMetricExporterBuilder | ||
| : public opentelemetry::sdk::configuration::ExtensionPullMetricExporterBuilder | ||
| { | ||
| public: | ||
| static void Register(opentelemetry::sdk::configuration::Registry *registry); | ||
|
|
||
| std::unique_ptr<opentelemetry::sdk::metrics::MetricReader> Build( | ||
| const opentelemetry::sdk::configuration::ExtensionPullMetricExporterConfiguration *model) | ||
| const override; | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.