core-telemetry-0.2.7.3: Advanced telemetry
Safe HaskellSafe-Inferred
LanguageHaskell2010

Core.Telemetry.Structured

Description

An exporter backend that outputs "structured" logs to your terminal as they are submitted.

Most traditional programs' logs were textual, single lines, sometimes with a reasonably well-known internal layout, but regardless very difficult to actually perform analysis on. Engineers attempting to diagnose problems are largely limited to doing text searches across masses of logs. It's hard to correlate between diffent subsystems let alone perform any sort of statistical analysis.

Other systems in the past gathered copious amounts of metrics but having done so, left us with the hard problem of actually doing anything useful with them other than providing fodder for pretty graphs.

Structured logging was a significant step forward for large-scale systems administration; by combining metrics together with context in the form of key/value pairs it allows us to perform more detailed investigation and analysis that this was largely done by emitting copious amounts of enormously wasteful JSON is astonishing and goes some way to explain why structured logging took so long to catch on).

Taking the example from telemetry, the output would be:

$ burgerservice --telemetry=structured
{"calories":667.0,"flavour":true,"meal_name":"hamburger","precise":45.0,"timestamp":"2021-10-22T11:12:53.674399531Z"}
...

which if pretty printed would have been more recognizable as

{
    "calories": 667.0,
    "flavour": true,
    "meal_name": "hamburger",
    "precise": 45.0,
    "timestamp": "2021-10-22T11:12:53.674399531Z",
}

but all that whitespace would be wasteful, right?

While more advanced observability systems will directly ingest this data and assemble it into traces of nested spans, in other situations having straight-forward metrics output as JSON may be sufficient for your needs. If you do use this exporter in a program embellished with traces and spans, the relevant contextual information will be added to the output:

{
    "calories": 667.0,
    "flavour": true,
    "meal_name": "hamburger",
    "precise": 45.0,
    "timestamp": "2021-10-22T11:12:53.674399531Z",
    "duration": 3.756717001,
    "span_id": "o7ucNqCeSJBzeviL",
    "span_name": "Process order",
    "trace_id": "order-11430185",
    "service_name": "burger-service"
}
Synopsis

Documentation

structuredExporter :: Exporter Source #

Output metrics to stdout in the form of a raw JSON object.