Skip to content

Commit 2d223d8

Browse files
committed
Moved runtime options to a dedicated structure.
1 parent 809ade7 commit 2d223d8

36 files changed

+568
-89
lines changed

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "opentelemetry/exporters/otlp/otlp_http_client.h"
1010
#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h"
11+
#include "opentelemetry/exporters/otlp/otlp_http_exporter_runtime_options.h"
1112
#include "opentelemetry/nostd/span.h"
1213
#include "opentelemetry/sdk/common/exporter_utils.h"
1314
#include "opentelemetry/sdk/trace/exporter.h"
@@ -36,6 +37,12 @@ class OPENTELEMETRY_EXPORT OtlpHttpExporter final : public opentelemetry::sdk::t
3637
*/
3738
explicit OtlpHttpExporter(const OtlpHttpExporterOptions &options);
3839

40+
/**
41+
* Create an OtlpHttpExporter using the given options.
42+
*/
43+
OtlpHttpExporter(const OtlpHttpExporterOptions &options,
44+
const OtlpHttpExporterRuntimeOptions &runtime_options);
45+
3946
/**
4047
* Create a span recordable.
4148
* @return a newly initialized Recordable object
@@ -69,7 +76,9 @@ class OPENTELEMETRY_EXPORT OtlpHttpExporter final : public opentelemetry::sdk::t
6976

7077
private:
7178
// The configuration options associated with this exporter.
72-
const OtlpHttpExporterOptions options_;
79+
OtlpHttpExporterOptions options_;
80+
// The runtime options associated with this exporter.
81+
OtlpHttpExporterRuntimeOptions runtime_options_;
7382

7483
// Object that stores the HTTP sessions that have been created
7584
std::unique_ptr<OtlpHttpClient> http_client_;

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_factory.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <memory>
77

88
#include "opentelemetry/exporters/otlp/otlp_http_exporter_options.h"
9+
#include "opentelemetry/exporters/otlp/otlp_http_exporter_runtime_options.h"
910
#include "opentelemetry/sdk/trace/exporter.h"
1011
#include "opentelemetry/version.h"
1112

@@ -31,6 +32,13 @@ class OPENTELEMETRY_EXPORT OtlpHttpExporterFactory
3132
*/
3233
static std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> Create(
3334
const OtlpHttpExporterOptions &options);
35+
36+
/**
37+
* Create an OtlpHttpExporter using the given options.
38+
*/
39+
static std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> Create(
40+
const OtlpHttpExporterOptions &options,
41+
const OtlpHttpExporterRuntimeOptions &runtime_options);
3442
};
3543

3644
} // namespace otlp

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
#pragma once
55

66
#include <chrono>
7-
#include <memory>
87
#include <string>
98

109
#include "opentelemetry/exporters/otlp/otlp_environment.h"
1110
#include "opentelemetry/exporters/otlp/otlp_http.h"
12-
#include "opentelemetry/sdk/common/thread_instrumentation.h"
1311
#include "opentelemetry/version.h"
1412

1513
OPENTELEMETRY_BEGIN_NAMESPACE
@@ -103,9 +101,6 @@ struct OPENTELEMETRY_EXPORT OtlpHttpExporterOptions
103101

104102
/** Compression type. */
105103
std::string compression;
106-
107-
std::shared_ptr<sdk::common::ThreadInstrumentation> thread_instrumentation =
108-
std::shared_ptr<sdk::common::ThreadInstrumentation>(nullptr);
109104
};
110105

