Skip to content

Commit

Permalink
first cut
Browse files Browse the repository at this point in the history
  • Loading branch information
rhildred committed Oct 2, 2024
1 parent 4afdb65 commit e914208
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 1 deletion.
Binary file added monolith_instrumenting/images/logger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added monolith_instrumenting/images/metric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added monolith_instrumenting/images/tracer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 100 additions & 1 deletion monolith_instrumenting/slides.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,36 @@ Chapter 3 and 5 in the book

## Pipeline Semantics

- signals are logs, traces and metrics
- add new signals like sessions in the Future
- signals have attributes

## Attributes (from the sqlquery)

```yaml
- sql: "SELECT sum(xact_rollback) as count_test FROM pg_stat_database; "
metrics:
- metric_name: query_errors # E from REDS
value_column: count_test
```

- the value_column is count_test but other columns will be stored as attributes

## Attributes (from today's lab)

```python
# Now create a counter instrument to make measurements with
roll_counter = meter.create_counter(
"dice.rolls",
description="The number of rolls by roll value",
)
roll_counter.add(1, {"roll.value": result})
```

- roll.value is an attribute

## Future of Open Telemetry

![OpenTelemetry’s long-term support guarantees](images/otelSupport.png)

## Foundation of OpenTelemetry is built on two points:
Expand All @@ -67,4 +97,73 @@ Chapter 3 and 5 in the book

- can provide schema transformations
- support changes in semantic conventions (and their associated support in analysis tools)
- without having to reinstrument or redefine output from existing services
- without having to reinstrument or redefine output from existing services

## setting up OpenTelemetry is twofold

- installing the software development kit (SDK)
- for python we do this with pip packages
- installing instrumentation
- some instrumentation is automatic with the SDK, some is custom

## requirements.txt

```txt
opentelemetry-distro
opentelemetry-exporter-otlp
```

- then run `opentelemetry-bootstrap -a install`

## logs

```python
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger.warn("{} is rolling the dice: {}", "Rich", "6")
```

- built in to python

## Logger Provider

![The LoggerProvider framework](images/logger.png)

## custom traces

```python
from opentelemetry import trace
# Acquire a tracer
tracer = trace.get_tracer("diceroller.tracer")
with tracer.start_as_current_span("roll") as rollspan:
rollspan.set_attribute("roll.value", 6)
```

## Tracer Provider

![The TracerProvider framework](images/tracer.png)

## custom metrics

```python
from opentelemetry import metrics
meter = metrics.get_meter("diceroller.meter")
# Now create a counter instrument to make measurements with
roll_counter = meter.create_counter(
"dice.rolls",
description="The number of rolls by roll value",
)
roll_counter.add(1, {"roll.value": "6"})
```

## Meter Provider

![The MeterProvider framework](images/metric.png)

## Conclusion

- work required to reinstrument a large system a form of vendor lock-in
- advantage of OpenTelemetry is that once it’s done
- OpenTelemetry is a standard that works with every observability system.

0 comments on commit e914208

Please sign in to comment.