Commit Graph
100 Commits
Author SHA1 Message Date
ask 1df4b0d4b4 feat(tracing): add bearer token authentication for OTLP exporters
Add BearerTokenFunc to support dynamic bearer token authentication
for OTLP exporters. Tokens are injected per-request via gRPC
PerRPCCredentials and HTTP custom RoundTripper.

- Add BearerTokenFunc type and Config field in tracerconfig
- Implement bearerCredentials (gRPC) and bearerRoundTripper (HTTP)
- Wire bearer auth into all exporter creation functions
- Add getHTTPClient helper for DRY HTTP client configuration
- Upgrade OpenTelemetry SDK to v1.39.0 for WithHTTPClient support
2026-01-01 03:39:01 -08:00
ask d43ff0f2a9 fix(pgdb): align pool defaults with pgxpool
Change MaxConns default from 25 to 4 to match pgxpool defaults.
This ensures consistent behavior between DATABASE_URI and config
file modes, and removes the warning log when using URI mode.

Defaults now reference: https://pkg.go.dev/github.com/jackc/pgx/v5/pgxpool#Config
2025-11-30 09:35:55 -08:00
ask 66a72265ce feat(pgdb): export config discovery functions for display purposes
Add FindConfig, ParseURIConfig, and GetConfigFiles as exported functions
to allow callers to retrieve database configuration info without
establishing a connection. Useful for version/startup info display.
2025-11-29 13:04:36 -08:00
ask 94b718a925 fix(database): correct metrics and improve error handling
- Fix metrics double-counting: track deltas for WaitCount/WaitDuration
  instead of adding cumulative values each tick
- Replace fmt.Printf with structured logging in pool monitor
- Add PoolOptions validation (MaxConns > 0, MinConns >= 0)
- Warn when DATABASE_URI overrides non-default PoolOptions
- Improve findAndParseConfig to report all tried files and errors
- Remove dead code in pgdb/config.go (unreachable host default)
- Fix errcheck lint issues for file.Close() calls
- Add context parameter to OpenDBMonitor() (breaking change)
2025-11-29 12:56:49 -08:00
ask 283d3936f6 feat(pgdb): add DATABASE_URI environment variable support
Add support for PostgreSQL connection URIs via DATABASE_URI env var.
When set, it takes precedence over config files and PoolOptions are
ignored (pool settings can be specified in URI query string).
2025-11-29 11:52:45 -08:00
ask 7291f00f48 feat(metricsserver): add Gatherer method
Add explicit Gatherer() method to improve API discoverability
and prevent users from accidentally using prometheus.DefaultGatherer
instead of the custom registry.

