Skip to content

Commit 85f690c

Browse files
authored
Merge pull request #13 from armitageee/develop
feat: [ add tracing ]
2 parents d81e9a5 + 7b07d44 commit 85f690c

33 files changed

+1593
-134
lines changed

.env.example

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,35 @@
1-
# FACEIT API Key
2-
# Get your API key from: https://developers.faceit.com/
3-
FACEIT_API_KEY=your_api_key_here
1+
# FACEIT API Configuration
2+
FACEIT_API_KEY=your_faceit_api_key_here
43

5-
# Default player nickname (optional)
6-
# If set, this player will be loaded automatically on startup
7-
FACEIT_DEFAULT_PLAYER=your_nickname_here
4+
# Optional: Default player nickname
5+
FACEIT_DEFAULT_PLAYER=
86

9-
# Logging configuration
10-
# Log level: debug, info, warn, error (default: info)
7+
# Logging Configuration
118
LOG_LEVEL=info
9+
LOG_TO_STDOUT=true
10+
PRODUCTION_MODE=false
1211

13-
# Kafka configuration
14-
# Enable Kafka logging (default: false)
12+
# Kafka Configuration (optional)
1513
KAFKA_ENABLED=false
16-
17-
# Kafka brokers (comma-separated, default: localhost:9092)
1814
KAFKA_BROKERS=localhost:9092
19-
20-
# Kafka topic for logs (default: faceit-cli-logs)
2115
KAFKA_TOPIC=faceit-cli-logs
2216

23-
# Production mode settings
24-
# Enable production mode (default: false)
25-
PRODUCTION_MODE=false
26-
27-
# Log to stdout (default: true, set to false in production)
28-
LOG_TO_STDOUT=true
29-
30-
# Pagination settings
31-
# Matches per page (default: 10)
17+
# Pagination Configuration
3218
MATCHES_PER_PAGE=10
33-
34-
# Maximum matches to load (default: 100)
3519
MAX_MATCHES_TO_LOAD=100
20+
COMPARISON_MATCHES=20
3621

37-
# Cache settings
38-
# Enable caching (default: false)
22+
# Cache Configuration
3923
CACHE_ENABLED=false
40-
41-
# Cache TTL in minutes (default: 30)
4224
CACHE_TTL=30
4325

44-
# Comparison settings
45-
# Number of matches to use for player comparison (default: 20)
46-
COMPARISON_MATCHES=20
26+
# Telemetry Configuration
27+
TELEMETRY_ENABLED=true
28+
OTLP_ENDPOINT=http://localhost:4318
29+
ZIPKIN_ENDPOINT=http://localhost:9411/api/v2/spans
30+
SERVICE_NAME=faceit-cli
31+
SERVICE_VERSION=1.0.0
32+
ENVIRONMENT=development
4733

48-
# Match Search Features
49-
# - Search matches by ID from main menu (press '2')
50-
# - Paste match IDs with Ctrl+V, Cmd+V, F2, or P
51-
# - View detailed team statistics for any match
52-
# - Cross-platform clipboard support (macOS, Linux, Windows)
34+
# Suppress OpenTelemetry logs to avoid stdout pollution
35+
OTEL_LOG_LEVEL=info

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ Thumbs.db
4040
# Coverage
4141
coverage.out
4242
coverage.html
43+
44+
/bazel-*
45+
WARP.md

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ run-optimized:
196196
@echo "Running with all optimizations..."
197197
CACHE_ENABLED=true CACHE_TTL=30 MATCHES_PER_PAGE=10 MAX_MATCHES_TO_LOAD=50 go run main.go
198198

199+
# Initialize configuration
200+
.PHONY: init
201+
init:
202+
@echo "Initializing configuration..."
203+
@go run main.go init
204+
205+
# Install via go install
206+
.PHONY: install
207+
install:
208+
@echo "Installing faceit-cli via go install..."
209+
@go install github.com/armitageee/faceit-cli@latest
210+
199211
# Help
200212
.PHONY: help
201213
help:
@@ -213,6 +225,8 @@ help:
213225
@echo " clean - Clean build artifacts"
214226
@echo " deps - Install dependencies"
215227
@echo " install-tools - Install development tools"
228+
@echo " init - Initialize configuration file"
229+
@echo " install - Install via go install"
216230
@echo " docker-build - Build Docker image"
217231
@echo " docker-run - Run in Docker with .env file"
218232
@echo " run - Build and run the application"

README.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,27 @@ A beautiful terminal user interface (TUI) for viewing FACEIT player profiles and
2222

2323
## Quick Start
2424

25-
### Option 1: Pre-built Binaries
25+
### Option 1: Go Install (Recommended)
26+
27+
```bash
28+
# Install the latest version
29+
go install github.com/armitageee/faceit-cli@latest
30+
31+
# Initialize configuration
32+
faceit-cli init
33+
34+
# Edit the config file and add your API key
35+
# ~/.config/faceit-cli/config.yml
36+
37+
# Run the application
38+
faceit-cli
39+
```
40+
41+
### Option 2: Pre-built Binaries
2642

