Skip to content

Commit c6c18d3

Browse files
committed
feat(Tool sync): Log/defaults polish
1 parent 9fb6c06 commit c6c18d3

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

tools/Propulsion.Tool/Infrastructure.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module EnvVar =
2121
module Sinks =
2222

2323
let equinoxMetricsOnly (l: LoggerConfiguration) =
24-
l.WriteTo.Sink(Equinox.CosmosStore.Core.Log.InternalMetrics.Stats.LogSink())
24+
l.WriteTo.Sink(Equinox.CosmosStore.Core.Log.InternalMetrics.Stats.LogSink(categorize = true))
2525
.WriteTo.Sink(Equinox.DynamoStore.Core.Log.InternalMetrics.Stats.LogSink())
2626
let console verbose (configuration: LoggerConfiguration) =
2727
let outputTemplate =
@@ -64,7 +64,7 @@ type Logging() =
6464
module CosmosStoreConnector =
6565

6666
let private get (role: string) (client: Microsoft.Azure.Cosmos.CosmosClient) databaseId containerId =
67-
Log.Information("CosmosDB {role} Database {database} Container {container}", role, databaseId, containerId)
67+
Log.Information("CosmosDB {role} {database}/{container}", role, databaseId, containerId)
6868
client.GetDatabase(databaseId).GetContainer(containerId)
6969
let getSource = get "Source"
7070
let getLeases = get "Leases"
@@ -74,7 +74,7 @@ type Logging() =
7474
type Equinox.CosmosStore.CosmosStoreContext with
7575

