# OpenTelemetry ## Vocabulary **OpenTelemetry** ("OTel") is a specification for how telemetry data is to be generated, collected, managed, and exported. The tasks of storage and visualization of this data are intentionally left to other tools. **OTLP** stands for OpenTelemetry Protocol. **Telemetry** data comprises Metrics, Logs, Traces, and Events. These are also sometimes called "signals". **Events** are recorded in OTLP as a structured log, so those terms are often used synonymously. This probably means that when an "event" happens, it only becomes an "Event" when it is written-about or "logged". Context matters. Events have multiple contexts. Think of them like perspectives. The **Trace** of an Event is information about the other Events happening around it. But to get there we have to start with the Operation: An **Operation** is a sequence of Events all related to the same task. OTel represents Operations as "**Spans**". A **Span** is a set of Events and/or Spans that describe a single Operation. Spans calling each other create a graph of the entire Transaction. This graph is called the **Trace**. A **Trace** describes the flow of execution through a large distributed system. The "application context" or **Resource Scope** of an Event is information about how and where the application is running. Attributes can include the service name, service version, device type, operating system, language runtime, container, region, network... Within the application is a set of libraries, packages, dependencies, and code. The "library context" or **Instrumentation Scope** of an Event is information about the specific code that generated the structured log. Attributes can include the library name, version, configuration, and source repository link. Resource and Instrumentation Scopes are examples of **static context**, and Traces are **dynamic context**. Put another way, the OTLP data model is as follows: ```plain Resource( Attributes( Service Name Service Version etc ) Scopes() ) Scope( Attributes( Library Name Library Version etc ) Spans() Metrics() Logs() ) Span( Attributes( Span Name Span ID Parent Span ID etc ) SpanEvents() ) SpanEvent( Attributes( Event Name Log Message etc ) ) Metric( Attributes( Metric Name Description etc ) DataPoints() Exemplars() ) DataPoint( ? ) Exemplars( ? ) Log( Attributes( Event Name Log Message etc ) ) ``` **Instrumentation** is the process of adding software to your systems to generate telemetry data. A **Collector** is a piece of software that handles receiving, processing, and exporting telemetry data. It comprises Receivers, Processors, Exporters, Connectors, and Extensions. **Receivers** are in charge of data ingest. They can either listen for applications to push data to them, or they can pull (or "scrape") data from applications. The **OTLP Receiver** is a push-type receiver. The **filelog Receiver** is a pull-type receiver. **Processors** take data from receivers and do something with it. Maybe you want to batch many logs together before exporting to a database. Maybe you want to scrub out PII, or add attributes to the signals. **Exporters** send the processed data somewhere else (for storage and visualization). The most common one is the **OTLP Exporter**. The **debug Exporter** sends the data to the console (stdout?). **Pipelines** combine any of the above into modular pieces. A pipeline can only handle a single type of data (logs, metrics, traces). **Connectors** can translate pipelines between data types. The **count connector** will count how many log lines are coming from a pipeline, and output that number as metric data. **Extensions** expand the capabilities of the Collector. For example, if your collector needs to auth to another service, you can do that with an extension. A Collector can observe itself. Using the `service.telemetry` config object, you can instrument the collector. One of the ways Ops teams use OTel is to build pipelines and connectors in a Collector to turn Events (structured log data) into Metrics (quantifiable, aggregatable, graphable). They can also turn Metrics data back into Events. Consider an "errors over time" metric, that alarms at a certain threshold and wakes you up. You need to figure out what the heck is going on with all these errors, so you might look at the Logs during this window. Maybe a lot of the logs say "error from node 6". If your "errors over time" graph is filterable by which node ID the errors are coming from, you can tell which node is having problems. A **Trace Examplar** is a metrics feature that contains a sampling of trace IDs associated with a particular metric's value. It lets you answer the question "which trace(s) generated this value?". More importantly, it also lets a _computer_ answer that question, leading to things like scaling, garbage-collection, and high-availability.