Show More
@@ -492,11 +492,24 b' class GeneralMetricSchema(colander.MappingSchema):' | |||||
492 | tags = TagSchemaList(missing=colander.required) |
|
492 | tags = TagSchemaList(missing=colander.required) | |
493 |
|
493 | |||
494 |
|
494 | |||
|
495 | class GeneralMetricPermanentSchema(GeneralMetricSchema): | |||
|
496 | """ | |||
|
497 | Validates universal metric schema | |||
|
498 | ||||
|
499 | """ | |||
|
500 | timestamp = colander.SchemaNode(NonTZDate(), missing=deferred_utcnow) | |||
|
501 | ||||
|
502 | ||||
495 | class GeneralMetricsListSchema(colander.SequenceSchema): |
|
503 | class GeneralMetricsListSchema(colander.SequenceSchema): | |
496 | metric = GeneralMetricSchema() |
|
504 | metric = GeneralMetricSchema() | |
497 | validator = colander.Length(1) |
|
505 | validator = colander.Length(1) | |
498 |
|
506 | |||
499 |
|
507 | |||
|
508 | class GeneralMetricsPermanentListSchema(colander.SequenceSchema): | |||
|
509 | metric = GeneralMetricPermanentSchema() | |||
|
510 | validator = colander.Length(1) | |||
|
511 | ||||
|
512 | ||||
500 | class MetricsListSchema(colander.SequenceSchema): |
|
513 | class MetricsListSchema(colander.SequenceSchema): | |
501 | """ |
|
514 | """ | |
502 | Validates list of metrics objects ie: |
|
515 | Validates list of metrics objects ie: |
@@ -42,7 +42,9 b' from appenlight.lib.request import JSONException' | |||||
42 | from appenlight.validators import (LogListSchema, |
|
42 | from appenlight.validators import (LogListSchema, | |
43 | MetricsListSchema, |
|
43 | MetricsListSchema, | |
44 | GeneralMetricsListSchema, |
|
44 | GeneralMetricsListSchema, | |
|
45 | GeneralMetricsPermanentListSchema, | |||
45 | GeneralMetricSchema, |
|
46 | GeneralMetricSchema, | |
|
47 | GeneralMetricPermanentSchema, | |||
46 | LogListPermanentSchema, |
|
48 | LogListPermanentSchema, | |
47 | ReportListSchema_0_5, |
|
49 | ReportListSchema_0_5, | |
48 | LogSchema, |
|
50 | LogSchema, | |
@@ -235,10 +237,19 b' def general_metrics_create(request):' | |||||
235 | payload = request.unsafe_json_body |
|
237 | payload = request.unsafe_json_body | |
236 | sequence_accepted = request.matched_route.name == 'api_general_metrics' |
|
238 | sequence_accepted = request.matched_route.name == 'api_general_metrics' | |
237 | if sequence_accepted: |
|
239 | if sequence_accepted: | |
238 | schema = GeneralMetricsListSchema().bind( |
|
240 | if application.allow_permanent_storage: | |
239 | utcnow=datetime.datetime.utcnow()) |
|
241 | schema = GeneralMetricsPermanentListSchema().bind( | |
|
242 | utcnow=datetime.datetime.utcnow()) | |||
|
243 | else: | |||
|
244 | schema = GeneralMetricsListSchema().bind( | |||
|
245 | utcnow=datetime.datetime.utcnow()) | |||
240 | else: |
|
246 | else: | |
241 | schema = GeneralMetricSchema().bind(utcnow=datetime.datetime.utcnow()) |
|
247 | if application.allow_permanent_storage: | |
|
248 | schema = GeneralMetricPermanentSchema().bind( | |||
|
249 | utcnow=datetime.datetime.utcnow()) | |||
|
250 | else: | |||
|
251 | schema = GeneralMetricSchema().bind( | |||
|
252 | utcnow=datetime.datetime.utcnow()) | |||
242 |
|
253 | |||
243 | deserialized_metrics = schema.deserialize(payload) |
|
254 | deserialized_metrics = schema.deserialize(payload) | |
244 | if sequence_accepted is False: |
|
255 | if sequence_accepted is False: |
General Comments 0
You need to be logged in to leave comments.
Login now