diff --git a/CHANGELOG.md b/CHANGELOG.md index 03e7be2d3..3d5918dee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The `Unreleased` section name is replaced by the expected version of next releas ### Changed - Remove explicit `net461` handling; minimum target now `netstandard 2.1` / `net5.0` [#310](https://github.com/jet/equinox/pull/310) +- `EventStore/SqlStreamStore`: rename `Equinox.XXXStore.Log.Event` -> `Metric` to match `CosmosStore` [#311](https://github.com/jet/equinox/pull/311) ### Removed ### Fixed diff --git a/samples/Store/Integration/LogIntegration.fs b/samples/Store/Integration/LogIntegration.fs index c8ffd4846..0d49ba769 100644 --- a/samples/Store/Integration/LogIntegration.fs +++ b/samples/Store/Integration/LogIntegration.fs @@ -13,7 +13,7 @@ module EquinoxEsInterop = [] type FlatMetric = { action: string; stream : string; interval: StopwatchInterval; bytes: int; count: int; batches: int option } with override __.ToString() = sprintf "%s-Stream=%s %s-Elapsed=%O" __.action __.stream __.action __.interval.Elapsed - let flatten (evt : Log.Event) : FlatMetric = + let flatten (evt : Log.Metric) : FlatMetric = let action, metric, batches = match evt with | Log.WriteSuccess m -> "AppendToStreamAsync", m, None @@ -66,7 +66,7 @@ type SerilogMetricsExtractor(emit : string -> unit) = let (|EsMetric|CosmosMetric|GenericMessage|) (logEvent : Serilog.Events.LogEvent) = logEvent.Properties |> Seq.tryPick (function - | KeyValue (k, SerilogScalar (:? Equinox.EventStore.Log.Event as m)) -> Some <| Choice1Of3 (k,m) + | KeyValue (k, SerilogScalar (:? Equinox.EventStore.Log.Metric as m)) -> Some <| Choice1Of3 (k,m) | KeyValue (k, SerilogScalar (:? Equinox.CosmosStore.Core.Log.Metric as m)) -> Some <| Choice2Of3 (k,m) | _ -> None) |> Option.defaultValue (Choice3Of3 ()) diff --git a/src/Equinox.EventStore/EventStore.fs b/src/Equinox.EventStore/EventStore.fs index e6bea4f69..f5050e1b3 100755 --- a/src/Equinox.EventStore/EventStore.fs +++ b/src/Equinox.EventStore/EventStore.fs @@ -12,14 +12,14 @@ type Direction = Forward | Backward with module Log = - /// Name of Property used for Event in LogEvents. + /// Name of Property used for Metric in LogEvents. let [] PropertyTag = "esEvt" [] type Measurement = { stream : string; interval : StopwatchInterval; bytes : int; count : int } [] - type Event = + type Metric = | WriteSuccess of Measurement | WriteConflict of Measurement | Slice of Direction * Measurement @@ -48,7 +48,7 @@ module Log = /// Attach a property to the log context to hold the metrics // Sidestep Log.ForContext converting to a string; see https://github.com/serilog/serilog/issues/1124 - let event (value : Event) (log : ILogger) = + let event (value : Metric) (log : ILogger) = let enrich (e : LogEvent) = e.AddPropertyIfAbsent(LogEventProperty(PropertyTag, ScalarValue(value))) log.ForContext({ new Serilog.Core.ILogEventEnricher with member _.Enrich(evt, _) = enrich evt }) @@ -81,9 +81,9 @@ module Log = | :? ScalarValue as x -> Some x.Value | _ -> None - let (|EsMetric|_|) (logEvent : LogEvent) : Event option = + let (|EsMetric|_|) (logEvent : LogEvent) : Metric option = match logEvent.Properties.TryGetValue(PropertyTag) with - | true, SerilogScalar (:? Event as e) -> Some e + | true, SerilogScalar (:? Metric as e) -> Some e | _ -> None type Counter = @@ -230,7 +230,7 @@ module private Read = let reqMetric : Log.Measurement = { stream = streamName; interval = t; bytes = bytes; count = count} let batches = (events.Length - 1) / batchSize + 1 let action = match direction with Direction.Forward -> "LoadF" | Direction.Backward -> "LoadB" - let evt = Log.Event.Batch (direction, batches, reqMetric) + let evt = Log.Metric.Batch (direction, batches, reqMetric) (log |> Log.prop "bytes" bytes |> Log.event evt).Information( "Ges{action:l} stream={stream} count={count}/{batches} version={version}", action, streamName, count, batches, version) diff --git a/src/Equinox.SqlStreamStore/SqlStreamStore.fs b/src/Equinox.SqlStreamStore/SqlStreamStore.fs index a670dfaf2..ab35c18e5 100644 --- a/src/Equinox.SqlStreamStore/SqlStreamStore.fs +++ b/src/Equinox.SqlStreamStore/SqlStreamStore.fs @@ -18,13 +18,13 @@ type Direction = Forward | Backward with module Log = - /// Name of Property used for Event in LogEvents. + /// Name of Property used for Metric in LogEvents. let [] PropertyTag = "esEvt" [] type Measurement = { stream : string; interval : StopwatchInterval; bytes : int; count : int } [] - type Event = + type Metric = | WriteSuccess of Measurement | WriteConflict of Measurement | Slice of Direction * Measurement @@ -46,7 +46,7 @@ module Log = open Serilog.Events /// Attach a property to the log context to hold the metrics // Sidestep Log.ForContext converting to a string; see https://github.com/serilog/serilog/issues/1124 - let event (value : Event) (log : ILogger) = + let event (value : Metric) (log : ILogger) = let enrich (e : LogEvent) = e.AddPropertyIfAbsent(LogEventProperty(PropertyTag, ScalarValue(value))) log.ForContext({ new Serilog.Core.ILogEventEnricher with member __.Enrich(evt, _) = enrich evt }) let withLoggedRetries<'t> retryPolicy (contextLabel : string) (f : ILogger -> Async<'t>) log : Async<'t> = @@ -76,9 +76,9 @@ module Log = let (|SerilogScalar|_|) : LogEventPropertyValue -> obj option = function | :? ScalarValue as x -> Some x.Value | _ -> None - let (|EsMetric|_|) (logEvent : LogEvent) : Event option = + let (|EsMetric|_|) (logEvent : LogEvent) : Metric option = match logEvent.Properties.TryGetValue(PropertyTag) with - | true, SerilogScalar (:? Event as e) -> Some e + | true, SerilogScalar (:? Metric as e) -> Some e | _ -> None type Counter = { mutable count : int64; mutable ms : int64 } @@ -215,7 +215,7 @@ module private Read = let reqMetric : Log.Measurement = { stream = streamName; interval = t; bytes = bytes; count = count} let batches = (events.Length - 1)/batchSize + 1 let action = match direction with Direction.Forward -> "LoadF" | Direction.Backward -> "LoadB" - let evt = Log.Event.Batch (direction, batches, reqMetric) + let evt = Log.Metric.Batch (direction, batches, reqMetric) (log |> Log.prop "bytes" bytes |> Log.event evt).Information( "SqlEs{action:l} stream={stream} count={count}/{batches} version={version}", action, streamName, count, batches, version) diff --git a/tests/Equinox.EventStore.Integration/Infrastructure.fs b/tests/Equinox.EventStore.Integration/Infrastructure.fs index 08e01fca2..eac361c7d 100644 --- a/tests/Equinox.EventStore.Integration/Infrastructure.fs +++ b/tests/Equinox.EventStore.Integration/Infrastructure.fs @@ -56,7 +56,7 @@ module SerilogHelpers = | _ -> None [] type EsAct = Append | AppendConflict | SliceForward | SliceBackward | BatchForward | BatchBackward - let (|EsAction|) (evt : Log.Event) = + let (|EsAction|) (evt : Log.Metric) = match evt with | Log.WriteSuccess _ -> EsAct.Append | Log.WriteConflict _ -> EsAct.AppendConflict @@ -64,9 +64,9 @@ module SerilogHelpers = | Log.Slice (Direction.Backward,_) -> EsAct.SliceBackward | Log.Batch (Direction.Forward,_,_) -> EsAct.BatchForward | Log.Batch (Direction.Backward,_,_) -> EsAct.BatchBackward - let (|EsEvent|_|) (logEvent : LogEvent) : Log.Event option = + let (|EsEvent|_|) (logEvent : LogEvent) : Log.Metric option = logEvent.Properties.Values |> Seq.tryPick (function - | SerilogScalar (:? Log.Event as e) -> Some e + | SerilogScalar (:? Log.Metric as e) -> Some e | _ -> None) let (|HasProp|_|) (name : string) (e : LogEvent) : LogEventPropertyValue option =