Skip to content

Commit 142a839

Browse files
Document jaeger tracing (#79)
1 parent 3230729 commit 142a839

File tree

2 files changed

+100
-3
lines changed

2 files changed

+100
-3
lines changed
68.2 KB
Loading

workflows/observability/open-telemetry.mdx

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,107 @@ Tilebox Workflows currently supports OpenTelemetry for tracing and logging, with
3434

3535
## Integrations
3636

37-
Tilebox exports telemetry data using the [OpenTelemetry Protocol](https://opentelemetry.io/docs/specs/otlp/).
37+
Tilebox exports telemetry data using the [OpenTelemetry Protocol](https://opentelemetry.io/docs/specs/otlp/). This allows you to send telemetry data to any OpenTelemetry-compatible backend, such as Axiom or Jaeger.
38+
39+
### Axiom
3840

3941
<img src="/assets/workflows/observability/tilebox-axiom.png" alt="Tilebox is pre-integrated with Axiom" />
4042

41-
Axiom, a cloud-based observability and telemetry platform, supports this protocol. Tilebox Workflows has built-in support for Axiom, and the examples and screenshots in this section come from this integration.
43+
Tilebox Workflows has built-in support for Axiom, a cloud-based observability and telemetry platform. The examples and screenshots in this section come from this integration.
44+
45+
To get started, [sign up for a free Axiom account](https://axiom.co/), create an axiom dataset for traces and logs, and generate an API key with ingest permissions for those datasets.
46+
47+
You can then configure Tilebox to export traces and logs to Axiom using [configure_otel_tracing_axiom](/workflows/observability/tracing#axiom) and [configure_otel_logging_axiom](/workflows/observability/logging#axiom).
48+
49+
### Jaeger
50+
51+
<img src="/assets/workflows/observability/tilebox-jaeger.png" alt="Tilebox works well with Jaeger" />
52+
53+
Another popular option is [Jaeger](https://jaegertracing.io/), a popular distributed tracing system. You can use the [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/) to collect telemetry data from Tilebox Workflows and export it to Jaeger.
54+
55+
An all-in-one Jaeger environment can be spun up using Docker:
56+
57+
```bash
58+
docker run --rm --name jaeger \
59+
-p 5778:5778 \
60+
-p 16686:16686 \
61+
-p 4318:4318 \
62+
jaegertracing/jaeger:2.9.0
63+
```
64+
65+
You can then configure Tilebox to export traces to Jaeger using `configure_otel_tracing`.
66+
67+
<CodeGroup>
68+
```python Python
69+
from tilebox.workflows import Client
70+
from tilebox.workflows.observability.tracing import configure_otel_tracing
71+
72+
# your own workflow:
73+
from my_workflow import MyTask
74+
75+
def main():
76+
configure_otel_tracing(
77+
# export traces to the local Jaeger instance
78+
endpoint="http://localhost:4318",
79+
)
80+
81+
# the following task runner generates traces for executed tasks and
82+
# exports trace and span data to the specified endpoint
83+
client = Client()
84+
runner = client.runner(tasks=[MyTask])
85+
runner.run_forever()
86+
87+
if __name__ == "__main__":
88+
main()
89+
```
90+
```go Go
91+
package main
92+
93+
import (
94+
"context"
95+
"log/slog"
96+
97+
"github.com/tilebox/tilebox-go/examples/workflows/opentelemetry"
98+
"github.com/tilebox/tilebox-go/observability"
99+
"github.com/tilebox/tilebox-go/observability/tracer"
100+
"github.com/tilebox/tilebox-go/workflows/v1"
101+
"go.opentelemetry.io/otel"
102+
)
103+
104+
// specify a service name and version to identify the instrumenting application in traces and logs
105+
var service = &observability.Service{Name: "task-runner", Version: "dev"}
106+
107+
func main() {
108+
ctx := context.Background()
109+
110+
endpoint := "http://localhost:4318"
111+
112+
// Setup an OpenTelemetry trace span processor, exporting traces and spans to an OTEL compatible trace endpoint
113+
tileboxTracerProvider, shutdown, err := tracer.NewOtelProvider(ctx, service, tracer.WithEndpointURL(endpoint))
114+
defer shutdown(ctx)
115+
if err != nil {
116+
slog.Error("failed to set up otel span processor", slog.Any("error", err))
117+
return
118+
}
119+
otel.SetTracerProvider(tileboxTracerProvider) // set the tilebox tracer provider as the global OTEL tracer provider
120+
121+
client := workflows.NewClient()
122+
123+
taskRunner, err := client.NewTaskRunner(ctx)
124+
if err != nil {
125+
slog.Error("failed to create task runner", slog.Any("error", err))
126+
return
127+
}
128+
129+
err = taskRunner.RegisterTasks(&MyTask{})
130+
if err != nil {
131+
slog.Error("failed to register tasks", slog.Any("error", err))
132+
return
133+
}
134+
135+
taskRunner.RunForever(ctx)
136+
}
137+
```
138+
</CodeGroup>
42139

43-
Additionally, any other OpenTelemetry-compatible backend, such as OpenTelemetry Collector or Jaeger, can be used to collect telemetry data generated by Tilebox Workflows.
140+
The generated workflow traces can then be viewed in the Jaeger UI at [http://localhost:16686](http://localhost:16686).

0 commit comments

Comments
 (0)