Skip to content

Commit 398502e

Browse files
committed
Initial codebase
0 parents  commit 398502e

File tree

17 files changed

+849
-0
lines changed

17 files changed

+849
-0
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export HONEYCOMB_API_KEY=your_api_key_here
2+
export HONEYCOMB_DATASET=cli-telemetry
3+
export HONEYCOMB_API_URL=https://api.eu1.honeycomb.io
4+
export PORT=8080

.github/workflows/CI.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
name: test
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 20
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v4
24+
with:
25+
go-version: '1.24'
26+
27+
- name: Run Backend Tests
28+
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
29+
30+
- name: Publish artifacts
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: coverage-${{ github.sha }}
34+
path: coverage.out
35+
retention-days: 1
36+
37+
lint:
38+
name: lint
39+
permissions:
40+
contents: read
41+
pull-requests: write
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v3
45+
with:
46+
fetch-depth: 0
47+
48+
- uses: actions/setup-go@v5
49+
with:
50+
go-version: '^1.24'
51+
check-latest: true
52+
cache: true
53+
go-version-file: 'go.mod'
54+
cache-dependency-path: |
55+
go.sum
56+
57+
- name: Lint Code Base
58+
uses: github/super-linter/slim@v4
59+
continue-on-error: true
60+
env:
61+
VALIDATE_ALL_CODEBASE: false
62+
DEFAULT_BRANCH: main
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
65+
code-analysis:
66+
runs-on: ubuntu-latest
67+
needs: [ test ]
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v3
71+
with:
72+
fetch-depth: 0
73+
74+
- name: Download backend test coverage
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: coverage-${{ github.sha }}
78+
path: ./
79+
continue-on-error: true
80+
81+
- name: SonarCloud Scan
82+
uses: sonarsource/sonarcloud-github-action@master
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
86+
87+
docker-build:
88+
name: Docker Build
89+
needs:
90+
- test
91+
runs-on: ubuntu-latest
92+
steps:
93+
- name: Checkout code
94+
uses: actions/checkout@v3
95+
96+
- name: Set up Docker Buildx
97+
uses: docker/setup-buildx-action@v2
98+
99+
- name: Build Docker image
100+
uses: docker/build-push-action@v4
101+
with:
102+
context: ./
103+
file: ./Dockerfile
104+
push: false
105+
load: true
106+
tags: telemetry-forwarder:${{ github.sha }}
107+
108+
- name: Cleanup
109+
if: always()
110+
run: docker image rm telemetry-forwarder:${{ github.sha }}
111+
112+
release:
113+
name: Test Release
114+
needs:
115+
- docker-build
116+
runs-on: ubuntu-latest
117+
steps:
118+
- uses: actions/checkout@v3
119+
with:
120+
fetch-depth: 0
121+
122+
- uses: actions/setup-go@v3
123+
with:
124+
go-version: '^1.24'
125+
126+
- uses: docker/login-action@v1
127+
with:
128+
registry: ghcr.io
129+
username: ${{ github.repository_owner }}
130+
password: ${{ secrets.GITHUB_TOKEN }}
131+
132+
- name: Create temporary tag
133+
run: |
134+
git config user.name "GitHub Actions"
135+
git config user.email "[email protected]"
136+
git tag -a v${{ github.run_number }}.0.0 -m "Test tag for GoReleaser"
137+
138+
- uses: goreleaser/goreleaser-action@v6
139+
with:
140+
version: '~> v2'
141+
args: release --skip=publish --clean --fail-fast --verbose
142+
env:
143+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: actions/setup-go@v3
21+
with:
22+
go-version: '^1.24'
23+
24+
- uses: docker/login-action@v1
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.repository_owner }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- uses: goreleaser/goreleaser-action@v6
31+
if: success() && startsWith(github.ref, 'refs/tags/')
32+
with:
33+
version: '~> v2'
34+
args: release --clean
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea
2+
/telemetry-forwarder
3+
/.env

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM golang:1.24-alpine AS builder
2+
RUN apk add --no-cache git
3+
4+
WORKDIR /app
5+
RUN adduser -D -g '' app
6+
7+
COPY . .
8+
9+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -trimpath -o build/telemetry-forwarder .
10+
11+
FROM alpine:3.19
12+
13+
RUN apk add --no-cache ca-certificates tzdata
14+
15+
COPY --from=builder /etc/passwd /etc/passwd
16+
17+
COPY --from=builder /app/build/telemetry-forwarder /usr/local/bin/telemetry-forwarder
18+
19+
USER app
20+
21+
ENV TZ=UTC \
22+
APP_USER=app
23+
24+
ENTRYPOINT ["/usr/local/bin/telemetry-forwarder"]
25+
26+
CMD []

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Shaharia Lab OÜ
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# OpenTelemetry to Honeycomb Forwarder
2+
3+
A lightweight service that forwards OpenTelemetry events to Honeycomb.io.
4+
5+
## Overview
6+
7+
This service acts as a bridge between applications sending OpenTelemetry-formatted telemetry data and the Honeycomb.io
8+
observability platform. It receives OpenTelemetry events via an HTTP endpoint and forwards them to Honeycomb's API.
9+
10+
## Features
11+
12+
- Accepts OpenTelemetry-formatted events via HTTP
13+
- Transforms events to Honeycomb's format
14+
- CORS support for cross-origin requests
15+
- Configurable via environment variables
16+
17+
## Configuration
18+
19+
The service is configured using environment variables:
20+
21+
| Variable | Description | Default |
22+
|---------------------|-----------------------------------------|---------------------|
23+
| `PORT` | The port the server will listen on | `8080` |
24+
| `HONEYCOMB_API_KEY` | Your Honeycomb API key | (required) |
25+
| `HONEYCOMB_DATASET` | The Honeycomb dataset to send events to | `cli-telemetry` |
26+
| `HONEYCOMB_API_URL` | Custom Honeycomb API URL (optional) | (Honeycomb default) |
27+
28+
## Getting Started
29+
30+
### Prerequisites
31+
32+
- Go 1.x
33+
34+
### Running the Service
35+
36+
1. Set required environment variables:
37+
38+
```bash
39+
export HONEYCOMB_API_KEY=your-api-key
40+
```
41+
42+
2. Build and run the service:
43+
44+
```bash
45+
go build
46+
./otel-honeycomb-forwarder
47+
```
48+
49+
## API
50+
51+
### POST /telemetry/event
52+
53+
Accepts OpenTelemetry events and forwards them to Honeycomb.
54+
55+
**Request Body**: An OpenTelemetry event with the following structure:
56+
57+
```json
58+
{
59+
"name": "event_name",
60+
"timeUnixNano": 1639083272000000000,
61+
"traceId": "trace-id",
62+
"spanId": "span-id",
63+
"severityText": "INFO",
64+
"severityNumber": 9,
65+
"body": "Event message or data",
66+
"attributes": {
67+
"key1": "value1",
68+
"key2": "value2"
69+
},
70+
"resource": {
71+
"service.name": "my-service"
72+
}
73+
}
74+
```
75+
76+
## License
77+
78+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/shaharia-lab/telemetry-forwarder
2+
3+
go 1.24.1
4+
5+
require github.com/kelseyhightower/envconfig v1.4.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
2+
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=

goreleaser.dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This dockerfile is only used to build the backend image for the application using goreleaser.
2+
FROM scratch
3+
COPY telemetry-forwarder /app/telemetry-forwarder
4+
ENTRYPOINT []

0 commit comments

Comments
 (0)