Files
Olares/docs/developer/develop/mw-view-otel-data.md
Meow33 839133fc27 docs: add middleware data access and integration guides (#2444)
* docs: add guides to view middleware data

* docs: add guide for grafana

* docs: add guide for otel and integration guides for other middleware

* docs: add guide for elasticsearch

* docs: update based on suggestions

* Update zh.ts

* docs: update content

* docs: resolve conflict
2026-02-05 23:34:59 +08:00

189 lines
6.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
outline: [2, 3]
description: Learn how to enable OpenTelemetry auto-instrumentation in an Olares cluster and view trace data in Jaeger.
---
# View OpenTelemetry data
This guide walks you through enabling OpenTelemetry auto-instrumentation for services running in an Olares cluster and viewing trace data in Jaeger.
## Prerequisites
- Your target service runs as a Kubernetes workload (Deployment, StatefulSet, or DaemonSet).
- You have access to run `kubectl` against the Olares cluster.
- You can generate some traffic to the target service. Trace data is generated only when traffic exists.
## Install Jaeger
Jaeger is used to visualize trace data. Install Jaeger from Market.
1. Open Market from Launchpad and search for "Jaeger".
2. Click **Get**, then **Install**, and wait for the installation to complete.
## Apply tracing configuration
Prepare the tracing backend configuration before enabling auto-instrumentation.
1. Click [`otc.yaml`](https://cdn.olares.com/common/otc.yaml) to download the configuration file.
2. Upload the file to your Olares host.
3. In the directory containing the file, apply it:
```bash
kubectl apply -f otc.yaml
```
## Configure service access
To enable OpenTelemetry auto-instrumentation, add specific **annotations** to the **Pod template** of your workload.
Auto-instrumentation is triggered entirely by annotations. No code changes are required.
:::info Rules for service access configuration
- Add annotations under `.spec.template.metadata.annotations` (Pod template, not top-level metadata).
- Pods will be recreated (rollout) for injection to take effect.
:::
:::tip Saving changes
After you finish editing with `kubectl edit`, save and exit the editor. Kubernetes will roll out updated Pods automatically in most cases.
:::
### BFL service (StatefulSet)
1. Edit the StatefulSet:
```bash
kubectl edit sts -n user-space-<olaresid> bfl
```
2. Under `.spec.template.metadata.annotations`, add:
```yaml
spec:
template:
metadata:
labels:
tier: bfl
# Locate here and add annotations
annotations:
instrumentation.opentelemetry.io/inject-go: "olares-instrumentation"
instrumentation.opentelemetry.io/go-container-names: "api"
instrumentation.opentelemetry.io/otel-go-auto-target-exe: "/bfl-api"
instrumentation.opentelemetry.io/inject-nginx: "olares-instrumentation"
instrumentation.opentelemetry.io/inject-nginx-container-names: "ingress"
```
### ChartRepo (Deployment)
1. Edit the Deployment:
```bash
kubectl edit deploy -n os-framework chartrepo-deployment
```
2. Under `.spec.template.metadata.annotations`, add:
```yaml
spec:
template:
metadata:
labels:
app: chartrepo
io.bytetrade.app: "true"
# Locate here and add annotations
annotations:
instrumentation.opentelemetry.io/inject-go: "olares-instrumentation"
instrumentation.opentelemetry.io/go-container-names: "chartrepo"
instrumentation.opentelemetry.io/otel-go-auto-target-exe: "/root/app"
```
### Olares app (Deployment)
1. Edit the Deployment:
```bash
kubectl edit deploy -n user-space-<olaresid> olares-app-deployment
```
2. Under `.spec.template.metadata.annotations`, add:
```yaml
spec:
template:
metadata:
labels:
app: olares-app
io.bytetrade.app: "true"
# Locate here and add annotations
annotations:
instrumentation.opentelemetry.io/inject-nodejs: "olares-instrumentation"
instrumentation.opentelemetry.io/nodejs-container-names: "user-service"
instrumentation.opentelemetry.io/inject-nginx: "olares-instrumentation"
instrumentation.opentelemetry.io/inject-nginx-container-names: "olares-app"
```
### Files (DaemonSet)
1. Edit the DaemonSet:
```bash
kubectl edit ds -n os-framework files
```
2. Under `.spec.template.metadata.annotations`, add:
```yaml
spec:
template:
metadata:
labels:
app: files
# Locate here and add annotations
annotations:
instrumentation.opentelemetry.io/inject-nginx: "olares-instrumentation"
instrumentation.opentelemetry.io/inject-nginx-container-names: "nginx"
instrumentation.opentelemetry.io/inject-go: "olares-instrumentation"
instrumentation.opentelemetry.io/go-container-names: "gateway,files,uploader"
instrumentation.opentelemetry.io/otel-go-auto-target-exe: "/filebrowser"
```
### Market (Deployment)
1. Edit the Deployment:
```bash
kubectl edit deploy -n os-framework market-deployment
```
2. Under `.spec.template.metadata.annotations`, add:
```yaml
spec:
template:
metadata:
labels:
app: appstore
io.bytetrade.app: "true"
# Locate here and add annotations
annotations:
instrumentation.opentelemetry.io/inject-go: "olares-instrumentation"
instrumentation.opentelemetry.io/go-container-names: "appstore-backend"
instrumentation.opentelemetry.io/otel-go-auto-target-exe: "/opt/app/market"
```
### System server (Deployment)
1. Edit the Deployment:
```bash
kubectl edit deploy -n user-system-<olaresid> system-server
```
2. Under `.spec.template.metadata.annotations`, add:
```yaml
spec:
template:
metadata:
labels:
app: systemserver
# Locate here and add annotations
annotations:
instrumentation.opentelemetry.io/go-container-names: "system-server"
instrumentation.opentelemetry.io/inject-go: "olares-instrumentation:"
instrumentation.opentelemetry.io/otel-go-auto-target-exe: "/system-server"
```
## View traces in Jaeger
:::info Traces may appear with a delay
After rollout, traces may take 15 minutes to appear. Make sure the service receives traffic.
:::
Generate traffic to the service.
1. Open Jaeger from Launchpad.
2. Select the service name from the **Service** dropdown.
3. Click **Find Traces** to view trace data.
![View traces](/images/developer/develop/middleware/mw-jaeger.png#bordered)