Skip to content

Commit

Permalink
Add Continuation to debug traces (#896)
Browse files Browse the repository at this point in the history
* Adding log

* tests

* Version bump
  • Loading branch information
ealsur authored Jun 12, 2024
1 parent d3189ef commit eae7c4c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- Extensions can have independent versions and only increment when released -->
<Version>3.0.0$(VersionSuffix)</Version>
<ExtensionsVersion>5.0.0$(VersionSuffix)</ExtensionsVersion> <!-- WebJobs.Extensions -->
<CosmosDBVersion>4.6.1$(VersionSuffix)</CosmosDBVersion>
<CosmosDBVersion>4.7.0$(VersionSuffix)</CosmosDBVersion>
<HttpVersion>3.2.0$(VersionSuffix)</HttpVersion>
<MobileAppsVersion>3.0.0$(VersionSuffix)</MobileAppsVersion>
<SendGridVersion>3.0.3$(VersionSuffix)</SendGridVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Task OnLeaseReleaseAsync(string leaseToken)

public void OnChangesDelivered(ChangeFeedProcessorContext context)
{
this.logger.LogDebug(Events.OnDelivery, "Events delivered to lease {LeaseToken} with diagnostics {Diagnostics}", context.LeaseToken, context.Diagnostics);
this.logger.LogDebug(Events.OnDelivery, "Events delivered to lease {LeaseToken}, Continuation {Continuation} with diagnostics {Diagnostics}", context.LeaseToken, context.Headers.ContinuationToken, context.Diagnostics);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<WarningsAsErrors />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.38.1" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.41.0" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.37" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.7.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,21 @@ public void LogsOnChangesDelivered()
string diagnosticsString = Guid.NewGuid().ToString();
Mock<CosmosDiagnostics> diagnostics = new Mock<CosmosDiagnostics>();
diagnostics.Setup(m => m.ToString()).Returns(diagnosticsString);
Headers headers = new Headers();
string continuationValue = Guid.NewGuid().ToString();
headers["x-ms-continuation"] = continuationValue;
Mock<ChangeFeedProcessorContext> context = new Mock<ChangeFeedProcessorContext>();
context.Setup(m => m.LeaseToken).Returns(leaseToken);
context.Setup(m => m.Diagnostics).Returns(diagnostics.Object);

context.Setup(m => m.Headers).Returns(headers);
cosmosDBTriggerHealthMonitor.OnChangesDelivered(context.Object);

Assert.Single(mockedLogger.Events);

LogEvent loggedEvent = mockedLogger.Events[0];
Assert.Equal(LogLevel.Debug, loggedEvent.LogLevel);
Assert.Null(loggedEvent.Exception);
Assert.True(loggedEvent.Message.Contains(leaseToken) && loggedEvent.Message.Contains(diagnosticsString));
Assert.True(loggedEvent.Message.Contains(leaseToken) && loggedEvent.Message.Contains(diagnosticsString) && loggedEvent.Message.Contains(continuationValue));
}

[Theory]
Expand Down

0 comments on commit eae7c4c

Please sign in to comment.