Skip to content

Commit ebe6ad8

Browse files
committed
Adding OpenChoreo trace module for Moesif
Signed-off-by: ruks <rukshan@wso2.com>
1 parent bd7385c commit ebe6ad8

7 files changed

Lines changed: 331 additions & 0 deletions

File tree

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Observability Tracing Module for Moesif
2+
3+
This module collects traces using [OpenTelemetry Collector](https://opentelemetry.io) and exports them to [Moesif](https://www.moesif.com).
4+
5+
## Prerequisites
6+
7+
- [OpenChoreo](https://github.com/openchoreo/openchoreo) must be installed with the **observability plane** enabled for this module to work.
8+
- A Moesif account and a **Collector Application ID** for each environment from [Moesif](https://www.moesif.com/).
9+
10+
## Installation
11+
12+
### Create a Kubernetes Secret
13+
14+
Create a Kubernetes secret containing your Moesif Collector Application IDs, with one key per environment.
15+
16+
> **Note:**
17+
> - Use the environment name as the key (e.g., `development`, `production`).
18+
> - For environment names that contain hyphens (e.g., `my-env`), replace hyphens with underscores in the secret key (e.g., `my_env`).
19+
20+
```bash
21+
kubectl create secret generic moesif-tracing-secret \
22+
--from-literal=development="YOUR_DEV_COLLECTOR_APP_ID" \
23+
--from-literal=production="YOUR_PROD_COLLECTOR_APP_ID" \
24+
--namespace openchoreo-observability-plane
25+
```
26+
27+
### Configuration Options
28+
29+
For easier configuration management, create a `moesif-tracing-values.yaml` file:
30+
31+
```yaml
32+
# moesif-tracing-values.yaml
33+
34+
moesif:
35+
# List of environment names to collect traces from.
36+
# These must match the openchoreo.dev/environment label on your resources.
37+
environments:
38+
- development
39+
- production
40+
41+
# (Optional) Moesif API endpoint. Defaults to https://api.moesif.net
42+
# endpoint: "https://api.moesif.net"
43+
44+
opentelemetryCollectorCustomizations:
45+
tailSampling:
46+
enabled: false # Enable tail-based sampling if needed
47+
```
48+
49+
Then install with:
50+
51+
```bash
52+
helm upgrade --install observability-tracing-moesif \
53+
oci://ghcr.io/openchoreo/helm-charts/observability-tracing-moesif \
54+
--create-namespace \
55+
--namespace openchoreo-observability-plane \
56+
--version 0.1.0 \
57+
-f moesif-tracing-values.yaml
58+
```
59+
60+
#### Configuration Parameters
61+
62+
| Parameter | Description | Default |
63+
|-----------|-------------|---------|
64+
| `moesif.environments` | List of environment names to collect traces from | `[development, production]` |
65+
| `moesif.endpoint` | (Optional) Moesif API endpoint URL | `https://api.moesif.net` |
66+
| `opentelemetryCollectorCustomizations.tailSampling.enabled` | Enable tail-based sampling | `false` |
67+
68+
## How It Works
69+
70+
This module deploys an **OpenTelemetry Collector** that:
71+
72+
1. Receives OTLP traces (gRPC on port `4317`, HTTP on port `4318`) from instrumented workloads.
73+
2. Enriches spans with Kubernetes metadata (pod name, deployment, namespace, etc.) using the `k8sattributes` processor.
74+
3. Routes traces to the correct Moesif application based on the `openchoreo.dev/environment` resource attribute.
75+
4. Exports traces to Moesif using the Moesif Collector Application ID stored in the `moesif-tracing-secret` Kubernetes secret.
76+
77+
## Troubleshooting
78+
79+
### Check OpenTelemetry Collector logs
80+
81+
```bash
82+
kubectl -n openchoreo-observability-plane logs -f deploy/moesif-tracing-collector
83+
```
84+
85+
### Verify the secret exists
86+
87+
```bash
88+
kubectl -n openchoreo-observability-plane get secret moesif-tracing-secret
89+
```
90+
91+
### Check pod health
92+
93+
```bash
94+
kubectl -n openchoreo-observability-plane get pods
95+
```
96+
97+
## Uninstalling
98+
99+
```bash
100+
helm uninstall observability-tracing-moesif \
101+
--namespace openchoreo-observability-plane
102+
```
103+
104+
To also remove the secret:
105+
106+
```bash
107+
kubectl delete secret moesif-tracing-secret \
108+
--namespace openchoreo-observability-plane
109+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2026 The OpenChoreo Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Patterns to ignore when building packages.
5+
# This supports shell glob matching, relative path matching, and
6+
# negation (prefixed with !). Only one pattern per line.
7+
.DS_Store
8+
# Common VCS dirs
9+
.git/
10+
.gitignore
11+
.bzr/
12+
.bzrignore
13+
.hg/
14+
.hgignore
15+
.svn/
16+
# Common backup files
17+
*.swp
18+
*.bak
19+
*.tmp
20+
*.orig
21+
*~
22+
# Various IDEs
23+
.project
24+
.idea/
25+
*.tmproj
26+
.vscode/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: opentelemetry-collector
3+
repository: https://open-telemetry.github.io/opentelemetry-helm-charts
4+
version: 0.140.0
5+
digest: sha256:95b44d32f6aa013cfb900bb0a34e42551bf87c4891cabba2cfc56b1898c13a3b
6+
generated: "2026-04-02T17:13:19.651043+05:30"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2026 The OpenChoreo Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: v2
5+
name: observability-tracing-moesif
6+
description: A Helm chart for OpenChoreo Moesif Tracing module
7+
type: application
8+
version: 0.1.0
9+
appVersion: "0.1.0"
10+
keywords:
11+
- moesif
12+
- observability
13+
- tracing
14+
home: https://github.com/openchoreo/community-modules
15+
maintainers:
16+
- name: Moesif Team
17+
dependencies:
18+
- name: opentelemetry-collector
19+
repository: https://open-telemetry.github.io/opentelemetry-helm-charts
20+
version: 0.140.0
21+
condition: opentelemetry-collector.enabled
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Copyright 2026 The OpenChoreo Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: v1
5+
kind: ConfigMap
6+
metadata:
7+
name: moesif-tracing-collector-config
8+
namespace: {{ .Release.Namespace }}
9+
data:
10+
relay: |
11+
receivers:
12+
otlp:
13+
protocols:
14+
grpc:
15+
endpoint: 0.0.0.0:4317
16+
http:
17+
endpoint: 0.0.0.0:4318
18+
19+
exporters:
20+
{{- if .Values.opentelemetryCollectorCustomizations.debug.enabled }}
21+
debug:
22+
verbosity: detailed
23+
{{- end }}
24+
{{- range .Values.moesif.environments }}
25+
otlphttp/{{ . }}:
26+
endpoint: {{ $.Values.moesif.endpoint | default "https://api.moesif.net" | quote }}
27+
headers:
28+
X-Moesif-Application-Id: ${env:{{ . | replace "-" "_" }}}
29+
{{- end }}
30+
31+
connectors:
32+
routing:
33+
table:
34+
{{- range .Values.moesif.environments }}
35+
- context: resource
36+
statement: route() where resource.attributes["openchoreo.dev/environment"] == {{ . | quote }}
37+
pipelines: [ traces/{{ . }} ]
38+
{{- end }}
39+
40+
extensions:
41+
health_check:
42+
endpoint: ${env:MY_POD_IP}:13133
43+
44+
processors:
45+
k8sattributes:
46+
auth_type: "serviceAccount"
47+
passthrough: false
48+
49+
extract:
50+
labels:
51+
- tag_name: $$1
52+
key_regex: (.*)
53+
from: pod
54+
55+
metadata:
56+
- k8s.pod.name
57+
- k8s.pod.uid
58+
- k8s.deployment.name
59+
- k8s.namespace.name
60+
- k8s.node.name
61+
{{- if .Values.opentelemetryCollectorCustomizations.tailSampling.enabled }}
62+
tail_sampling:
63+
decision_wait: {{ .Values.opentelemetryCollectorCustomizations.tailSampling.decisionWait }}
64+
num_traces: {{ .Values.opentelemetryCollectorCustomizations.tailSampling.numTraces }}
65+
expected_new_traces_per_sec: {{ .Values.opentelemetryCollectorCustomizations.tailSampling.expectedNewTracesPerSec }}
66+
decision_cache:
67+
sampled_cache_size: {{ .Values.opentelemetryCollectorCustomizations.tailSampling.decisionCache.sampledCacheSize }}
68+
non_sampled_cache_size: {{ .Values.opentelemetryCollectorCustomizations.tailSampling.decisionCache.nonSampledCacheSize }}
69+
policies: [
70+
{
71+
name: rate_limiting,
72+
type: rate_limiting,
73+
rate_limiting: {spans_per_second: {{ .Values.opentelemetryCollectorCustomizations.tailSampling.spansPerSecond }} }
74+
},
75+
]
76+
{{- end }}
77+
78+
service:
79+
extensions: [health_check]
80+
pipelines:
81+
traces/in:
82+
receivers: [otlp]
83+
{{- $processors := list }}
84+
{{- $processors = append $processors "k8sattributes" }}
85+
{{- if .Values.opentelemetryCollectorCustomizations.tailSampling.enabled }}
86+
{{- $processors = append $processors "tail_sampling" }}
87+
{{- end }}
88+
{{- if $processors }}
89+
processors: [{{ join ", " $processors }}]
90+
{{- end }}
91+
exporters: [ routing ]
92+
{{- range .Values.moesif.environments }}
93+
traces/{{ . }}:
94+
receivers: [ routing ]
95+
exporters: [ otlphttp/{{ . }}{{- if $.Values.opentelemetryCollectorCustomizations.debug.enabled }}, debug{{- end }} ]
96+
{{- end }}
97+
telemetry:
98+
metrics:
99+
readers:
100+
- pull:
101+
exporter:
102+
prometheus:
103+
host: '0.0.0.0'
104+
port: 8888
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2026 The OpenChoreo Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
## -----------------------------------------------------------
5+
## Values for OpenTelemetry Collector configuration
6+
## -----------------------------------------------------------
7+
opentelemetry-collector:
8+
enabled: true
9+
fullnameOverride: "moesif-tracing-collector"
10+
11+
clusterRole:
12+
create: true
13+
rules:
14+
- apiGroups: [""]
15+
resources: ["pods"]
16+
verbs: ["list", "watch"]
17+
- apiGroups: ["apps"]
18+
resources: ["replicasets"]
19+
verbs: ["list", "watch"]
20+
21+
configMap:
22+
create: false
23+
existingName: "moesif-tracing-collector-config"
24+
25+
image:
26+
repository: otel/opentelemetry-collector-contrib
27+
28+
mode: deployment
29+
30+
extraEnvsFrom:
31+
- secretRef:
32+
name: moesif-tracing-secret
33+
34+
resources:
35+
limits:
36+
cpu: 100m
37+
memory: 200Mi
38+
requests:
39+
cpu: 50m
40+
memory: 100Mi
41+
42+
service:
43+
type: ClusterIP
44+
45+
opentelemetryCollectorCustomizations:
46+
debug:
47+
enabled: false
48+
49+
tailSampling:
50+
enabled: true
51+
decisionWait: 10s
52+
numTraces: 100
53+
expectedNewTracesPerSec: 10
54+
decisionCache:
55+
sampledCacheSize: 10000
56+
nonSampledCacheSize: 1000
57+
spansPerSecond: 10
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright 2026 The OpenChoreo Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Module manifest used by the CI workflow to discover Docker images to build.
5+
# Each entry defines the image name, build context, Dockerfile path, and the
6+
# corresponding field in helm/values.yaml to update with the published image URI.
7+
8+
images: []

0 commit comments

Comments
 (0)