Skip to content

Commit

Permalink
Logging tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Aug 19, 2023
1 parent b0acb9e commit a1ed78d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/Propulsion.CosmosStore/ChangeFeedProcessor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ type ChangeFeedProcessor =
let leaseRenewInterval = defaultArg leaseRenewInterval (TimeSpan.FromSeconds 3.)
let leaseTtl = defaultArg leaseTtl (TimeSpan.FromSeconds 10.)

log.Information("ChangeFeed {processorName} Lease acquire {leaseAcquireIntervalS:n0}s ttl {ttlS:n0}s renew {renewS:n0}s feedPollDelay {feedPollDelayS:n0}s",
processorName, leaseAcquireInterval.TotalSeconds, leaseTtl.TotalSeconds, leaseRenewInterval.TotalSeconds, feedPollDelay.TotalSeconds)
log.Information("ChangeFeed {processorName} Lease acquire {leaseAcquireIntervalS:n0}s ttl {ttlS:n0}s renew {renewS:n0}s feedPollDelay {feedPollDelayS:n0}s Items limit {maxItems}",
processorName, leaseAcquireInterval.TotalSeconds, leaseTtl.TotalSeconds, leaseRenewInterval.TotalSeconds, feedPollDelay.TotalSeconds, Option.toNullable maxItems)
let processorName_ = processorName + ":"
let leaseTokenToPartitionId (leaseToken : string) = int (leaseToken.Trim[|'"'|])
let processor =
Expand Down
2 changes: 1 addition & 1 deletion src/Propulsion/Sinks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module StreamResult =

let toIndex<'F> (span : FsCodec.ITimelineEvent<'F>[]) = function
| NoneProcessed -> span[0].Index
| AllProcessed -> span[0].Index + span.LongLength
| AllProcessed -> span[0].Index + span.LongLength // all-but equivalent to Events.nextIndex span
| PartiallyProcessed count -> span[0].Index + int64 count
| OverrideNextIndex index -> index

Expand Down
32 changes: 13 additions & 19 deletions tools/Propulsion.Tool/Args.fs
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,16 @@ type Configuration(tryGet : string -> string option) =

module Cosmos =

open Configuration.Cosmos

type Microsoft.Azure.Cosmos.Container with
module CosmosStoreConnector =

member private x.LogConfiguration(role) =
Log.Information("CosmosDb {role} Database {database} Container {container}", role, x.Database.Id, x.Id)
let logContainer (role: string) (databaseId: string) (containerId: string) =
Log.Information("CosmosDb {role} Database {database} Container {container}", role, databaseId, containerId)

type Microsoft.Azure.Cosmos.CosmosClient with

member x.CreateMonitoredAndLeases(databaseId, containerId, auxContainerId) =
let db = x.GetDatabase(databaseId)
let monitored, leases = db.GetContainer(containerId), db.GetContainer(auxContainerId)
monitored.LogConfiguration("Source")
leases.LogConfiguration("Leases")
monitored, leases
let createMonitoredAndLeases (client: Microsoft.Azure.Cosmos.CosmosClient) databaseId containerId auxContainerId =
logContainer "Source" databaseId containerId
logContainer "Leases" databaseId auxContainerId
let db = client.GetDatabase(databaseId)
db.GetContainer(containerId), db.GetContainer(auxContainerId)

type Equinox.CosmosStore.CosmosStoreConnector with

Expand All @@ -87,22 +82,21 @@ module Cosmos =
// NOTE uses CreateUninitialized as the Database/Container may not actually exist yet
member x.CreateLeasesContainer(databaseId, auxContainerId) =
x.LogConfiguration("Feed")
let leases = x.CreateUninitialized().GetDatabase(databaseId).GetContainer(auxContainerId)
leases.LogConfiguration("Leases")
leases
CosmosStoreConnector.logContainer "Leases" databaseId auxContainerId
x.CreateUninitialized().GetDatabase(databaseId).GetContainer(auxContainerId)

member x.ConnectFeed(databaseId, containerId, auxContainerId) = async {
x.LogConfiguration("Feed")
let! cosmosClient = x.Connect(databaseId, [| containerId; auxContainerId |])
return cosmosClient.CreateMonitoredAndLeases(databaseId, containerId, auxContainerId) }
return CosmosStoreConnector.createMonitoredAndLeases cosmosClient databaseId containerId auxContainerId }

/// Connect a CosmosStoreClient, including warming up
/// Configure with default packing and querying policies. Search for other `module CosmosStoreContext` impls for custom variations
/// Connect a CosmosStoreClient Configure with default packing and querying policies, including warming up
member x.Connect(role, databaseId, containerId: string) =
x.LogConfiguration(role, databaseId, containerId)
let maxEvents = 256
Equinox.CosmosStore.CosmosStoreContext.Connect(x, databaseId, containerId, tipMaxEvents = maxEvents)

open Configuration.Cosmos
type [<NoEquality; NoComparison>] Parameters =
| [<AltCommandLine "-m">] ConnectionMode of Microsoft.Azure.Cosmos.ConnectionMode
| [<AltCommandLine "-s">] Connection of string
Expand Down

0 comments on commit a1ed78d

Please sign in to comment.