111106
} // namespace otlp
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#pragma once
5+
6+
#include <memory>
7+
8+
#include "opentelemetry/sdk/common/thread_instrumentation.h"
9+
#include "opentelemetry/version.h"
10+
11+
OPENTELEMETRY_BEGIN_NAMESPACE
12+
namespace exporter
13+
{
14+
namespace otlp
15+
{
16+
17+
/**
18+
* Struct to hold OTLP HTTP traces exporter runtime options.
19+
*/
20+
struct OPENTELEMETRY_EXPORT OtlpHttpExporterRuntimeOptions
21+
{
22+
OtlpHttpExporterRuntimeOptions() = default;
23+
~OtlpHttpExporterRuntimeOptions() = default;
24+
25+
std::shared_ptr<sdk::common::ThreadInstrumentation> thread_instrumentation =
26+
std::shared_ptr<sdk::common::ThreadInstrumentation>(nullptr);
27+
};
28+
29+
} // namespace otlp
30+
} // namespace exporter
31+
OPENTELEMETRY_END_NAMESPACE

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "opentelemetry/exporters/otlp/otlp_http_client.h"
1010
#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h"
11+
#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_runtime_options.h"
1112
#include "opentelemetry/nostd/span.h"
1213
#include "opentelemetry/sdk/common/exporter_utils.h"
1314
#include "opentelemetry/sdk/logs/exporter.h"
@@ -37,6 +38,14 @@ class OtlpHttpLogRecordExporter final : public opentelemetry::sdk::logs::LogReco
3738
*/
3839
OtlpHttpLogRecordExporter(const OtlpHttpLogRecordExporterOptions &options);
3940

41+
/**
42+
* Create an OtlpHttpLogRecordExporter with user specified options.
43+
* @param options An object containing the user's configuration options.
44+
* @param runtime_options An object containing the user's runtime options.
45+
*/
46+
OtlpHttpLogRecordExporter(const OtlpHttpLogRecordExporterOptions &options,
47+
const OtlpHttpLogRecordExporterRuntimeOptions &runtime_options);
48+
4049
/**
4150
* Creates a recordable that stores the data in a JSON object
4251
*/
@@ -68,7 +77,9 @@ class OtlpHttpLogRecordExporter final : public opentelemetry::sdk::logs::LogReco
6877

6978
private:
7079
// Configuration options for the exporter
71-
const OtlpHttpLogRecordExporterOptions options_;
80+
OtlpHttpLogRecordExporterOptions options_;
81+
// Runtime options for the exporter
82+
OtlpHttpLogRecordExporterRuntimeOptions runtime_options_;
7283

7384
// Object that stores the HTTP sessions that have been created
7485
std::unique_ptr<OtlpHttpClient> http_client_;

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <memory>
77

88
#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h"
9+
#include "opentelemetry/exporters/otlp/otlp_http_log_record_exporter_runtime_options.h"
910
#include "opentelemetry/sdk/logs/exporter.h"
1011
#include "opentelemetry/version.h"
1112

@@ -31,6 +32,13 @@ class OPENTELEMETRY_EXPORT OtlpHttpLogRecordExporterFactory
3132
*/
3233
static std::unique_ptr<opentelemetry::sdk::logs::LogRecordExporter> Create(
3334
const OtlpHttpLogRecordExporterOptions &options);
35+
36+
/**
37+
* Create a OtlpHttpLogRecordExporter.
38+
*/
39+
static std::unique_ptr<opentelemetry::sdk::logs::LogRecordExporter> Create(
40+
const OtlpHttpLogRecordExporterOptions &options,
41+
const OtlpHttpLogRecordExporterRuntimeOptions &runtime_options);
3442
};
3543

3644
} // namespace otlp

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
#pragma once
55

66
#include <chrono>
7-
#include <memory>
87
#include <string>
98

109
#include "opentelemetry/exporters/otlp/otlp_environment.h"
1110
#include "opentelemetry/exporters/otlp/otlp_http.h"
12-
#include "opentelemetry/sdk/common/thread_instrumentation.h"
1311
#include "opentelemetry/version.h"
1412

1513
OPENTELEMETRY_BEGIN_NAMESPACE
@@ -103,9 +101,6 @@ struct OPENTELEMETRY_EXPORT OtlpHttpLogRecordExporterOptions
103101

