Commit Graph

106 Commits

Author SHA1 Message Date
Daniel García Aubert
762a240890 Breaking changes:
- Log system revamp:
  - Logs to stdout, disabled while testing
  - Use header `X-Request-Id`, or create a new `uuid` when no present, to identyfy log entries
  - Be able to set log level from env variable `LOG_LEVEL`, useful while testing: `LOG_LEVEL=info npm test`; even more human-readable: `LOG_LEVEL=info npm t | ./node_modules/.bin/pino-pretty`
  - Be able to reduce the footprint in the final log file depending on the environment
  - Use one logger for every service: Queries, Batch Queries (Jobs), and Data Ingestion (CopyTo/CopyFrom)
  - Stop using headers such as: `X-SQL-API-Log`, `X-SQL-API-Profiler`, and `X-SQL-API-Errors` as a way to log info.
  - Be able to tag requests with labels as an easier way to provide business metrics
  - Metro: Add log-collector utility (`metro`), it will be moved to its own repository. Attaching it here fro development purposes. Try it with the following command `LOG_LEVEL=info npm t | node metro`
  - Metro: Creates `metrics-collector.js` a stream to update Prometheus' counters and histograms and exposes them via Express' app (`:9145/metrics`). Use the ones defined in `grok_exporter`

Announcements:
- Profiler is always set. No need to check its existence anymore
- Unify profiler usage for every endpoint

