Skip to content
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

Request Header #83

Open
steveoh opened this issue Jun 22, 2020 · 4 comments
Open

Request Header #83

steveoh opened this issue Jun 22, 2020 · 4 comments
Milestone

Comments

@steveoh
Copy link

steveoh commented Jun 22, 2020

I setup the correlation id with EnforceHeader = false; and IgnoreRequestHeader = true;. T

he warning is still emitted.

(CorrelationId.CorrelationIdMiddleware) No correlation ID was found in the request headers

I would think that if these two properties are set up this way then there shouldn't be a need to read the headers at all. Am I misunderstanding the properties?

if (!hasCorrelationIdHeader && _options.EnforceHeader)
{
Log.EnforcedCorrelationIdHeaderMissing(_logger);
context.Response.StatusCode = StatusCodes.Status400BadRequest;
await context.Response.WriteAsync($"The '{_options.RequestHeader}' request header is required, but was not found.");
return;
}
var correlationId = hasCorrelationIdHeader ? cid.FirstOrDefault() : null;
if (hasCorrelationIdHeader)
{
Log.FoundCorrelationIdHeader(_logger, correlationId);
}
else
{
Log.MissingCorrelationIdHeader(_logger);
}
if (_options.IgnoreRequestHeader || RequiresGenerationOfCorrelationId(hasCorrelationIdHeader, cid))
{
correlationId = GenerateCorrelationId(context);

@stevejgordon
Copy link
Owner

Thanks for reporting this @steveoh. You are correct, that would make sense and be a small perf gain. Although I doubt it, making this change could be breaking for some users if they for some reason depend on that log message. For now, I'll slate this for a 4.0 release.

In the time being, you could filter out those messages from being logged.

@steveoh
Copy link
Author

steveoh commented Sep 23, 2020

How's the 4.0 development going? The log messages are getting rather annoying.

@stevejgordon
Copy link
Owner

@steveoh It's been a bit delayed through other commitments. Hoping to carve some time out in the next few months to look at things in a solid block. Did you manage to filter the log messages to reduce the false warnings?

@steveoh
Copy link
Author

steveoh commented Sep 30, 2020

I have "CorrelationId": "Information" and I suppose I could turn it up to Warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants