@@ -44,36 +44,41 @@ Users of a tap can configure the SDK logging by setting the `SINGER_SDK_LOG_CONF
44
44
environment variable. The value of this variable should be a path to a YAML file in the
45
45
[ Python logging dict format] ( https://docs.python.org/3/library/logging.config.html#dictionary-schema-details ) .
46
46
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:
48
52
49
53
``` yaml
50
54
version : 1
51
55
disable_existing_loggers : false
52
56
formatters :
53
57
metrics :
54
- format : " {asctime} {levelname} {message}"
58
+ () : pythonjsonlogger.jsonlogger.JsonFormatter
59
+ format : " {created} {message} {point}"
55
60
style : " {"
56
61
handlers :
57
62
metrics :
58
63
class : logging.FileHandler
59
64
formatter : metrics
60
- filename : metrics.log
65
+ filename : metrics.jsonl
61
66
loggers :
62
67
singer_sdk.metrics :
63
68
level : INFO
64
69
handlers : [ metrics ]
65
- propagate : yes
70
+ propagate : no
66
71
` ` `
67
72
68
- This will send metrics to a ` metrics.log `:
73
+ This will send metrics to a ` metrics.jsonl `:
69
74
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": {}}}
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": {} }}}
79
84
` ` `
0 commit comments