Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
howardyoo authored Aug 26, 2024
1 parent 7d72aeb commit 3cc166b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ You may need to restart Airflow in order for this to take action, but a great wa

### Using Otel hook inside the DAG file

#### Traces

You can use `span` decorator to indicate that a particular function would be emitting its span when running.

```python
Expand Down Expand Up @@ -93,6 +95,8 @@ from airflow_provider_opentelemetry.hooks.otel import OtelHook
)
```

#### Logs

You can also submit your very own log message which then can automatically converted and linked to OTEL log record within the span context.

```python
Expand All @@ -114,3 +118,25 @@ You can also submit your very own log message which then can automatically conve
python_callable=setup
)
```

#### Metrics

You can use otel hook to increment counter of certain actions
```python
otel_hook.incr('my.counter')
...
otel_hook.decr('my.counter')
```

You can use otel hook to set value of a gauge type metric
```python
otel_hook.gauge('my.gauge', 12345)
```

You can use timing to record delta time
```python
last_finish_time = timezone.utcnow()
last_duration = last_finish_time - processor.start_time
file_name = 'myfile.txt'
otel_hook.timing("my.last_duration", last_duration, tags={"file_name": file_name})
```

0 comments on commit 3cc166b

Please sign in to comment.