elastic / elastic/apm-server

model: create a specification for valid event docs

Open
#4,410 3 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
1.3k
Forks
543
Avg merge
1d 18h
Merged PRs (30d)
109

Description

We currently have hand-written model types, whose Transform methods are responsible for setting fields according to our schema. The schema is defined by fields.yml, and is only partially covered by ECS.

In the Kibana APM app code there are Typescript type definitions for the document `_source`: https://github.com/elastic/kibana/tree/master/x-pack/plugins/apm/typings/es_schemas/raw. In theory we could generate these from our field definitions, and with some annotations to indicate which fields are "required" (expected to always be produced by APM Server) we could avoid having `?:` on every property.

If we had a more complete model specification, we could use that to generate Typescript type definitions as well as the Go code for our own model Transform methods. Furthermore, in the future we might build on this to avoid the need for creating memory-heavy `common.MapStr` objects by generating code following an approach like described in https://github.com/elastic/apm-server/issues/3565#issuecomment-604839280. The main point being that relying on code generation makes the change easier than if we continue hand writing everything.

Finally, with a spec we could produce a more efficient codec for local event storage (i.e. for tail-based sampling): https://github.com/elastic/apm-server/issues/4120.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.