2743
Download the latest release from the [Releases page](https://github.com/armitageee/faceit-cli/releases) and extract the binary for your platform.
2844

29-
### Option 2: Docker
45+
### Option 3: Docker
3046

3147
```bash
3248
# Clone the repository
@@ -80,7 +96,45 @@ make run-production
8096

8197
## Configuration
8298

83-
Create a `.env` file in the project root:
99+
### Configuration Priority
100+
101+
The application uses a flexible configuration system with the following priority order:
102+
103+
1. **Environment Variables** (highest priority)
104+
2. **YAML Configuration** (`~/.config/faceit-cli/config.yml`)
105+
3. **Default Values** (lowest priority)
106+
107+
### YAML Configuration
108+
109+
The application supports YAML configuration files for better user experience:
110+
111+
```bash
112+
# Initialize default config
113+
faceit-cli init
114+
115+
# Edit the config file
116+
# ~/.config/faceit-cli/config.yml
117+
```
118+
119+
### Environment Variables Override
120+
121+
Environment variables always take priority over YAML configuration. This is useful for:
122+
- Production deployments
123+
- CI/CD pipelines
124+
- Temporary overrides
125+
- Security-sensitive values
126+
127+
**Example:**
128+
```bash
129+
# YAML config has: log_level: "info", cache_enabled: true
130+
# Environment variable overrides it:
131+
export LOG_LEVEL="debug"
132+
export CACHE_ENABLED="false"
133+
134+
# Result: log_level="debug", cache_enabled=false
135+
```
136+
137+
You can use environment variables or a `.env` file in the project root:
84138

85139
```bash
86140
# Required

config.example.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# FACEIT CLI Configuration
2+
# Copy this file to ~/.config/faceit-cli/config.yml and configure your settings
3+
4+
# Required: Your FACEIT API key
5+
api_key: "your_faceit_api_key_here"
6+
7+
# Optional: Default player to load on startup
8+
default_player: ""
9+
10+
# Logging settings
11+
log_level: "info" # debug, info, warn, error
12+
log_to_stdout: false
13+
production_mode: false
14+
15+
# Pagination settings
16+
matches_per_page: 10
17+
max_matches_to_load: 100
18+
comparison_matches: 20
19+
20+
# Caching settings
21+
cache_enabled: true
22+
cache_ttl: 30 # minutes
23+
24+
# Kafka integration (optional)
25+
kafka_enabled: false
26+
kafka_brokers: "localhost:9092"
27+
kafka_topic: "faceit-cli-logs"
28+
29+
# Telemetry settings (optional)
30+
telemetry_enabled: false
31+
otlp_endpoint: "localhost:4317"
32+
service_name: "faceit-cli"
33+
service_version: "1.0.0"
34+
environment: "development"
35+
otel_log_level: "fatal"

docker-compose.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,51 @@ services:
6767
"
6868
restart: "no"
6969

70+
# OpenTelemetry Collector
71+
otel-collector:
72+
image: otel/opentelemetry-collector-contrib:0.95.0
73+
container_name: faceit-cli-otel-collector
74+
command: ["--config=/etc/otel-collector-config.yaml"]
75+
volumes:
76+
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
77+
ports:
78+
- "4317:4317" # OTLP gRPC receiver
79+
- "4318:4318" # OTLP HTTP receiver
80+
- "8888:8888" # Prometheus metrics
81+
- "8889:8889" # Prometheus exporter metrics
82+
depends_on:
83+
- zipkin
84+
environment:
85+
- OTEL_RESOURCE_ATTRIBUTES=service.name=faceit-cli-collector,service.version=1.0.0
86+
87+
# Zipkin for trace visualization
88+
zipkin:
89+
image: openzipkin/zipkin:3.3
90+
container_name: faceit-cli-zipkin
91+
ports:
92+
- "9411:9411"
93+
environment:
94+
- STORAGE_TYPE=mem
95+
- MYSQL_HOST=zipkin-mysql
96+
- MYSQL_USER=zipkin
97+
- MYSQL_PASS=zipkin
98+
healthcheck:
99+
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:9411/health"]
100+
interval: 30s
101+
timeout: 10s
102+
retries: 3
103+
104+
# Jaeger as alternative trace backend (optional)
105+
# jaeger:
106+
# image: jaegertracing/all-in-one:1.55
107+
# container_name: faceit-cli-jaeger
108+
# ports:
109+
# - "16686:16686" # Jaeger UI
110+
# - "14250:14250" # Jaeger gRPC
111+
# environment:
112+
# - COLLECTOR_OTLP_ENABLED=true
113+
# profiles:
114+
# - jaeger
115+
70116
volumes:
71117
kafka-data:
File renamed without changes.

0 commit comments

Comments
 (0)