Skip to content

Commit

Permalink
Add OTEL collector code
Browse files Browse the repository at this point in the history
  • Loading branch information
rockdaboot committed Jul 18, 2024
1 parent d386d27 commit 0cf8254
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
8 changes: 8 additions & 0 deletions otel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
collector/components.go
collector/go.mod
collector/go.sum
collector/main.go
collector/main_others.go
collector/main_windows.go
collector/profiling-collector
ocb
28 changes: 28 additions & 0 deletions otel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
The collector code is just meant as an example.
The receiver code needs to use the OTEL profiling API, once that is available.
Technically, the receiver and collector code can both live in separate repositories.


To get the `ocb` tool (OTEL collector builder, amend version):
```
curl --proto '=https' --tlsv1.2 -fL -o ocb https://github.com/open-telemetry/opentelemetry-collector/releases/download/cmd%2Fbuilder%2Fv0.104.0/ocb_0.104.0_linux_amd64
chmod a+x ocb
```

To build a static version of the collector with glibc
```
./ocb --skip-strict-versioning --verbose --config builder-config.yaml
```

To build a static version of the collector with muslc (on x86/amd64)
```
CC=x86_64-linux-musl-gcc \
CGO_ENABLED=1 \
./ocb --skip-strict-versioning --verbose --config builder-config.yaml \
--ldflags="-linkmode external -extldflags=-static"
```

Run the collector (start devfiler first)
```
sudo collector/profiling-collector --config collector/config.yaml
```
23 changes: 23 additions & 0 deletions otel/builder-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
dist:
name: profiling-collector
description: Profiling OTel Collector distribution
output_path: ./collector
otelcol_version: 0.104.0

exporters:
- gomod:
go.opentelemetry.io/collector/exporter/debugexporter v0.104.0
- gomod:
go.opentelemetry.io/collector/exporter/otlpexporter v0.104.0

processors:
- gomod:
go.opentelemetry.io/collector/processor/batchprocessor v0.104.0

receivers:
- gomod:
go.opentelemetry.io/collector/receiver/otlpreceiver v0.104.0
- gomod:
github.com/elastic/otel-profiling-agent v0.0.0-20240717140952-d386d2702214
import: github.com/elastic/otel-profiling-agent/otel/receiver
name: profilingreceiver
32 changes: 32 additions & 0 deletions otel/collector/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
otelreceiver: # this line represents the ID of your receiver
project-id: 123
collection-agent: 127.0.0.1:11000
verbose: true
disable-tls: true
secret-token: abc123

processors:
batch:

exporters:
debug:
verbosity: detailed
# otlp/jaeger:
# endpoint: localhost:14317
# tls:
# insecure: true

service:
pipelines:
traces:
receivers: [ otlp, otelreceiver ]
processors: [ batch ]
exporters: [ debug ]
telemetry:
logs:
level: debug

0 comments on commit 0cf8254

Please sign in to comment.