Mforns has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/404303 )
Change subject: [WIP] Move EventCapsule into codebase ...................................................................... [WIP] Move EventCapsule into codebase Bug: T179836 Change-Id: I8a932e7f5fa7a511778112e3d9fc1fd75b027811 --- A config/implicit_schemas/EventCapsule/1 M eventlogging/schema.py 2 files changed, 73 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/eventlogging refs/changes/03/404303/1 diff --git a/config/implicit_schemas/EventCapsule/1 b/config/implicit_schemas/EventCapsule/1 new file mode 100644 index 0000000..e39e2c0 --- /dev/null +++ b/config/implicit_schemas/EventCapsule/1 @@ -0,0 +1,48 @@ +description: A wrapper around event objects that encodes generic metadata +properties: + event: + type: object + description: The encapsulated event object + required: true + wiki: + type: string + description: "$wgDBName (for example: 'enwiki')" + required: true + webHost: + type: string + description: "Request host. 'window.location.hostname' on client-side events; $_SERVER['HTTP_HOST'] on server." + schema: + type: string + description: Title of event schema + required: true + revision: + type: integer + description: Revision ID of event schema + required: true + topic: + type: string + description: The queue topic name this event belongs in + recvFrom: + type: string + description: Hostname of server emitting the log line + required: true + timestamp: + type: number + description: 'UTC unix epoch timestamp of event. Optional. Should be the same as dt. Exists for backwards compatibility. See: https://phabricator.wikimedia.org/T179625)' + dt: + type: string + description: 'UTC ISO-8601 timestamp of event' + format: 'date-time' + seqId: + type: integer + description: Udp2log sequence ID + uuid: + type: string + description: Unique event identifier + format: 'uuid5-hex' + required: true + userAgent: + type: any + description: 'User Agent from HTTP request. Either a parsed object, parsed JSON string, or original User-Agent string.' + required: false +additionalProperties: false diff --git a/eventlogging/schema.py b/eventlogging/schema.py index 06716a0..bd43a2c 100644 --- a/eventlogging/schema.py +++ b/eventlogging/schema.py @@ -64,7 +64,20 @@ SCHEMA_URI_FORMAT = '%s/%s' # SCID of the metadata object which wraps each capsule-style event. -CAPSULE_SCID = ('EventCapsule', 17418976) +# Since January 2018 this is hardcoded as an implicit schema as opposed +# to be stored in https://meta.wikimedia.org/wiki/Schema:EventCapsule. +# See: https://phabricator.wikimedia.org/T179836 +CAPSULE_SCID = ('EventCapsule', 1) + +# Directory where EventLogging implicit schemas are stored. +# Implicit schemas are hardcoded into EventLogging's codebase, +# because they are highly coupled with how the codebase works, +# and it doesn't make sense to have them in meta.wikimedia.org. +# See: https://phabricator.wikimedia.org/T179836 +IMPLICIT_SCHEMAS_PATH = os.path.join( + os.path.dirname(__file__), + '../config/implicit_schemas' +) # TODO: Make new meta style EventError on meta. ERROR_SCID = ('EventError', 14035058) @@ -85,6 +98,7 @@ """ schema_cache.clear() schema_validator_cache.clear() + load_implicit_schemas() if schemas_path: load_local_schemas(schemas_path=schemas_path) @@ -240,6 +254,16 @@ return schema +def load_implicit_schemas(): + """Load implicit schemas (like EventCapsule).""" + capsule_uri = 'file://' + os.path.join( + IMPLICIT_SCHEMAS_PATH, + schema_uri_from_scid(CAPSULE_SCID) + ) + capsule_schema = url_get_schema(capsule_uri) + cache_schema(CAPSULE_SCID, capsule_schema) + + def load_local_schemas(schemas_path): """ Walks schemas_path looking for files that mach -- To view, visit https://gerrit.wikimedia.org/r/404303 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8a932e7f5fa7a511778112e3d9fc1fd75b027811 Gerrit-PatchSet: 1 Gerrit-Project: eventlogging Gerrit-Branch: master Gerrit-Owner: Mforns <mfo...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits