-
Notifications
You must be signed in to change notification settings - Fork 416
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
Convert Seq component to use OTEL's AddProcessor
instead of AddOtlpExporter
#3697
Conversation
…b.com/liammclennan/aspire into seq-component-switch-to-add-processor
…processor Seq component switch to add processor
public OtlpExporterOptions Logs | ||
{ | ||
get; | ||
private set; | ||
} = new (); |
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.
public OtlpExporterOptions Logs | |
{ | |
get; | |
private set; | |
} = new (); | |
public OtlpExporterOptions Logs { get; } = new(); |
No need for a private setter, it is never used.
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.
done
public OtlpExporterOptions Traces | ||
{ | ||
get; | ||
private set; | ||
} = new (); | ||
|
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.
public OtlpExporterOptions Traces | |
{ | |
get; | |
private set; | |
} = new (); | |
public OtlpExporterOptions Traces { get; } = new(); |
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.
done
)); | ||
|
||
if (settings.HealthChecks) | ||
if (settings is { HealthChecks: true, ServerUrl: not null }) |
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.
Should it be an error if you haven't set ServerUrl? Seems odd that setting HealthChecks = true
, but not getting health checks would be silent.
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.
I don't think it should be an error because a user could set Logs.EndPoint
or Traces.EndPoint
directly.
The combination of no ServerUrl
and HealthChecks == true
is never valid, so I will make that an error.
settings.ServerUrl = builder.Configuration.GetConnectionString(connectionName); | ||
settings.Logs.Protocol = OtlpExportProtocol.HttpProtobuf; | ||
settings.Traces.Protocol = OtlpExportProtocol.HttpProtobuf; | ||
|
||
builder.Configuration.GetSection("Aspire:Seq").Bind(settings); |
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.
The settings should continue to be bound to the configuration section before getting the connection string from connectionName
. That is consistent with every other component. The order of precedence goes (lower number wins):
- User code (
configureSettings
) always wins - ConnectionStrings w/ connection name
- Configuration section
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.
Thanks. Done.
} | ||
} | ||
builder.Services.Configure<OpenTelemetryLoggerOptions>(logging => logging.AddProcessor( | ||
sp => new BatchLogRecordExportProcessor(new OtlpLogExporter(settings.Logs)) |
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.
@liammclennan If you want to respect ExportProcessorType
make this...
builder.Services.Configure<OpenTelemetryLoggerOptions>(logging => logging.AddProcessor(
sp => settings.Logs.ExportProcessorType == ExportProcessorType.Batch
? new BatchLogRecordExportProcessor(new OtlpLogExporter(settings.Logs))
: new SimpleLogRecordExportProcessor(new OtlpLogExporter(settings.Logs))
));
Similar for below in tracing.
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.
Thanks for the review. I've made this change.
Throw an exception if ServerUrl is unspecified, but HealthChecks is e…
@reyang @davidfowl |
_ => settings.Logs.ExportProcessorType == ExportProcessorType.Batch | ||
? new BatchLogRecordExportProcessor(new OtlpLogExporter(settings.Logs)) | ||
: new SimpleLogRecordExportProcessor(new OtlpLogExporter(settings.Logs)) |
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.
switch expressions are much cleaner here:
_ => settings.Logs.ExportProcessorType == ExportProcessorType.Batch | |
? new BatchLogRecordExportProcessor(new OtlpLogExporter(settings.Logs)) | |
: new SimpleLogRecordExportProcessor(new OtlpLogExporter(settings.Logs)) | |
_ => settings.Logs.ExportProcessorType switch | |
ExportProcessorType.Batch => new BatchLogRecordExportProcessor(new OtlpLogExporter(settings.Logs)), | |
_ => new SimpleLogRecordExportProcessor(new OtlpLogExporter(settings.Logs)) |
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.
Thanks @davidfowl
This change is done.
public OtlpExporterOptions Logs | ||
{ | ||
get; | ||
} = new (); |
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.
This formatting is very weird:
public OtlpExporterOptions Logs | |
{ | |
get; | |
} = new (); | |
public OtlpExporterOptions Logs { get; } = new(); |
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.
Done
public OtlpExporterOptions Traces | ||
{ | ||
get; | ||
} = new (); | ||
|
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.
public OtlpExporterOptions Traces | |
{ | |
get; | |
} = new (); | |
public OtlpExporterOptions Traces { get; } = new(); | |
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.
Done
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. Thanks for the fix!
/backport to release/8.0 |
Started backporting to release/8.0: https://github.com/dotnet/aspire/actions/runs/8709142034 |
@eerhardt backporting to release/8.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Switch Seq OpenTelemetry configuration from `AddOtlpExporter` to `AddProcessor`.
Using index info to reconstruct a base tree...
M playground/seq/Seq.AppHost/aspire-manifest.json
A src/Components/Aspire.Seq/PublicAPI.Unshipped.txt
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): src/Components/Aspire.Seq/PublicAPI.Unshipped.txt deleted in HEAD and modified in Switch Seq OpenTelemetry configuration from `AddOtlpExporter` to `AddProcessor`.. Version Switch Seq OpenTelemetry configuration from `AddOtlpExporter` to `AddProcessor`. of src/Components/Aspire.Seq/PublicAPI.Unshipped.txt left in tree.
Auto-merging playground/seq/Seq.AppHost/aspire-manifest.json
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Switch Seq OpenTelemetry configuration from `AddOtlpExporter` to `AddProcessor`.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
@eerhardt an error occurred while backporting to release/8.0, please check the run log for details! Error: git am failed, most likely due to a merge conflict. |
…pExporter` (dotnet#3697) * Switch Seq OpenTelemetry configuration from `AddOtlpExporter` to `AddProcessor`. * Switch Seq OpenTelemetry configuration from `AddOtlpExporter` to `AddProcessor`. * Move OTLP exporter options onto SeqSettings.cs * Add test * Update README * Renamed Seq settings * Change order of config * Updated code doc * ConfigurationSchema.json * Throw an exception if ServerUrl is unspecified, but HealthChecks is enabled. * Fix tests * PR feedback Fix dotnet#3546
…pExporter` (#3697) (#3728) * Switch Seq OpenTelemetry configuration from `AddOtlpExporter` to `AddProcessor`. * Switch Seq OpenTelemetry configuration from `AddOtlpExporter` to `AddProcessor`. * Move OTLP exporter options onto SeqSettings.cs * Add test * Update README * Renamed Seq settings * Change order of config * Updated code doc * ConfigurationSchema.json * Throw an exception if ServerUrl is unspecified, but HealthChecks is enabled. * Fix tests * PR feedback Fix #3546 Co-authored-by: Liam McLennan <lmclennan@datalust.co>
OpenTelemetry's
AddOtlpExporter
now throws an exception, so the Seq component is not working.This PR switches to
AddProcessor
and adds some configuration work to compensate forAddProcessor
not picking up .NET's OTEL configuration (as described by @CodeBlanch here). AddingOtlpExporterOptions
onto Seq's configuration makes it possible to set the most vital options.Changes due to #3546
Thank you to @CodeBlanch for showing the way forward!
Microsoft Reviewers: Open in CodeFlow