104102
/** Compression type. */
105103
std::string compression;
106-
107-
std::shared_ptr<sdk::common::ThreadInstrumentation> thread_instrumentation =
108-
std::shared_ptr<sdk::common::ThreadInstrumentation>(nullptr);
109104
};
110105

111106
} // namespace otlp
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#pragma once
5+
6+
#include <memory>
7+
8+
#include "opentelemetry/sdk/common/thread_instrumentation.h"
9+
#include "opentelemetry/version.h"
10+
11+
OPENTELEMETRY_BEGIN_NAMESPACE
12+
namespace exporter
13+
{
14+
namespace otlp
15+
{
16+
17+
/**
18+
* Struct to hold OTLP HTTP log record exporter runtime options.
19+
*/
20+
struct OPENTELEMETRY_EXPORT OtlpHttpLogRecordExporterRuntimeOptions
21+
{
22+
OtlpHttpLogRecordExporterRuntimeOptions() = default;
23+
~OtlpHttpLogRecordExporterRuntimeOptions() = default;
24+
25+
std::shared_ptr<sdk::common::ThreadInstrumentation> thread_instrumentation =
26+
std::shared_ptr<sdk::common::ThreadInstrumentation>(nullptr);
27+
};
28+
29+
} // namespace otlp
30+
} // namespace exporter
31+
OPENTELEMETRY_END_NAMESPACE

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "opentelemetry/exporters/otlp/otlp_http_client.h"
1010
#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h"
11+
#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_runtime_options.h"
1112
#include "opentelemetry/sdk/common/exporter_utils.h"
1213
#include "opentelemetry/sdk/metrics/export/metric_producer.h"
1314
#include "opentelemetry/sdk/metrics/instruments.h"
@@ -36,6 +37,14 @@ class OtlpHttpMetricExporter final : public opentelemetry::sdk::metrics::PushMet
3637
*/
3738
OtlpHttpMetricExporter(const OtlpHttpMetricExporterOptions &options);
3839

40+
/**
41+
* Create an OtlpHttpMetricExporter with user specified options.
42+
* @param options An object containing the user's configuration options.
43+
* @param runtime_options An object containing the user's runtime options.
44+
*/
45+
OtlpHttpMetricExporter(const OtlpHttpMetricExporterOptions &options,
46+
const OtlpHttpMetricExporterRuntimeOptions &runtime_options);
47+
3948
/**
4049
* Get the AggregationTemporality for exporter
4150
*
@@ -58,7 +67,9 @@ class OtlpHttpMetricExporter final : public opentelemetry::sdk::metrics::PushMet
5867

5968
private:
6069
// Configuration options for the exporter
61-
const OtlpHttpMetricExporterOptions options_;
70+
OtlpHttpMetricExporterOptions options_;
71+
// Runtime options for the exporter
72+
OtlpHttpMetricExporterRuntimeOptions runtime_options_;
6273

6374
// Aggregation Temporality Selector
6475
const sdk::metrics::AggregationTemporalitySelector aggregation_temporality_selector_;

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <memory>
77

88
#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h"
9+
#include "opentelemetry/exporters/otlp/otlp_http_metric_exporter_runtime_options.h"
910
#include "opentelemetry/sdk/metrics/push_metric_exporter.h"
1011
#include "opentelemetry/version.h"
1112

@@ -31,6 +32,13 @@ class OPENTELEMETRY_EXPORT OtlpHttpMetricExporterFactory
3132
*/
3233
static std::unique_ptr<opentelemetry::sdk::metrics::PushMetricExporter> Create(
3334
const OtlpHttpMetricExporterOptions &options);
35+
36+
/**
37+
* Create a OtlpHttpMetricExporter.
38+
*/
39+
static std::unique_ptr<opentelemetry::sdk::metrics::PushMetricExporter> Create(
40+
const OtlpHttpMetricExporterOptions &options,
41+
const OtlpHttpMetricExporterRuntimeOptions &runtime_options);
3442
};
3543

3644
} // namespace otlp

0 commit comments

Comments
 (0)