Open mterhar opened 4 days ago
Dockerfile
FROM golang:1.23 AS build
ARG OTEL_VERSION=0.112.0
WORKDIR /app
RUN \
curl -SsL https://github.com/mterhar/libhoneyreceiver/archive/refs/tags/v0.1.tar.gz | tar -xzC /app/
RUN go install go.opentelemetry.io/collector/cmd/builder@v${OTEL_VERSION}
COPY . .
RUN CGO_ENABLED=0 builder --config=manifest.yaml --output-path=/app
FROM cgr.dev/chainguard/static:latest
COPY --from=build /app/otelcol-custom /
# COPY config.yaml /
EXPOSE 4317/tcp 4318/tcp 13133/tcp
CMD ["/otelcol-custom", "--config=/config.yaml"]
Manifest.yaml
dist:
name: otelcol-custom
description: Custom otel collector with Libhoney receiver
output_path: ./otelcol-custom
version: 0.112.0
otelcol_version: 0.112.0
debug_compilation: true
extensions:
- gomod: go.opentelemetry.io/collector/extension/zpagesextension v0.112.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.112.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/bearertokenauthextension v0.112.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/headerssetterextension v0.112.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.112.0
exporters:
- gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.112.0
- gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.112.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter v0.112.0
processors:
- gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.112.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.112.0
receivers:
- gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.112.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/libhoneyreceiver v0.1.0
providers:
- gomod: go.opentelemetry.io/collector/confmap/provider/envprovider v1.18.0
connectors:
- gomod: go.opentelemetry.io/collector/connector/forwardconnector v0.112.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector v0.112.0
replaces:
- github.com/open-telemetry/opentelemetry-collector-contrib/receiver/libhoneyreceiver v0.1.0 => ./libhoneyreceiver-0.1
Otel configuration
receivers:
libhoney:
http:
endpoint: 0.0.0.0:8088
traces_url_paths:
- "/1/events/"
- "/1/batch/"
include_metadata: true
auth_api: https://api.honeycomb.io
resources:
service_name: service.name
scopes:
library_name: library.name
library_version: library.version
attributes:
trace_id: trace_id
parent_id: parent_id
span_id: span_id
name: name
error: error
spankind: span.kind
durationFields:
- duration_ms
processors:
batch:
metadata_keys:
- x-honeycomb-team
metadata_cardinality_limit: 30
transform:
error_mode: ignore
trace_statements:
- context: resource
statements:
- set(attributes["collector.after_refinery"], "${env:HOSTNAME}")
exporters:
debug:
verbosity: detailed
file:
path: ./output.json
otlp:
endpoint: "api.honeycomb.io:443"
auth:
authenticator: headers_setter
extensions:
headers_setter:
headers:
- action: upsert
key: x-honeycomb-team
from_context: x-honeycomb-team
service:
extensions:
- headers_setter
pipelines:
traces:
receivers: [libhoney]
processors: [transform, batch]
exporters: [otlp]
telemetry:
logs:
level: info
Files are in comments below.
Steps
This uses docker rather than installing any depdenceies locally.
This runs a 2 stage build with go:1.23 and then creates a container that runs
otelcol-custom
.To use the container, put a n otel config file in a directory and run
Make sure you add the
-p
for any ports you're exposing for OTLP or other receivers as well.