-
Notifications
You must be signed in to change notification settings - Fork 772
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
Add support for OTEL_BSP_EXPORT_* environmental variables #2219
Add support for OTEL_BSP_EXPORT_* environmental variables #2219
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2219 +/- ##
==========================================
- Coverage 79.66% 79.63% -0.04%
==========================================
Files 232 233 +1
Lines 7294 7325 +31
==========================================
+ Hits 5811 5833 +22
- Misses 1483 1492 +9
|
namespace OpenTelemetry | ||
{ | ||
public class BatchExportProcessorOptions<T> | ||
where T : class | ||
{ | ||
internal const string MaxQueueSizeEnvVarKey = "OTEL_BSP_MAX_QUEUE_SIZE"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are specific to batch span processors, we need some logic to make sure it is not affecting other scenario (e.g. metrics).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any proposal on how to approach this?
I think that the root problem is that the .NET SDK tries to use common (premature?) abstractions to implement multiple OTel specification components. E.g. we have a common exporter base class for both metrics and traces exporter. I am aware it reduces some code duplication but it tightly couples the API and it may be hard to maintain backward compatibility going this way.
Can we use BatchExportProcessorOptions
for tracing (to not break SemVer) and create a BatchMetricsExportProcessorOptions
for metrics SDK?
Moreover, I think we should consider separating the metrics and traces SDKs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we did something like...
internal const string SpanMaxQueueSizeEnvVarKey = "OTEL_BSP_MAX_QUEUE_SIZE";
internal const string SpanMaxExportBatchSizeEnvVarKey = "OTEL_BSP_MAX_EXPORT_BATCH_SIZE";
internal const string SpanExporterTimeoutEnvVarKey = "OTEL_BSP_EXPORT_TIMEOUT";
internal const string SpanScheduledDelayEnvVarKey = "OTEL_BSP_SCHEDULE_DELAY";
public BatchExportProcessorOptions()
{
if (typeof(T) == typeof(Activity))
{
LoadSpanEnvVars();
}
}
private void LoadSpanEnvVars()
{
int value;
if (TryLoadEnvVarInt(SpanExporterTimeoutEnvVarKey, out value))
{
this.ExporterTimeoutMilliseconds = value;
}
if (TryLoadEnvVarInt(SpanMaxExportBatchSizeEnvVarKey, out value))
{
this.MaxExportBatchSize = value;
}
if (TryLoadEnvVarInt(SpanMaxQueueSizeEnvVarKey, out value))
{
this.MaxQueueSize = value;
}
if (TryLoadEnvVarInt(SpanScheduledDelayEnvVarKey, out value))
{
this.ScheduledDelayMilliseconds = value;
}
}
I'm not really a fan of duck typing in generics like this but trying to introduce classes into the hierarchy now will probably be a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CodeBlanch thanks 👍
but trying to introduce classes into the hierarchy now will probably be a breaking change
That is why I suggest changing the metrics SDK as AFAIK it od not stable yet. And leave the tracing SDK as it is.
Your proposal would work and probably it is the most pragmatic idea for this PR. But maybe it is worth taking a step back and make more refactoring in separate PR(s).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CodeBlanch
I noticed that OtlpMetricsExporter
uses OtlpExporterOptions
which has a BatchExportProcessorOptions<Activity>
.
Personally, I would prefer to redesign the OtlpMetricsExporter
. The main repository's readme says that metrics are experimental so probably it is acceptable. Then we could redesign OtlpMetricsExporter
to not have BatchExportProcessorOptions
as it is not used anyway. I think we could refactor OtlpMetricsExporter
as a separate issue+PR.
Regarding this PR I see the following options:
-
We could just improve the
BatchExportProcessorOptions
docs and say that this option is designed for the tracing SDK. -
Instead of "duck typing in generics" we could also possibly create a subclass
BatchSpanExportProcessorOptions
and use it like this:public BatchExportProcessorOptions<Activity> BatchExportProcessorOptions { get; set; } = new BatchSpanExportProcessorOptions();
not sure how much of a breaking change - I guess 99% of the existing code should simply work. Personally, I find such "common property grouping" as a code smell and possible premature abstraction. Will the exporters handle all of the possible options?
-
Use the "duck typing in generics" proposed here
Shouldn't the tracing and metrics packages be distributed separately to avoid confusion? How the user would distinguish between stable and unstable API?
@reyang PTAL as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the SIG meeting, I have an impression that this would be the preferred way forward:
- Create an issue that
OtlpMetricsExporter
should not referenceBatchExportProcessorOptions<Activity>
. Done here:OtlpMetricsExporter
should not referenceBatchExportProcessorOptions<Activity>
#2246 - Create a
BatchSpanExportProcessorOptions
as a subclass ofBatchExportProcessorOptions<Activity>
. Addressed here: 092ddea
@open-telemetry/dotnet-approvers PTAL |
f078cd0
to
917fd8d
Compare
@open-telemetry/dotnet-approvers could you PTAL, so we can close this one? It's been hanging here for quite a long time now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Sorry for my delayed response, I was focusing on the metrics part recently.
@@ -202,10 +202,24 @@ purposes, the SDK provides the following built-in processors: | |||
* [BatchExportProcessor<T>](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#batching-processor) | |||
: This is an exporting processor which batches the telemetry before sending to | |||
the configured exporter. | |||
|
|||
The following environment variables can be used to override the default | |||
values of the `BatchExportActivityProcessorOptions`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be a good idea to call out that this env variables affect all exporters unless individually overridden in code.
@pellared Merging this. Please take a note of couple of suggestion, and consider follow ups to address them. |
@cijothomas @CodeBlanch I have the follow-ups very high on my TODO list. I am just overwhelmed with other stuff ATM. |
Partially addresses #1453.
This feature is important so that we can reuse the SDK in https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation.
Changes
BatchExportProcessorOptions
defaults can be overridden usingOTEL_BSP_SCHEDULE_DELAY
,OTEL_BSP_EXPORT_TIMEOUT
,OTEL_BSP_MAX_QUEUE_SIZE
,OTEL_BSP_MAX_EXPORT_BATCH_SIZE
envionmental variables as defined in the
specification.