##// END OF EJS Templates
metrics: allow indexing items with dates in past if permanent storage is enabled
ergo -
Show More
@@ -492,11 +492,24 b' class GeneralMetricSchema(colander.MappingSchema):'
492 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 503 class GeneralMetricsListSchema(colander.SequenceSchema):
496 504 metric = GeneralMetricSchema()
497 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 513 class MetricsListSchema(colander.SequenceSchema):
501 514 """
502 515 Validates list of metrics objects ie:
@@ -42,7 +42,9 b' from appenlight.lib.request import JSONException'
42 42 from appenlight.validators import (LogListSchema,
43 43 MetricsListSchema,
44 44 GeneralMetricsListSchema,
45 GeneralMetricsPermanentListSchema,
45 46 GeneralMetricSchema,
47 GeneralMetricPermanentSchema,
46 48 LogListPermanentSchema,
47 49 ReportListSchema_0_5,
48 50 LogSchema,
@@ -235,10 +237,19 b' def general_metrics_create(request):'
235 237 payload = request.unsafe_json_body
236 238 sequence_accepted = request.matched_route.name == 'api_general_metrics'
237 239 if sequence_accepted:
238 schema = GeneralMetricsListSchema().bind(
239 utcnow=datetime.datetime.utcnow())
240 if application.allow_permanent_storage:
241 schema = GeneralMetricsPermanentListSchema().bind(
242 utcnow=datetime.datetime.utcnow())
243 else:
244 schema = GeneralMetricsListSchema().bind(
245 utcnow=datetime.datetime.utcnow())
240 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 254 deserialized_metrics = schema.deserialize(payload)
244 255 if sequence_accepted is False:
General Comments 0
You need to be logged in to leave comments. Login now