mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-09 23:51:20 +00:00
@@ -1,4 +1,4 @@
|
|||||||
This licence applies to the file: event.schema.json
|
This licence applies to the files: event.schema.json (and its derivatives)
|
||||||
The source of this file is: https://raw.githubusercontent.com/getsentry/sentry-data-schemas/main/LICENSE
|
The source of this file is: https://raw.githubusercontent.com/getsentry/sentry-data-schemas/main/LICENSE
|
||||||
|
|
||||||
Copyright (c) 2020 Sentry (https://sentry.io) and individual contributors.
|
Copyright (c) 2020 Sentry (https://sentry.io) and individual contributors.
|
||||||
|
|||||||
@@ -40,12 +40,3 @@ In short, the more reasons to just use the "upstream" API.
|
|||||||
|
|
||||||
Said in another way: we act more as the "relay" than as "getsentry/sentry", because we do ingest straight in the main
|
Said in another way: we act more as the "relay" than as "getsentry/sentry", because we do ingest straight in the main
|
||||||
process. So we should adhere to the relay's spec.
|
process. So we should adhere to the relay's spec.
|
||||||
|
|
||||||
### Notes on use:
|
|
||||||
|
|
||||||
Bugsink, as it stands, doesn't use event.schema.json much.
|
|
||||||
|
|
||||||
* We have `--valid-only` as a param on `send_json`, but I appear to have used that only sporadically (back in nov 2023)
|
|
||||||
* We _could_ at some point in the future [offer the option to] throw events through a validator before proceeding with
|
|
||||||
digesting. At that point we'll re-vendor event.schema.json (from the sentry-data-schemas repo)
|
|
||||||
* Reading this file is useful, but we can do that straight from the source.
|
|
||||||
|
|||||||
4372
api/event.schema.altered.json
Normal file
4372
api/event.schema.altered.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,20 @@ from django.conf import settings
|
|||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
|
|
||||||
|
def alter_schema(schema):
|
||||||
|
# alter the schema to make it fit what the actual documentation says; see issues/utils.py' get_values() for details
|
||||||
|
|
||||||
|
for key in ['exception', 'threads', 'breadcrumbs']:
|
||||||
|
# no idea why that anyOf[0] is there (since there's no anyOf[1]), but it's there.
|
||||||
|
definition = schema['anyOf'][0]['properties'][key]
|
||||||
|
schema['anyOf'][0]['properties'][key] = {
|
||||||
|
"anyOf": [
|
||||||
|
definition,
|
||||||
|
definition['properties']['values'],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = "Fetches the event schema JSON from the API and saves it to disk. Used during development."
|
help = "Fetches the event schema JSON from the API and saves it to disk. Used during development."
|
||||||
|
|
||||||
@@ -26,7 +40,7 @@ class Command(BaseCommand):
|
|||||||
license_result.raise_for_status()
|
license_result.raise_for_status()
|
||||||
|
|
||||||
with open(settings.BASE_DIR / "api/LICENSE", "w") as f:
|
with open(settings.BASE_DIR / "api/LICENSE", "w") as f:
|
||||||
f.write("""This licence applies to the file: event.schema.json
|
f.write("""This licence applies to the files: event.schema.json (and its derivatives)
|
||||||
The source of this file is: %s
|
The source of this file is: %s
|
||||||
|
|
||||||
""" % license_url)
|
""" % license_url)
|
||||||
@@ -35,13 +49,17 @@ The source of this file is: %s
|
|||||||
# Generate fastjsonschema code from the schema and save it to disk
|
# Generate fastjsonschema code from the schema and save it to disk
|
||||||
schema = json.loads(json_result.text)
|
schema = json.loads(json_result.text)
|
||||||
|
|
||||||
|
alter_schema(schema)
|
||||||
|
with open(settings.BASE_DIR / "api/event.schema.altered.json", "w") as f:
|
||||||
|
json.dump(schema, f, indent=2)
|
||||||
|
|
||||||
# use_formats=False for "uint64", see https://github.com/horejsek/python-fastjsonschema/issues/108
|
# use_formats=False for "uint64", see https://github.com/horejsek/python-fastjsonschema/issues/108
|
||||||
# use_default=False to avoid fastjsonschema adding default values to the data it validates (bwegh)
|
# use_default=False to avoid fastjsonschema adding default values to the data it validates (bwegh)
|
||||||
code = fastjsonschema.compile_to_code(schema, use_formats=False, use_default=False, detailed_exceptions=False)
|
code = fastjsonschema.compile_to_code(schema, use_formats=False, use_default=False, detailed_exceptions=False)
|
||||||
|
|
||||||
with open(settings.BASE_DIR / "bugsink/event_schema.py", "w") as f:
|
with open(settings.BASE_DIR / "bugsink/event_schema.py", "w") as f:
|
||||||
f.write("""# This file is generated by fetch_event_schema_json.py
|
f.write("""# This file is generated by fetch_event_schema_json.py
|
||||||
# it is based on api/event.schema.json
|
# it is based on api/event.schema.altered.json
|
||||||
# the following license applies:
|
# the following license applies:
|
||||||
""")
|
""")
|
||||||
f.write("\n".join("# " + line for line in license_result.text.splitlines()) + "\n\n")
|
f.write("\n".join("# " + line for line in license_result.text.splitlines()) + "\n\n")
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class Command(BaseCommand):
|
|||||||
del data["_meta"]
|
del data["_meta"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
schema_filename = settings.BASE_DIR / 'api/event.schema.json'
|
schema_filename = settings.BASE_DIR / 'api/event.schema.altered.json'
|
||||||
with open(schema_filename, 'r') as f:
|
with open(schema_filename, 'r') as f:
|
||||||
schema = json.loads(f.read())
|
schema = json.loads(f.read())
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class BaseIngestAPIView(View):
|
|||||||
# exceptions, so you'd have that cost-of-rollback anyway.
|
# exceptions, so you'd have that cost-of-rollback anyway.
|
||||||
|
|
||||||
def get_schema():
|
def get_schema():
|
||||||
schema_filename = settings.BASE_DIR / 'api/event.schema.json'
|
schema_filename = settings.BASE_DIR / 'api/event.schema.altered.json'
|
||||||
with open(schema_filename, 'r') as f:
|
with open(schema_filename, 'r') as f:
|
||||||
return json.loads(f.read())
|
return json.loads(f.read())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user