Repository navigation
Fix Event Hub telemetry logging without an EventContext - #823
Merged
moprashant merged 1 commit intoOct 13, 2026
Merged
Conversation
Use persisted context for ordinary logging states and handle null state safely. Add regression coverage for context-free logs and existing structured event behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d7afa8f5-e846-41bf-bf84-842b11a52ef4
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Bryan DeYoung (brdeyo)
approved these changes
Oct 13, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fix
EventHubTelemetryLoggerfor enabled log calls whose state is not anEventContext, including null state.CreateEventcasts the state toEventContext, butCreateEventObjectimmediately accesses its properties. OrdinaryILogger.LogInformation("Processed {Count} items", 42)calls therefore produceEventHubTelemetryLogger.LoggingErrorrather than the intended event. Null state also throws when callingToString().Changes
state?.ToString()for the state-only message path.EventContext.Persisted()only when no structured context was supplied.The production fix changes only two statements. Existing event-name precedence, formatter/exception message selection, structured contexts, channel behavior, and oversized-event handling remain unchanged.
Validation
EventHubTelemetryLogger.LoggingError; 7 existing/preservation cases pass.EventHubTelemetryLoggerTestscases pass.build-test.cmd): still running; result will be added when available.Risk
This is a narrow null-context fix in shared logging code. Previously failing ordinary logs will now be serialized and offered to the channel, using ambient correlation and persistent properties. This adds context allocation and can change delivered telemetry volume. Regression tests cover the affected path and preservation of structured events; performance overhead and live Event Hub delivery have not been measured. No benchmark/workload execution logic is changed.