@@ -44,38 +44,43 @@ Users of a tap can configure the SDK logging by setting the `SINGER_SDK_LOG_CONF
4444environment variable. The value of this variable should be a path to a YAML file in the
4545[ Python logging dict format] ( https://docs.python.org/3/library/logging.config.html#dictionary-schema-details ) .
4646
47- For example, to send [ metrics] ( ./metrics.md ) (with logger name ` singer_sdk.metrics ` ) to a file, you could use the following config:
47+ ### Metrics logging
48+
49+ The Singer SDK provides a logger named ` singer_sdk.metrics ` for logging [ Singer metrics] ( ./metrics.md ) . Metric log records contain an extra field ` point ` which is a dictionary containing the metric data. The ` point ` field is formatted as JSON by default.
50+
51+ To send metrics to a file in JSON format, you could use the following config:
4852
4953``` yaml
5054version : 1
5155disable_existing_loggers : false
5256formatters :
5357 metrics :
54- format : " {asctime} {levelname} {message}"
58+ () : pythonjsonlogger.jsonlogger.JsonFormatter
59+ format : " {created} {message} {point}"
5560 style : " {"
5661handlers :
5762 metrics :
5863 class : logging.FileHandler
5964 formatter : metrics
60- filename : metrics.log
65+ filename : metrics.jsonl
6166loggers :
6267 singer_sdk.metrics :
6368 level : INFO
6469 handlers : [ metrics ]
65- propagate : yes
70+ propagate : no
6671` ` `
6772
68- This will send metrics to a ` metrics.log `:
69-
70- ```
71- 2022-09-29 00:48:52,746 INFO METRIC: {"metric_type ": "timer", "metric": "http_request_duration", "value": 0.501743, "tags": {"stream": "continents", "endpoint": "", "http_status_code": 200, "status": "succeeded"}}
72- 2022-09-29 00:48:52,775 INFO METRIC: {"metric_type ": "counter", "metric": "http_request_count", "value": 1, "tags": {"stream": "continents", "endpoint": ""}}
73- 2022-09-29 00:48:52,776 INFO METRIC: {"metric_type ": "timer", "metric": "sync_duration", "value": 0.7397160530090332, "tags": {"stream": "continents", "context": {}, "status": "succeeded"}}
74- 2022-09-29 00:48:52,776 INFO METRIC: {"metric_type ": "counter", "metric": "record_count", "value": 7, "tags": {"stream": "continents", "context": {}}}
75- 2022-09-29 00:48:53,225 INFO METRIC: {"metric_type ": "timer", "metric": "http_request_duration", "value": 0.392148, "tags": {"stream": "countries", "endpoint": "", "http_status_code": 200, "status": "succeeded"}}
76- 2022-09-29 00:48:53,302 INFO METRIC: {"metric_type ": "counter", "metric": "http_request_count", "value": 1, "tags": {"stream": "countries", "endpoint": ""}}
77- 2022-09-29 00:48:53,302 INFO METRIC: {"metric_type ": "timer", "metric": "sync_duration", "value": 0.5258760452270508, "tags": {"stream": "countries", "context": {}, "status": "succeeded"}}
78- 2022-09-29 00:48:53,303 INFO METRIC: {"metric_type ": "counter", "metric": "record_count", "value": 250, "tags": {"stream": "countries", "context": {}}}
73+ This will send metrics to a ` metrics.jsonl `:
74+
75+ ` ` ` json
76+ {"created": 1705709074.883021, "message": " METRIC", "point" : {"type ": "timer", "metric": "http_request_duration", "value": 0.501743, "tags": {"stream": "continents", "endpoint": "", "http_status_code": 200, "status": "succeeded"} }}
77+ {"created": 1705709074.897184, "message": " METRIC", "point" : {"type ": "counter", "metric": "http_request_count", "value": 1, "tags": {"stream": "continents", "endpoint": ""} }}
78+ {"created": 1705709074.897256, "message": " METRIC", "point" : {"type ": "timer", "metric": "sync_duration", "value": 0.7397160530090332, "tags": {"stream": "continents", "context": {}, "status": "succeeded"} }}
79+ {"created": 1705709074.897292, "message": " METRIC", "point" : {"type ": "counter", "metric": "record_count", "value": 7, "tags": {"stream": "continents", "context": {} }}}
80+ {"created": 1705709075.397254, "message": " METRIC", "point" : {"type ": "timer", "metric": "http_request_duration", "value": 0.392148, "tags": {"stream": "countries", "endpoint": "", "http_status_code": 200, "status": "succeeded"} }}
81+ {"created": 1705709075.421888, "message": " METRIC", "point" : {"type ": "counter", "metric": "http_request_count", "value": 1, "tags": {"stream": "countries", "endpoint": ""} }}
82+ {"created": 1705709075.422001, "message": " METRIC", "point" : {"type ": "timer", "metric": "sync_duration", "value": 0.5258760452270508, "tags": {"stream": "countries", "context": {}, "status": "succeeded"} }}
83+ {"created": 1705709075.422047, "message": " METRIC", "point" : {"type ": "counter", "metric": "record_count", "value": 250, "tags": {"stream": "countries", "context": {} }}}
7984` ` `
8085
8186# # For package developers
0 commit comments