Changes:
- Add Gatherer() method returning prometheus.Gatherer interface
- Add NewWithDefaultGatherer() constructor for opt-in default usage
- Update package docs with usage examples
- Add tests for both gatherer modes
2025-10-12 16:13:19 -07:00
ask 2670d25b52 feat(config): add pool_domain and upgrade dependencies
- Add configurable pool_domain with pool.ntp.org default
- Update Go from 1.23.5 to 1.24.0
- Update golang.org/x/* dependencies
- Add enumer and accessory as tool dependencies
- Update goreleaser to v2.12.3
2025-10-04 03:55:38 -07:00
ask 45308cd4bf feat(database): add PostgreSQL support with native pgx pool
Add PostgreSQL support to database package alongside existing MySQL support.
Both databases share common infrastructure (pool management, metrics,
transactions) while using database-specific connectors.

database/ changes:
- Add PostgresConfig struct and PostgreSQL connector using pgx/stdlib
- Change MySQL config from DBConfig to *MySQLConfig (pointer)
- Add Config.Validate() to prevent multiple database configs
- Add PostgreSQL connector with secure config building (no password in DSN)
- Add field validation and secure defaults (SSLMode="prefer")
- Support legacy flat PostgreSQL config format for backward compatibility
- Add tests for PostgreSQL configs and validation

New database/pgdb/ package:
- Native pgx connection pool support (*pgxpool.Pool)
- OpenPool() and OpenPoolWithConfigFile() APIs
- CreatePoolConfig() for secure config conversion
- PoolOptions for fine-grained pool control
- Full test coverage and documentation

Security:
- Passwords never exposed in DSN strings
- Set passwords separately in pgx config objects
- Validate all configuration before connection

Architecture:
- Shared code in database/ for both MySQL and PostgreSQL (sql.DB)
- database/pgdb/ for PostgreSQL-specific native pool support
2025-09-27 16:55:54 -07:00
ask 4767caf7b8 feat(xff): add AddTrustedCIDR for custom proxies
- Add AddTrustedCIDR() method to support non-Fastly proxies
- Enable trusting custom CIDR ranges (e.g., 10.0.0.0/8)
- Validate CIDR format before adding to trusted list
- Maintain backward compatibility with Fastly-only usage

Allows mixed proxy environments where requests pass through
both Fastly CDN and custom internal proxies/load balancers.
Uses precise CIDR terminology instead of generic "range".
2025-09-27 14:46:02 -07:00
ask f90281f472 feat(xff): add net/http middleware support
- Add HTTPMiddleware() method for standard net/http handlers
- Add GetRealIP() helper to extract client IP from context
- Update r.RemoteAddr with real IP and port 0 (proxy port invalid)
- Support both IPv4 and IPv6 Fastly IP range validation
- Maintain backward compatibility with existing Echo support

The middleware extracts real client IPs from X-Forwarded-For
headers when requests come from trusted Fastly proxy ranges.
2025-09-27 13:41:12 -07:00
ask ca190b0085 docs: add v0.5.2 release notes
Add changelog entries for recent commits:
- Health package: Kubernetes health probes
- Logger package: runtime level control and fixes
- Database package: config file override support
2025-09-21 12:10:05 -07:00
ask 10864363e2 feat(health): enhance server with probe-specific handlers
- Add separate handlers for liveness (/healthz), readiness (/readyz),
  and startup (/startupz) probes
- Implement WithLivenessHandler, WithReadinessHandler, WithStartupHandler,
  and WithServiceName options
- Add probe-specific JSON response formats
- Add comprehensive package documentation with usage examples
- Maintain backward compatibility for /__health and / endpoints
- Add tests for all probe types and fallback scenarios

Enables proper Kubernetes health monitoring with different probe types.
2025-09-21 10:52:29 -07:00
ask 66b51df2af feat(logger): add runtime log level control API
Add independent log level control for stderr and OTLP loggers.
Both can be configured via environment variables or programmatically
at runtime.

- Add SetLevel() and SetOTLPLevel() for runtime control
- Add ParseLevel() to convert strings to slog.Level
- Support LOG_LEVEL and OTLP_LOG_LEVEL env vars
- Maintain backward compatibility with DEBUG env var
- Add comprehensive test coverage
2025-09-06 05:21:33 -07:00
ask 28d05d1d0e feat(database): add DATABASE_CONFIG_FILE env override
Allow overriding default database.yaml paths via DATABASE_CONFIG_FILE
environment variable. When set, uses single specified file instead of
default ["database.yaml", "/vault/secrets/database.yaml"] search paths.

Maintains backward compatibility when env var not set.
2025-08-03 12:20:35 -07:00
ask a774f92bf7 fix(logger): prevent mutex crash in bufferingExporter
Remove sync.Once reset that caused "unlock of unlocked mutex" panic.
Redesign initialization to use only checkReadiness goroutine for
retry attempts, eliminating race condition while preserving retry
functionality for TLS/tracing setup delays.
2025-08-02 22:55:57 -07:00
ask 0b9769dc39 Prepare v0.5.1 2025-08-02 11:04:13 -07:00
ask 9dadd9edc3 feat(version): add Unix epoch support for buildTime
Support both Unix epoch timestamps and RFC3339 format for build time
injection via ldflags. Unix epoch format provides simpler build
commands: $(date +%s) vs $(date -u +%Y-%m-%dT%H:%M:%SZ).

- Add parseBuildTime() to convert epoch to RFC3339
- Maintain backward compatibility with existing RFC3339 format
- Ensure consistent RFC3339 output regardless of input format
- Fix build date priority over git commit time
2025-08-02 10:16:41 -07:00
ask c6230be91e feat(metrics): add OTLP metrics support with centralized config
- Create new metrics/ package for OpenTelemetry-native metrics with OTLP export
- Refactor OTLP configuration to internal/tracerconfig/ to eliminate code duplication
- Add consistent retry configuration across all HTTP OTLP exporters
- Add configuration validation and improved error messages
- Include test coverage for all new functionality
- Make OpenTelemetry metrics dependencies explicit in go.mod

Designed for new applications requiring structured metrics export to
observability backends via OTLP protocol.
2025-08-02 09:29:27 -07:00
ask 796b2a8412 tracing: enable retrying otlp requests when using http 2025-07-27 17:13:06 -07:00
ask 6a3bc7bab3 feat(logger): add buffering exporter with TLS support for OTLP logs
Add buffering exporter to queue OTLP logs until tracing is configured.
Support TLS configuration for OpenTelemetry log export with client
certificate authentication. Improve logfmt formatting and tracing setup.
2025-07-27 16:36:18 -07:00
ask da13a371b4 feat(database): add shared transaction helpers
Add transaction base utilities with Begin, Commit, and Rollback
functions supporting both sql.DB and sql.Tx interfaces.
2025-07-12 23:52:48 -07:00
ask a1a5a6b8be database: create shared database package
Extract common database functionality from api/ntpdb and monitor/ntpdb
into shared common/database package:

- Dynamic connector pattern with configuration loading
- Configurable connection pool management (API: 25/10, Monitor: 10/5)
- Optional Prometheus metrics integration
- Generic transaction helpers with proper error handling
- Unified interfaces compatible with SQLC-generated code

Foundation for migration to eliminate ~200 lines of duplicate code.
2025-07-12 17:59:28 -07:00
ask 96afb77844 database: create shared database package with configurable patterns
Extract ~200 lines of duplicate database connection code from api/ntpdb/
and monitor/ntpdb/ into common/database/ package. Creates foundation for
database consolidation while maintaining zero breaking changes.

Files added:
- config.go: Unified configuration with package-specific defaults
- connector.go: Dynamic connector pattern from Boostport
- pool.go: Configurable connection pool management
- metrics.go: Optional Prometheus metrics integration
- interfaces.go: Shared database interfaces for consistent patterns

Key features:
- Configuration-driven approach (API: 25/10 connections + metrics,
  Monitor: 10/5 connections, no metrics)
- Optional Prometheus metrics when registerer provided
- Backward compatibility via convenience functions
- Flexible config file loading (explicit paths + search-based)

Dependencies: Added mysql driver and yaml parsing for database configuration.
2025-07-12 16:54:24 -07:00
ask c372d79d1d build: goreleaser 2.11.0 and download script tweaks 2025-07-12 16:51:10 -07:00
ask b5141d6a70 Add database transaction helpers 2025-07-12 13:57:27 -07:00
ask 694f8ba1d3 Add comprehensive godoc documentation to all packages
- Add package-level documentation with usage examples and architecture details
- Document all public types, functions, and methods following godoc conventions
- Remove unused logger.Error type and NewError function
- Apply consistent documentation style across all packages

Packages updated:
- apitls: TLS certificate management with automatic renewal
- config: Environment-based configuration system
- config/depenv: Deployment environment handling
- ekko: Enhanced Echo web framework wrapper
- kafka: Kafka client wrapper with TLS support
- logger: Structured logging with OpenTelemetry integration
- tracing: OpenTelemetry distributed tracing setup
- types: Shared data structures for NTP Pool project
- xff/fastlyxff: Fastly CDN IP range management

All tests pass after documentation changes.
2025-06-19 23:52:03 -07:00
ask 09b52f92d7 version: add documentation and tests 2025-06-06 20:19:08 -07:00
ask 785abdec8d ulid: simplify, add function without a timestamp 2025-06-06 20:02:23 -07:00
ask ce203a4618 Add README 2025-06-06 19:56:43 -07:00
ask 3c994a7343 Add copilot/claude instructions 2025-06-06 19:50:30 -07:00
ask f69c3e9c3c ulid: add documentation and more tests 2025-06-06 19:31:28 -07:00
ask fac5b1f275 metrics: add tests and documentation 2025-06-06 19:24:30 -07:00
ask a37559b93e health: add documentation 2025-06-06 19:16:14 -07:00
ask faac09ac0c timeutil: Add documentation 2025-06-06 19:08:16 -07:00
ask 62a7605869 config: add depenv.MonitorDomain() and config.ManageURL() methods 2025-04-19 23:07:08 -07:00
ask 0996167865 modernize + gofumpt 2025-04-19 22:19:02 -07:00
ask 87344dd601 version: KongVersionCmd type 2025-04-12 00:24:19 -07:00
ask 39e6611602 build: update goreleaser 2025-04-12 00:23:33 -07:00
ask 355d246010 depenv: implement UnmarshalText 2025-04-12 00:22:57 -07:00
ask e5836a8b97 depenv: ntppool configuration for deployment environments 2025-01-26 11:08:44 -08:00
ask f6d160a7f8 health: fix shutdown of health check server 2025-01-03 14:01:52 +01:00
ask 9e2d6fb74e Update dependencies 2024-12-27 18:39:48 -08:00
ask 0df1154bb5 Update goreleaser to 2.5.0 2024-12-21 08:55:17 -08:00
ask b926a85737 ekko: gzip config option 2024-12-01 16:45:49 -08:00
ask 68bd4d8904 ekko: configurable read write and readheader timeouts 2024-11-26 01:04:34 -08:00
ask 152be9d956 logger: otlp support 2024-11-09 10:59:11 +00:00
ask ab94adb925 tracing: setup log provider 2024-11-09 10:19:16 +00:00
ask ddb56b3566 ekko: Add WithLogFilters option 2024-10-12 11:39:16 -07:00
ask 4367ef9c29 Add Fatalf to standard logger-ish 2024-10-12 11:11:50 -07:00
ask d6a77f4003 ekko: add gzip, move recover middleware to run early 2024-09-21 00:53:10 -07:00
ask 3f3fb29bc9 ekko: helper to setup labstack echo with logging, tracing, etc 2024-09-20 21:47:10 -07:00
ask 8e898d9c59 tracing: refactor code, support more exporters with default environment configuration 2024-09-14 00:47:07 -07:00
ask 1ecd5684e6 version: Add CheckVersion() function 2024-08-18 18:11:17 -07:00
ask 59580b50ba scripts: update goreleaser 2024-07-07 13:05:06 -07:00
ask 9a86b2aaf5 tracing: semconv v1.26.0 2024-07-06 13:04:48 -07:00
ask bcf7232154 Update dependencies + otel schema 1.25 2024-06-08 00:14:42 -07:00
ask 9934dc8e36 Update Go, slog-otel, prometheus client 2024-04-06 09:42:41 -07:00
ask a458dcb226 tracing: add EndpointURL option 2024-03-16 10:40:43 -07:00
ask 4ed44c72a4 Update dependencies 2024-03-09 21:57:46 -08:00
ask 8a8ff93996 scripts: goreleaser 1.24.0 2024-02-10 19:10:01 -08:00
ask 1e8785bd32 version: fix metric name for services with dash in the name 2024-02-03 00:21:31 -08:00
ask 5aeaa97c6f Add BSD license
(for pkg.go.dev)
2024-01-20 11:48:32 -07:00
ask df2285d355 tracing: update semconv, better error checking 2024-01-19 22:59:29 -08:00
ask 232a6f98df tracing: add minimal test 2024-01-19 22:48:14 -08:00
ask 4f6b09200f Update dependencies 2024-01-12 23:12:15 -08:00
ask 7085202154 Update goreleaser 2024-01-12 22:17:07 -08:00
ask 5c7ae6ab8a Basic config package to parse NTP Pool system config 2023-12-10 20:43:38 -08:00
ask 608f05d395 types: shared data types 2023-12-10 19:16:13 -08:00
ask b5420f9dbd build: private repository support for drone / goreleaser 2023-12-10 19:15:49 -08:00
ask 537ee53384 Minor dependency updates 2023-11-26 01:15:04 -08:00
ask 0a92ad768e tracing: option to set endpoint without environment variables 2023-11-15 22:29:20 +08:00
ask 61d73f7be3 Update dependencies 2023-11-15 22:28:41 +08:00
ask 2bff6d8ef3 X-Forwarded-For handler for labstack echo and Fastly 2023-11-12 15:51:21 -08:00
ask 62e28b71f1 tracing: option to use a GetClientCertificates function 2023-10-29 18:18:41 -07:00
ask 5b033a1f0b logging: use remychantenay/slog-otel 2023-10-21 22:09:48 -07:00
ask a4447c97f6 tracing: support for shutting down the trace provider 2023-10-21 21:59:10 -07:00
ask 9d136b2502 logger: Add experimental support for adding trace_id from context 2023-10-21 21:51:29 -07:00
ask 7420ad12f4 Update dependencies 2023-10-21 21:49:51 -07:00
ask cf33a99566 tracing: tweak API 2023-10-14 04:20:29 -07:00
ask c2b303bec9 goreleaser: --skip-publish is now --skip=publish 2023-10-14 04:10:33 -07:00
ask 6fd0728668 Update kafka-go 2023-10-14 03:31:30 -07:00
ask 09f963b267 tracing: wip / test 2023-10-14 03:30:19 -07:00
ask ad63071f60 Update dependencies and goreleaser; require Go 1.21.3 for h2 fix 2023-10-11 22:03:38 -07:00
ask 020966a4b3 Go 1.21; use log/slog instead of version from x/exp 2023-09-17 23:03:55 -07:00
ask 053de4fd16 scripts: manage goreleaser version in script 2023-09-17 23:02:48 -07:00
ask 3f1f4436df metrics: have Registry() return a Registry instead of Registerer
(so it can also be used as a Gatherer)
2023-08-06 12:34:56 -07:00
ask be9b63f382 health: support custom health check functions 2023-07-22 23:48:04 -07:00
ask e9d0f7419a kafka: CheckPartitions() method for health checks 2023-07-22 23:47:37 -07:00
ask 2a021b453d timeutil: time.Duration json helper 2023-07-22 00:10:55 -07:00
ask 03bde25c6d health: make health listener semantics match metrics one 2023-07-08 21:18:38 -07:00
ask 6b6b22092e metrics: allow server to return errors 2023-07-08 21:13:31 -07:00
ask facd2f4f57 Common release scripts 2023-07-08 17:39:36 -07:00
ask 5c067e3752 version: Prefix build_info metric name 2023-07-08 15:56:57 -07:00
ask 7550d1597c version: add more data to prometheus metric 2023-07-08 15:04:43 -07:00
ask cca1240a65 version: change prom metric to have separate label with build time 2023-07-08 13:09:37 -07:00
ask 7ad495fe2b kafka: switch to lz4 compression; disable default logger on writer 2023-07-08 13:08:52 -07:00
ask 3ba8ba4a22 Add ulid package 2023-07-08 12:49:14 -07:00
ask ebd0695862 Add version package 2023-07-08 12:32:49 -07:00
ask a1e600e8ae metricsserver: add helper for exporting prom metrics
(also from the monitor code)
2023-07-08 11:45:01 -07:00
ask ab579128b9 health: basic health checker from the monitor 2023-07-02 23:49:05 -07:00