7676
member x.LogConfiguration(role, databaseId: string, containerId: string) =
77-
Log.Information("CosmosStore {role:l} {db}/{container} Tip maxEvents {maxEvents} maxSize {maxJsonLen} Query maxItems {queryMaxItems}",
77+
Log.Information("CosmosStore {role:l} {database}/{container} Tip maxEvents {maxEvents} maxSize {maxJsonLen} Query maxItems {queryMaxItems}",
7878
role, databaseId, containerId, x.TipOptions.MaxEvents, x.TipOptions.MaxJsonLength, x.QueryOptions.MaxItems)
7979

8080
type Equinox.CosmosStore.CosmosStoreClient with
@@ -89,7 +89,7 @@ type Logging() =
8989
member private x.LogConfiguration(role, databaseId: string, containers: string[]) =
9090
let o = x.Options
9191
let timeout, retries429, timeout429 = o.RequestTimeout, o.MaxRetryAttemptsOnRateLimitedRequests, o.MaxRetryWaitTimeOnRateLimitedRequests
92-
Log.Information("CosmosDB {role} {mode} {endpointUri} {db} {containers} timeout {timeout}s Throttling retries {retries}, max wait {maxRetryWaitTime}s",
92+
Log.Information("CosmosDB {role} {mode} {endpointUri} {database}/{containers} timeout {timeout}s Retries {retries}<{maxRetryWaitTime}s",
9393
role, o.ConnectionMode, x.Endpoint, databaseId, containers, timeout.TotalSeconds, retries429, let t = timeout429.Value in t.TotalSeconds)
9494
member private x.CreateAndInitialize(role, databaseId, containers) =
9595
x.LogConfiguration(role, databaseId, containers)

tools/Propulsion.Tool/Sync.fs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type [<NoEquality; NoComparison; RequireSubcommand>] Parameters =
3030
interface IArgParserTemplate with
3131
member a.Usage = a |> function
3232
| ConsumerGroupName _ -> "Projector instance context name. Optional if source is JSON"
33-
| MaxReadAhead _ -> "maximum number of batches to let processing get ahead of completion. Default: File: 32768 Other: 2."
33+
| MaxReadAhead _ -> "maximum number of batches to let processing get ahead of completion. Default: File: 32768 Other: 4."
3434
| MaxWriters _ -> "maximum number of concurrent streams on which to process at any time. Default: 8 (Cosmos: 16)."
3535
| FromTail -> "(iff fresh projection) - force starting from present Position. Default: Ensure each and every event is projected from the start."
3636
| Follow -> "Stop when the Tail is reached."
@@ -40,7 +40,7 @@ type [<NoEquality; NoComparison; RequireSubcommand>] Parameters =
4040
"Default: assume events arrive from the changefeed (and/or the input JSON file) without any gaps or out of order deliveries for any stream."
4141
| EventsOnly -> "Exclude Unfolds from processing. Default: Unfolds are read, parsed and processed"
4242
| Categorize -> "Gather handler latency stats by category"
43-
| MaxItems _ -> "Limits RU consumption when reading; impacts checkpointing granularity by adjusting the batch size being loaded from the feed. Default (Sync): 9999. Default: Unlimited"
43+
| MaxItems _ -> "Limits RU consumption when reading; impacts checkpointing granularity by adjusting the batch size being loaded from the feed. Default (Sync): 9999. Default: 100 (CosmosClient default)"
4444

4545
| ExcSys -> "Exclude System streams. Default: Include Index Streams, identified by a $ prefix."
4646
| IncCat _ -> "Allow Stream Category. Multiple values are combined with OR. Default: include all, subject to Category Deny and Stream Deny rules."
@@ -61,7 +61,7 @@ and Arguments(c, p: ParseResults<Parameters>) =
6161
includeSystem = not (p.Contains ExcSys),
6262
allowEts = p.GetResults IncEvent, denyEts = p.GetResults ExcEvent)
6363
member val Categorize = p.Contains Categorize
64-
member val IncludeUnfolds = not (p.Contains EventsOnly)
64+
member val EventsOnly = p.Contains EventsOnly
6565
member val Command =
6666
match p.GetSubCommand() with
6767
| Kafka a -> KafkaArguments(c, a) |> SubCommand.Kafka
@@ -122,7 +122,7 @@ and [<NoEquality; NoComparison; RequireSubcommand>] CosmosParameters =
122122
| Container _ -> "specify a container name for store."
123123
| LeaseContainerId _ -> "store leases in Sync target DB (default: use `-aux` adjacent to the Source Container). Enables the Source to be read via a ReadOnly connection string."
124124
| Timeout _ -> "specify operation timeout in seconds. Default: 5."
125-
| Retries _ -> "specify operation retries. Default: 0."
125+
| Retries _ -> "specify operation retries. Default: 2."
126126
| RetriesWaitTime _ -> "specify max wait-time for retry when being throttled by Cosmos in seconds. Default: 5."
127127
| MaxKiB _ -> "specify maximum size in KiB to pass to the Sync stored proc (reduce if Malformed Streams due to 413 RequestTooLarge responses). Default: 128."
128128
| From _ -> "Specify Source."
@@ -133,9 +133,9 @@ and CosmosArguments(c: Args.Configuration, p: ParseResults<CosmosParameters>) =
133133
| Json _ -> p.GetResult Connection
134134
| x -> p.Raise $"unexpected subcommand %A{x}"
135135
let connector =
136-
let timeout = p.GetResult(Timeout, 5.) |> TimeSpan.seconds
137-
let retries = p.GetResult(Retries, 1)
138-
let maxRetryWaitTime = p.GetResult(RetriesWaitTime, 5.) |> TimeSpan.seconds
136+
let timeout = p.GetResult(Timeout, 5) |> TimeSpan.seconds
137+
let retries = p.GetResult(Retries, 2)
138+
let maxRetryWaitTime = p.GetResult(RetriesWaitTime, 5) |> TimeSpan.seconds
139139
Equinox.CosmosStore.CosmosStoreConnector(Equinox.CosmosStore.Discovery.ConnectionString connection, timeout, retries, maxRetryWaitTime)
140140
let database = match source.Store with
141141
| Cosmos c -> p.GetResult(Database, fun () -> c.Database)
@@ -238,10 +238,10 @@ let run appName (c: Args.Configuration, p: ParseResults<Parameters>) = async {
238238
let isFileSource = match a.Command.Source with Json _ -> true | _ -> false
239239
let parse =
240240
a.Filters.CreateStreamFilter()
241-
|> if a.IncludeUnfolds then Propulsion.CosmosStore.EquinoxSystemTextJsonParser.eventsAndUnfoldsWhereStream
242-
else Propulsion.CosmosStore.EquinoxSystemTextJsonParser.whereStream
241+
|> if a.EventsOnly then Propulsion.CosmosStore.EquinoxSystemTextJsonParser.whereStream
242+
else Propulsion.CosmosStore.EquinoxSystemTextJsonParser.eventsAndUnfoldsWhereStream
243243
let statsInterval, stateInterval = a.StatsInterval, a.StateInterval
244-
let maxReadAhead = p.GetResult(MaxReadAhead, if isFileSource then 32768 else 2)
244+
let maxReadAhead = p.GetResult(MaxReadAhead, if isFileSource then 32768 else 4)
245245
let maxConcurrentProcessors = p.GetResult(MaxWriters, 8)
246246
let sink =
247247
match a.Command with

0 commit comments

Comments
 (0)