https://github.com/shaharia-lab/telemetry-collector
A telemetry collector for receiving telemetry data and forward to a specified endpoint (i.e: Honeycomb)
https://github.com/shaharia-lab/telemetry-collector
honeycomb open-source open-telemetry otel telemetry
Last synced: about 1 month ago
JSON representation
A telemetry collector for receiving telemetry data and forward to a specified endpoint (i.e: Honeycomb)
- Host: GitHub
- URL: https://github.com/shaharia-lab/telemetry-collector
- Owner: shaharia-lab
- License: mit
- Created: 2025-04-04T12:05:46.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-04-04T17:45:40.000Z (6 months ago)
- Last Synced: 2025-08-30T05:02:16.698Z (about 1 month ago)
- Topics: honeycomb, open-source, open-telemetry, otel, telemetry
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Telemetry Package
A Go package for sending telemetry events following OpenTelemetry standards.
## Features
- OpenTelemetry-compatible event structure
- Synchronous and asynchronous sending methods
- Automatic addition of required fields (timestamp, severity numbers)
- Configurable service name
- Helper methods for common event types
- Background processing for non-blocking operations## Installation
```bash
go get github.com/shaharia-lab/telemetry-collector
```## Usage
### Basic Setup
```go
import (
"context"
"time"
"github.com/shaharia-lab/telemetry-collector"
)func main() {
// Create a collector with endpoint and service name
collector := telemetry.NewCollector(
"https://telemetry-service.example.com/telemetry/event",
"my-service"
)
defer collector.Close() // Ensure proper shutdown
// Your application code...
}
```### Sending Events Synchronously
```go
// Send a synchronous event with full control over fields
err := collector.SendSync(context.Background(), &telemetry.TelemetryEvent{
Name: "user.login",
TraceID: "trace-123",
SpanID: "span-456",
SeverityText: telemetry.SeverityInfo,
Body: "User logged in successfully",
Attributes: map[string]string{
"user_id": "user-123",
"region": "us-west",
},
})
if err != nil {
log.Printf("Failed to send event: %v", err)
}
```### Sending Events Asynchronously
```go
// Send an asynchronous event (non-blocking)
collector.SendAsync(&telemetry.TelemetryEvent{
Name: "background.task",
TraceID: "trace-789",
SpanID: "span-012",
SeverityText: telemetry.SeverityDebug,
Body: "Background task started",
})
```### Using Helper Methods
```go
// Using the helper method for info events
collector.InfoEvent(
context.Background(),
"app.startup",
"Application started",
map[string]string{"version": "1.0.0"}
)
```## Severity Levels
The package includes standard severity levels:
- `SeverityTrace` (1)
- `SeverityDebug` (5)
- `SeverityInfo` (9)
- `SeverityWarn` (13)
- `SeverityError` (17)
- `SeverityFatal` (21)## Event Structure
Events follow the OpenTelemetry format:
```go
type TelemetryEvent struct {
Name string `json:"name"`
TimeUnixNano int64 `json:"timeUnixNano"`
TraceID string `json:"traceId"`
SpanID string `json:"spanId"`
SeverityText Severity `json:"severityText"`
SeverityNumber int `json:"severityNumber"`
Body string `json:"body"`
Attributes map[string]string `json:"attributes,omitempty"`
Resource Resource `json:"resource"`
}
```## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.