Bug fixes:
- Avoid hung requests while fetching user identifier
2020-06-30 17:42:59 +02:00
Daniel García Aubert
0c92fcaf96 Node.js 12 support:
- Update `gc-stats` to version 1.4.0
- Replace `zipfile` -> `adm-zip`
- Update `libxmljs` to version 0.19.7
- Update `sqlite` to version 4.2.0
- Adapted pool acquires to the new version of `cartodb-redis`
- Adapted test to use `adm-zip`
2020-05-18 11:32:41 +02:00
Esther Lozano
419adea234
Add pubsub metrics (#642)
* Create middleware and service for pubsub metrics

* Use pubsub middleware for all request

* Replace isEnabled with isDisabled to avoid negation

* Use new headers names

* Add acceptance and unit tests

* Remove commented log calls

* Remove only filters in tests

Remove typo

* Refactor service to ease integration test

* Fix interaction with query controller

* Use middleware at api-router and test all controllers

* Rename user middleware function

* Use sinon latest version

* Create middleware and service for pubsub metrics

* Use pubsub middleware for all request

* Replace isEnabled with isDisabled to avoid negation

* Use new headers names

* Add acceptance and unit tests

* Remove commented log calls

* Remove only filters in tests

Remove typo

* Refactor service to ease integration test

* Fix interaction with query controller

* Use middleware at api-router and test all controllers

* Rename user middleware function

* Use sinon latest version

* Fix tests

* Fix typos

* Checks if pubsub config exists to enable the service

* Fix typo

* Normalize headers values for pubsub

* Trim fields when normalizing

* Trim fields when normalizing
2020-02-26 17:19:06 +01:00
Daniel García Aubert
014158c968 Eslint errors 2019-12-26 17:46:27 +01:00
Daniel García Aubert
ac7d60d97d Fix lint errors 2019-12-26 14:51:09 +01:00
Daniel García Aubert
e242d94d30 Fix eslint errors 2019-12-26 14:38:53 +01:00
Daniel García Aubert
cc535b13d2 Use asert.strict mode 2019-12-26 14:23:21 +01:00
Daniel García Aubert
5a96dbb59c Run eslint --fix 2019-12-23 18:19:08 +01:00
Daniel García Aubert
06a47a8afc Changed folder structure to reflect application functionallity. Renamed files using hyphens instead of underscore to have a more consistent naming across the whole project 2019-10-03 18:24:39 +02:00
Daniel García Aubert
1905a2bd28 Please, jshint 2019-04-04 15:16:44 +02:00
Daniel García Aubert
2e2e233b68 Use 'bunyan' logger instead of 'debug' to log debug messages 2019-04-04 14:31:41 +02:00
Rafa de la Torre
aeec1922ee Fix test and add const #543 2018-12-05 19:15:57 +01:00
Rafa de la Torre
b6251568eb Test first, with hardcoded values (WIP) #543 2018-12-05 18:59:11 +01:00
Rafa de la Torre
8505857412 Make error_handler.test.js independent from other tests #543
This is needed to avoid a "test race" and get it closer to a real unit
test.

When running it along with others it passes:

```
$ make test-unit
...
  48 passing (54ms)
  12 pending
```

(note it relies on the ordering produced by `find`)

when running it along with some other test that reads the config, it
works as well:

```
$ test/run_tests.sh  test/unit/apikeyauth.test.js test/unit/error_handler.test.js
...
  3 passing (9ms)
  12 pending
```

but when run in isolation, it fails:

```
$ test/run_tests.sh test/unit/error_handler.test.js
...
  0 passing (15ms)
  3 failing

  1) error-handler should return a header with errors:
     TypeError: Cannot read property 'environment' of undefined
      at errorMiddleware (app/middlewares/error.js:10:28)
      at Context.<anonymous> (test/unit/error_handler.test.js:53:26)

  2) error-handler JSONP should return a header with error statuscode:
     TypeError: Cannot read property 'environment' of undefined
      at errorMiddleware (app/middlewares/error.js:10:28)
      at Context.<anonymous> (test/unit/error_handler.test.js:79:26)

  3) error-handler should escape chars that broke logs regex:
     TypeError: Cannot read property 'environment' of undefined
      at errorMiddleware (app/middlewares/error.js:10:28)
      at Context.<anonymous> (test/unit/error_handler.test.js:108:26)
```
2018-12-05 16:22:48 +01:00
Daniel García Aubert
a616982ec3 Use strict mode 2018-10-24 15:42:33 +02:00
Eneko Lakasta
1bf8a06ec2 Rephrase error message 2018-06-29 13:19:32 +02:00
Eneko Lakasta
3c603d65c8 update tests messages accordingly 2018-06-27 16:27:10 +02:00
Simon Martín
1174499dcf Merge branch 'master' into pgcopy-stream 2018-06-11 14:38:52 +02:00
Eneko Lakasta
eab3d289b6 refactor authenticated to authorizationLevel 2018-06-05 13:21:56 +02:00
Simon Martín
2f2dcfd762 fix copy format case 2018-06-04 18:15:28 +02:00
Simon Martín
0bac7a484c improving query info 2018-05-22 14:16:22 +02:00
Simon Martín
f31f00dbbc fix test vars naming 2018-05-22 12:05:16 +02:00
Simon Martín
81be15fbc3 adding format to copy metrics 2018-05-21 19:13:44 +02:00
Simon Martín
5f8e1d8f53 fix validatePGEntitiesAccess access 2018-04-26 10:13:03 +02:00
Simon Martín
4f6d4322f6 forgotten 'only' 2018-04-24 15:51:40 +02:00
Simon Martín
00273bc760 unit tests 2018-04-24 15:51:12 +02:00
Simon Martín
2a729b7da8 destructuring error_handler parameters 2018-04-03 13:43:17 +02:00
Simon Martín
3ad3cb7aa9 permission denied tests 2018-03-28 14:02:10 +02:00
Simon Martín
d17975d7f5 errorHandlerFactory tests 2018-03-28 13:31:45 +02:00
Simon Martín
d727a50407 jshint 2018-03-28 12:17:42 +02:00
Simon Martín
152ef05028 removing forgotten only 2018-03-28 12:15:23 +02:00
Simon Martín
8e5ac72411 simplify error_handler tests 2018-03-28 12:10:48 +02:00
Daniel García Aubert
edd382fb8f Check user is the same user that sends the request when basic-auth is provided 2018-02-16 18:21:06 +01:00
Daniel García Aubert
ad772246d0 Get api_key from specific middleware and save it into res.locals 2018-02-15 17:23:35 +01:00
Simon Martín
47b6ae65f5 test escape chars function 2017-12-18 12:46:03 +01:00
Simon Martín
43598cafe6 test ensuring errors header 2017-11-28 17:19:48 +01:00
Daniel García Aubert
8012fe26aa Avoid scan behaviour to discover active queues of user's jobs, now keeps an index to know which queues are available 2017-03-31 14:30:33 +02:00
Raul Ochoa
aa68dff24b Use constants for tests 2016-10-12 18:44:46 +02:00
Raul Ochoa
611508c654 Hide queue seeker behind job subscriber 2016-10-11 19:01:39 +02:00
Raul Ochoa
e4b1711e8e pub/sub package 2016-10-11 18:28:46 +02:00
Raul Ochoa
461728d3e2 Remove user indexer 2016-08-30 19:08:06 +02:00
Daniel García Aubert
ccff602bbf Merge branch 'master' into fix-publisher-connection 2016-07-07 16:07:41 +02:00
Raul Ochoa
368fe2403e Allow to setup more than one domain to validate oauth against 2016-07-07 14:20:36 +02:00
Daniel García Aubert
5eaad4d5d9 Uses redis-mpool for pubsub in Batch API 2016-07-07 14:14:46 +02:00
Daniel García Aubert
74d83a457e Now batch publisher sends a ping to server before publishing and create a new connection if error.
Batch publisher and subscriber logs (if debug enabled) both outcoming and incoming messages to give more visibility.
2016-07-07 10:44:17 +02:00
Daniel García Aubert
a1f31df92e Now Batch API broadcast to other APIs everytime that re-enqueues a multiple-query job 2016-06-29 18:29:53 +02:00
Daniel García Aubert
7121b3b800 Passed test 2016-04-04 20:05:58 +02:00
Daniel García Aubert
b62edcb64f Refactored batch-api startup. Isolated code related to queue discovering, api much clear and concise. 2016-04-04 16:05:33 +02:00
dgaubert
e8a44136c5 Now Batch API looks for queues with jobs to consume at service initialization time 2016-03-31 17:37:35 +02:00
Daniel García Aubert
c540899580 Implemented unit test for user indexer in batch service 2016-01-25 10:47:21 +01:00