Skip to content

Commit

Permalink
continue
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 7, 2023
1 parent c6b51f0 commit 2abc06d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 1 addition & 3 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Changelog

## Release 5.3
## Release 6.0

- The stats will not anymore be published on StatsD, use Prometheus client instead.
stats is no more initialized by default, you need to call `c2cwsgiutils.stats.init_backends(settings)` and
`c2cwsgiutils.config.include(metrics.includeme)` to initialize it.

## Release 5.2

Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
This is a Python 3 library (>=3.5) providing common tools for Camptocamp WSGI
applications:

- Provide a small framework for gathering performance statistics about
a web application (statsd protocol)
- Provide prometheus metrics
- Allow to use a master/slave PostgresQL configuration
- Logging handler for CEE/UDP logs
- An optional view to change runtime the log levels
Expand Down Expand Up @@ -504,8 +503,6 @@ def on_starting(server):

### Database metrics

Other functions exists to generate metrics. Look at the `c2cwsgiutils.stats` module.

Look at the `c2cwsgiutils-stats-db` utility if you want to generate statistics (gauges) about the
row counts.

Expand Down
13 changes: 9 additions & 4 deletions acceptance_tests/app/c2cwsgiutils_app/services.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

import prometheus_client
import requests
from pyramid.httpexceptions import (
HTTPBadRequest,
Expand All @@ -10,10 +11,14 @@
)

from c2cwsgiutils import sentry, services
from c2cwsgiutils.stats import increment_counter, set_gauge, timer_context

from c2cwsgiutils_app import models

_PROMETHEUS_TEST_COUNTER = prometheus_client.Counter("test_counter", "Test counter")
_PROMETHEUS_TEST_GAUGE = prometheus_client.Gauge("test_gauge", "Test gauge", ["value", "toto"])
_PROMETHEUS_TEST_SUMMARY = prometheus_client.Summary("test_summary", "Test summary")


ping_service = services.create("ping", "/ping")
hello_service = services.create("hello", "/hello", cors_credentials=True)
error_service = services.create("error", "/error")
Expand All @@ -39,10 +44,10 @@ def hello_get(request):
"""
Will use the slave.
"""
with timer_context(["sql", "read_hello"]):
with _PROMETHEUS_TEST_SUMMARY.time():
hello = request.dbsession.query(models.Hello).first()
increment_counter(["test", "counter"])
set_gauge(["test", "gauge/s"], 42, tags={"value": 24, "toto": "tutu"})
_PROMETHEUS_TEST_COUNTER.inc()
_PROMETHEUS_TEST_GAUGE.labels(value=24, toto="tutu").set(42)
return {"value": hello.value}


Expand Down

0 comments on commit 2abc06d

Please sign in to comment.