Skip to content

Commit

Permalink
feat: initialize metrics with 0 to have them from application start (#…
Browse files Browse the repository at this point in the history
…497)

* feat: initialize metrics with 0 to have them from application start

* chore: dont do that for processes since the states are not known here

* chore: update changelog
  • Loading branch information
carstendietrich authored Oct 18, 2023
1 parent d94d942 commit fc771ac
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Changelog

## v3.9.0 [upcoming]

**search**

* Introduce an Action to search result to advise the frontend to perform an action for that search different from displaying the result page.
The action model is completely open to anything, but the most common use case is to redirect certain searches directly to product detail pages or special brand landing pages.

Expand All @@ -14,6 +12,8 @@
* GraphQL:
* Add new mutation `Commerce_Cart_UpdateItemBundleConfig` to update bundle configs for existing cart items

**checkout**
* initialize place order metrics with 0 on application start to follow prometheus best practices

## v3.8.0

Expand Down
4 changes: 3 additions & 1 deletion checkout/application/orderService.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ func init() {
}

for name, measure := range openCensusViews {
err := opencensus.View(name, measure, view.Count())
err := opencensus.View(name, measure, view.Sum())
if err != nil {
panic(err)
}

stats.Record(context.Background(), measure.M(0))
}
}

Expand Down
4 changes: 3 additions & 1 deletion checkout/application/placeorder/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ var (

func init() {
gob.Register(process.Context{})
err := opencensus.View("flamingo-commerce/checkout/placeorder/starts", startCount, view.Count())
err := opencensus.View("flamingo-commerce/checkout/placeorder/starts", startCount, view.Sum())
if err != nil {
panic(err)
}

stats.Record(context.Background(), startCount.M(0))
}

// Inject dependencies
Expand Down
1 change: 1 addition & 0 deletions checkout/domain/placeorder/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func init() {
if err := opencensus.View("flamingo-commerce/checkout/placeorder/state_run_count", processedState, view.Count(), keyState); err != nil {
panic(err)
}

if err := opencensus.View("flamingo-commerce/checkout/placeorder/state_failed_count", failedStateTransition, view.Count(), keyState); err != nil {
panic(err)
}
Expand Down

0 comments on commit fc771ac

Please sign in to comment.