mirror of
				https://github.com/elyby/chrly.git
				synced 2025-05-31 14:11:51 +05:30 
			
		
		
		
	Add autoconfiguration for OTEL and resolve TODOs for metrics
This commit is contained in:
		
							
								
								
									
										32
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								go.mod
									
									
									
									
									
								
							| @@ -19,16 +19,13 @@ require ( | |||||||
| 	github.com/spf13/cobra v1.8.0 | 	github.com/spf13/cobra v1.8.0 | ||||||
| 	github.com/spf13/viper v1.18.1 | 	github.com/spf13/viper v1.18.1 | ||||||
| 	github.com/valyala/fastjson v1.6.4 | 	github.com/valyala/fastjson v1.6.4 | ||||||
|  | 	go.opentelemetry.io/contrib/exporters/autoexport v0.49.0 | ||||||
| 	go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.48.0 | 	go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.48.0 | ||||||
| 	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0 |  | ||||||
| 	go.opentelemetry.io/contrib/instrumentation/runtime v0.48.0 | 	go.opentelemetry.io/contrib/instrumentation/runtime v0.48.0 | ||||||
| 	go.opentelemetry.io/otel v1.23.1 | 	go.opentelemetry.io/otel v1.24.0 | ||||||
| 	go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.23.1 | 	go.opentelemetry.io/otel/metric v1.24.0 | ||||||
| 	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.23.1 | 	go.opentelemetry.io/otel/sdk v1.24.0 | ||||||
| 	go.opentelemetry.io/otel/metric v1.23.1 | 	go.opentelemetry.io/otel/sdk/metric v1.24.0 | ||||||
| 	go.opentelemetry.io/otel/sdk v1.23.1 |  | ||||||
| 	go.opentelemetry.io/otel/sdk/metric v1.23.1 |  | ||||||
| 	go.opentelemetry.io/otel/trace v1.23.1 |  | ||||||
| 	go.uber.org/multierr v1.11.0 | 	go.uber.org/multierr v1.11.0 | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -40,8 +37,10 @@ require ( | |||||||
|  |  | ||||||
| // Indirect dependencies | // Indirect dependencies | ||||||
| require ( | require ( | ||||||
|  | 	github.com/beorn7/perks v1.0.1 // indirect | ||||||
| 	github.com/cenkalti/backoff/v4 v4.2.1 // indirect | 	github.com/cenkalti/backoff/v4 v4.2.1 // indirect | ||||||
| 	github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect | 	github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect | ||||||
|  | 	github.com/cespare/xxhash/v2 v2.2.0 // indirect | ||||||
| 	github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | 	github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||||||
| 	github.com/felixge/httpsnoop v1.0.4 // indirect | 	github.com/felixge/httpsnoop v1.0.4 // indirect | ||||||
| 	github.com/fsnotify/fsnotify v1.7.0 // indirect | 	github.com/fsnotify/fsnotify v1.7.0 // indirect | ||||||
| @@ -57,9 +56,14 @@ require ( | |||||||
| 	github.com/inconshreveable/mousetrap v1.1.0 // indirect | 	github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||||||
| 	github.com/leodido/go-urn v1.2.4 // indirect | 	github.com/leodido/go-urn v1.2.4 // indirect | ||||||
| 	github.com/magiconair/properties v1.8.7 // indirect | 	github.com/magiconair/properties v1.8.7 // indirect | ||||||
|  | 	github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect | ||||||
| 	github.com/mitchellh/mapstructure v1.5.0 // indirect | 	github.com/mitchellh/mapstructure v1.5.0 // indirect | ||||||
| 	github.com/pelletier/go-toml/v2 v2.1.1 // indirect | 	github.com/pelletier/go-toml/v2 v2.1.1 // indirect | ||||||
| 	github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | 	github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | ||||||
|  | 	github.com/prometheus/client_golang v1.18.0 // indirect | ||||||
|  | 	github.com/prometheus/client_model v0.6.0 // indirect | ||||||
|  | 	github.com/prometheus/common v0.45.0 // indirect | ||||||
|  | 	github.com/prometheus/procfs v0.12.0 // indirect | ||||||
| 	github.com/sagikazarmark/locafero v0.4.0 // indirect | 	github.com/sagikazarmark/locafero v0.4.0 // indirect | ||||||
| 	github.com/sagikazarmark/slog-shim v0.1.0 // indirect | 	github.com/sagikazarmark/slog-shim v0.1.0 // indirect | ||||||
| 	github.com/sourcegraph/conc v0.3.0 // indirect | 	github.com/sourcegraph/conc v0.3.0 // indirect | ||||||
| @@ -69,7 +73,15 @@ require ( | |||||||
| 	github.com/stretchr/objx v0.5.0 // indirect | 	github.com/stretchr/objx v0.5.0 // indirect | ||||||
| 	github.com/subosito/gotenv v1.6.0 // indirect | 	github.com/subosito/gotenv v1.6.0 // indirect | ||||||
| 	github.com/tilinna/clock v1.0.2 // indirect | 	github.com/tilinna/clock v1.0.2 // indirect | ||||||
| 	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.23.1 // indirect | 	go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.24.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.24.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/exporters/prometheus v0.46.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.24.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/trace v1.24.0 // indirect | ||||||
| 	go.opentelemetry.io/proto/otlp v1.1.0 // indirect | 	go.opentelemetry.io/proto/otlp v1.1.0 // indirect | ||||||
| 	golang.org/x/crypto v0.19.0 // indirect | 	golang.org/x/crypto v0.19.0 // indirect | ||||||
| 	golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect | 	golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect | ||||||
| @@ -79,7 +91,7 @@ require ( | |||||||
| 	golang.org/x/text v0.14.0 // indirect | 	golang.org/x/text v0.14.0 // indirect | ||||||
| 	google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect | 	google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect | ||||||
| 	google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect | 	google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect | ||||||
| 	google.golang.org/grpc v1.61.0 // indirect | 	google.golang.org/grpc v1.61.1 // indirect | ||||||
| 	google.golang.org/protobuf v1.32.0 // indirect | 	google.golang.org/protobuf v1.32.0 // indirect | ||||||
| 	gopkg.in/ini.v1 v1.67.0 // indirect | 	gopkg.in/ini.v1 v1.67.0 // indirect | ||||||
| 	gopkg.in/yaml.v3 v3.0.1 // indirect | 	gopkg.in/yaml.v3 v3.0.1 // indirect | ||||||
|   | |||||||
							
								
								
									
										68
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										68
									
								
								go.sum
									
									
									
									
									
								
							| @@ -2,12 +2,16 @@ github.com/agoda-com/opentelemetry-go/otelslog v0.1.1 h1:6nV8PZCzySHuh9kP/HZ2OJq | |||||||
| github.com/agoda-com/opentelemetry-go/otelslog v0.1.1/go.mod h1:CSc0veIcY/HsIfH7l5PGtIpRvBttk09QUQlweVkD2PI= | github.com/agoda-com/opentelemetry-go/otelslog v0.1.1/go.mod h1:CSc0veIcY/HsIfH7l5PGtIpRvBttk09QUQlweVkD2PI= | ||||||
| github.com/agoda-com/opentelemetry-logs-go v0.4.3 h1:dYAx/q9di+/Pv6HuGq59DFIOjqKT0LTy3PYTIz8ccq8= | github.com/agoda-com/opentelemetry-logs-go v0.4.3 h1:dYAx/q9di+/Pv6HuGq59DFIOjqKT0LTy3PYTIz8ccq8= | ||||||
| github.com/agoda-com/opentelemetry-logs-go v0.4.3/go.mod h1:gPQ0fHqroxNP2DlQFZt29/pfqGiP2m6Q5CCxEgLo6yQ= | github.com/agoda-com/opentelemetry-logs-go v0.4.3/go.mod h1:gPQ0fHqroxNP2DlQFZt29/pfqGiP2m6Q5CCxEgLo6yQ= | ||||||
|  | github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= | ||||||
|  | github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= | ||||||
| github.com/brunomvsouza/singleflight v0.4.0 h1:9dNcTeYoXSus3xbZEM0EEZ11EcCRjUZOvVW8rnDMG5Y= | github.com/brunomvsouza/singleflight v0.4.0 h1:9dNcTeYoXSus3xbZEM0EEZ11EcCRjUZOvVW8rnDMG5Y= | ||||||
| github.com/brunomvsouza/singleflight v0.4.0/go.mod h1:8RYo9j5WQRupmsnUz5DlUWZxDLNi+t9Zhj3EZFmns7I= | github.com/brunomvsouza/singleflight v0.4.0/go.mod h1:8RYo9j5WQRupmsnUz5DlUWZxDLNi+t9Zhj3EZFmns7I= | ||||||
| github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= | github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= | ||||||
| github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= | github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= | ||||||
| github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d h1:S2NE3iHSwP0XV47EEXL8mWmRdEfGscSJ+7EgePNgt0s= | github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d h1:S2NE3iHSwP0XV47EEXL8mWmRdEfGscSJ+7EgePNgt0s= | ||||||
| github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= | github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= | ||||||
|  | github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= | ||||||
|  | github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= | ||||||
| github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | ||||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||||
| @@ -70,6 +74,8 @@ github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= | |||||||
| github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= | github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= | ||||||
| github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= | github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= | ||||||
| github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= | github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= | ||||||
|  | github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= | ||||||
|  | github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= | ||||||
| github.com/mediocregopher/radix/v4 v4.1.4 h1:Uze6DEbEAvL+VHXUEu/EDBTkUk5CLct5h3nVSGpc6Ts= | github.com/mediocregopher/radix/v4 v4.1.4 h1:Uze6DEbEAvL+VHXUEu/EDBTkUk5CLct5h3nVSGpc6Ts= | ||||||
| github.com/mediocregopher/radix/v4 v4.1.4/go.mod h1:ajchozX/6ELmydxWeWM6xCFHVpZ4+67LXHOTOVR0nCE= | github.com/mediocregopher/radix/v4 v4.1.4/go.mod h1:ajchozX/6ELmydxWeWM6xCFHVpZ4+67LXHOTOVR0nCE= | ||||||
| github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= | github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= | ||||||
| @@ -83,6 +89,14 @@ github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdU | |||||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||||
| github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= | ||||||
| github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||||
|  | github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= | ||||||
|  | github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= | ||||||
|  | github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= | ||||||
|  | github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= | ||||||
|  | github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= | ||||||
|  | github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= | ||||||
|  | github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= | ||||||
|  | github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= | ||||||
| github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= | github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= | ||||||
| github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= | github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= | ||||||
| github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||||||
| @@ -118,32 +132,42 @@ github.com/tilinna/clock v1.0.2 h1:6BO2tyAC9JbPExKH/z9zl44FLu1lImh3nDNKA0kgrkI= | |||||||
| github.com/tilinna/clock v1.0.2/go.mod h1:ZsP7BcY7sEEz7ktc0IVy8Us6boDrK8VradlKRUGfOao= | github.com/tilinna/clock v1.0.2/go.mod h1:ZsP7BcY7sEEz7ktc0IVy8Us6boDrK8VradlKRUGfOao= | ||||||
| github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= | github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= | ||||||
| github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= | github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= | ||||||
|  | go.opentelemetry.io/contrib/exporters/autoexport v0.49.0 h1:SPuRs5SgCd9loXBBY5HuZsyuweowIs6ADg9UtStEv+k= | ||||||
|  | go.opentelemetry.io/contrib/exporters/autoexport v0.49.0/go.mod h1:BDsrww+PTgwfvBjsZQMstsE1n5dS3hDCtAfYG1t3wag= | ||||||
| go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.48.0 h1:7rkdNoXgScpSUIqBch/VOB24fk9g0wl3Tr5WPtshi9o= | go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.48.0 h1:7rkdNoXgScpSUIqBch/VOB24fk9g0wl3Tr5WPtshi9o= | ||||||
| go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.48.0/go.mod h1:U3t9uswWhDzieXHMNWP6zk87J4HNondiibKMdNLpnMk= | go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.48.0/go.mod h1:U3t9uswWhDzieXHMNWP6zk87J4HNondiibKMdNLpnMk= | ||||||
| go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0 h1:doUP+ExOpH3spVTLS0FcWGLnQrPct/hD/bCPbDRUEAU= |  | ||||||
| go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0/go.mod h1:rdENBZMT2OE6Ne/KLwpiXudnAsbdrdBaqBvTN8M8BgA= |  | ||||||
| go.opentelemetry.io/contrib/instrumentation/runtime v0.48.0 h1:dJlCKeq+zmO5Og4kgxqPvvJrzuD/mygs1g/NYM9dAsU= | go.opentelemetry.io/contrib/instrumentation/runtime v0.48.0 h1:dJlCKeq+zmO5Og4kgxqPvvJrzuD/mygs1g/NYM9dAsU= | ||||||
| go.opentelemetry.io/contrib/instrumentation/runtime v0.48.0/go.mod h1:p+hpBCpLHpuUrR0lHgnHbUnbCBll1IhrcMIlycC+xYs= | go.opentelemetry.io/contrib/instrumentation/runtime v0.48.0/go.mod h1:p+hpBCpLHpuUrR0lHgnHbUnbCBll1IhrcMIlycC+xYs= | ||||||
| go.opentelemetry.io/otel v1.23.1 h1:Za4UzOqJYS+MUczKI320AtqZHZb7EqxO00jAHE0jmQY= | go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= | ||||||
| go.opentelemetry.io/otel v1.23.1/go.mod h1:Td0134eafDLcTS4y+zQ26GE8u3dEuRBiBCTUIRHaikA= | go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= | ||||||
| go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.23.1 h1:q/Nj5/2TZRIt6PderQ9oU0M00fzoe8UZuINGw6ETGTw= | go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.24.0 h1:f2jriWfOdldanBwS9jNBdeOKAQN7b4ugAMaNu1/1k9g= | ||||||
| go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.23.1/go.mod h1:DTE9yAu6r08jU3xa68GiSeI7oRcSEQ2RpKbbQGO+dWM= | go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.24.0/go.mod h1:B+bcQI1yTY+N0vqMpoZbEN7+XU4tNM0DmUiOwebFJWI= | ||||||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.23.1 h1:o8iWeVFa1BcLtVEV0LzrCxV2/55tB3xLxADr6Kyoey4= | go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.24.0 h1:mM8nKi6/iFQ0iqst80wDHU2ge198Ye/TfN0WBS5U24Y= | ||||||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.23.1/go.mod h1:SEVfdK4IoBnbT2FXNM/k8yC08MrfbhWk3U4ljM8B3HE= | go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.24.0/go.mod h1:0PrIIzDteLSmNyxqcGYRL4mDIo8OTuBAOI/Bn1URxac= | ||||||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.23.1 h1:cfuy3bXmLJS7M1RZmAL6SuhGtKUp2KEsrm00OlAXkq4= | go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8= | ||||||
| go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.23.1/go.mod h1:22jr92C6KwlwItJmQzfixzQM3oyyuYLCfHiMY+rpsPU= | go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0/go.mod h1:iSDOcsnSA5INXzZtwaBPrKp/lWu/V14Dd+llD0oI2EA= | ||||||
| go.opentelemetry.io/otel/metric v1.23.1 h1:PQJmqJ9u2QaJLBOELl1cxIdPcpbwzbkjfEyelTl2rlo= | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 h1:Mw5xcxMwlqoJd97vwPxA8isEaIoxsta9/Q51+TTJLGE= | ||||||
| go.opentelemetry.io/otel/metric v1.23.1/go.mod h1:mpG2QPlAfnK8yNhNJAxDZruU9Y1/HubbC+KyH8FaCWI= | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0/go.mod h1:CQNu9bj7o7mC6U7+CA/schKEYakYXWr79ucDHTMGhCM= | ||||||
| go.opentelemetry.io/otel/sdk v1.23.1 h1:O7JmZw0h76if63LQdsBMKQDWNb5oEcOThG9IrxscV+E= | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs= | ||||||
| go.opentelemetry.io/otel/sdk v1.23.1/go.mod h1:LzdEVR5am1uKOOwfBWFef2DCi1nu3SA8XQxx2IerWFk= | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM= | ||||||
| go.opentelemetry.io/otel/sdk/metric v1.23.1 h1:T9/8WsYg+ZqIpMWwdISVVrlGb/N0Jr1OHjR/alpKwzg= | go.opentelemetry.io/otel/exporters/prometheus v0.46.0 h1:I8WIFXR351FoLJYuloU4EgXbtNX2URfU/85pUPheIEQ= | ||||||
| go.opentelemetry.io/otel/sdk/metric v1.23.1/go.mod h1:8WX6WnNtHCgUruJ4TJ+UssQjMtpxkpX0zveQC8JG/E0= | go.opentelemetry.io/otel/exporters/prometheus v0.46.0/go.mod h1:ztwVUHe5DTR/1v7PeuGRnU5Bbd4QKYwApWmuutKsJSs= | ||||||
| go.opentelemetry.io/otel/trace v1.23.1 h1:4LrmmEd8AU2rFvU1zegmvqW7+kWarxtNOPyeL6HmYY8= | go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.24.0 h1:JYE2HM7pZbOt5Jhk8ndWZTUWYOVift2cHjXVMkPdmdc= | ||||||
| go.opentelemetry.io/otel/trace v1.23.1/go.mod h1:4IpnpJFwr1mo/6HL8XIPJaE9y0+u1KcVmuW7dwFSVrI= | go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.24.0/go.mod h1:yMb/8c6hVsnma0RpsBMNo0fEiQKeclawtgaIaOp2MLY= | ||||||
|  | go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 h1:s0PHtIkN+3xrbDOpt2M8OTG92cWqUESvzh2MxiR5xY8= | ||||||
|  | go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0/go.mod h1:hZlFbDbRt++MMPCCfSJfmhkGIWnX1h3XjkfxZUjLrIA= | ||||||
|  | go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= | ||||||
|  | go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= | ||||||
|  | go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= | ||||||
|  | go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= | ||||||
|  | go.opentelemetry.io/otel/sdk/metric v1.24.0 h1:yyMQrPzF+k88/DbH7o4FMAs80puqd+9osbiBrJrz/w8= | ||||||
|  | go.opentelemetry.io/otel/sdk/metric v1.24.0/go.mod h1:I6Y5FjH6rvEnTTAYQz3Mmv2kl6Ek5IIrmwTLqMrrOE0= | ||||||
|  | go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= | ||||||
|  | go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= | ||||||
| go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= | go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= | ||||||
| go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= | go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= | ||||||
| go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= | go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= | ||||||
| go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= | go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= | ||||||
| go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= | go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= | ||||||
| go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= | go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= | ||||||
| golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= | golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= | ||||||
| @@ -165,8 +189,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 h1: | |||||||
| google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014/go.mod h1:rbHMSEDyoYX62nRVLOCc4Qt1HbsdytAYoVwgjiOhF3I= | google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014/go.mod h1:rbHMSEDyoYX62nRVLOCc4Qt1HbsdytAYoVwgjiOhF3I= | ||||||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 h1:FSL3lRCkhaPFxqi0s9o+V4UI2WTzAVOvkgbd4kVV4Wg= | google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 h1:FSL3lRCkhaPFxqi0s9o+V4UI2WTzAVOvkgbd4kVV4Wg= | ||||||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014/go.mod h1:SaPjaZGWb0lPqs6Ittu0spdfrOArqji4ZdeP5IC/9N4= | google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014/go.mod h1:SaPjaZGWb0lPqs6Ittu0spdfrOArqji4ZdeP5IC/9N4= | ||||||
| google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= | google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY= | ||||||
| google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= | google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= | ||||||
| google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= | google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= | ||||||
| google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= | google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= | ||||||
| google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= | google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= | ||||||
|   | |||||||
| @@ -33,23 +33,25 @@ func startServer(modules ...string) error { | |||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	shutdownOtel, err := otel.SetupOTelSDK(globalCtx) |  | ||||||
| 	defer func() { |  | ||||||
| 		err := shutdownOtel(context.Background()) |  | ||||||
| 		if err != nil { |  | ||||||
| 			slog.Error("Unable to shutdown OpenTelemetry", slog.Any("error", err)) |  | ||||||
| 		} |  | ||||||
| 	}() |  | ||||||
| 	if err != nil { |  | ||||||
| 		return err |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	var config *viper.Viper | 	var config *viper.Viper | ||||||
| 	err = container.Resolve(&config) | 	err = container.Resolve(&config) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if !config.GetBool("otel.sdk.disabled") { | ||||||
|  | 		shutdownOtel, err := otel.SetupOTelSDK(globalCtx) | ||||||
|  | 		defer func() { | ||||||
|  | 			err := shutdownOtel(context.Background()) | ||||||
|  | 			if err != nil { | ||||||
|  | 				slog.Error("Unable to shutdown OpenTelemetry", slog.Any("error", err)) | ||||||
|  | 			} | ||||||
|  | 		}() | ||||||
|  | 		if err != nil { | ||||||
|  | 			return err | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	config.Set("modules", modules) | 	config.Set("modules", modules) | ||||||
|  |  | ||||||
| 	err = container.Invoke(http.StartServer) | 	err = container.Invoke(http.StartServer) | ||||||
|   | |||||||
| @@ -4,7 +4,6 @@ import ( | |||||||
| 	"net/http" | 	"net/http" | ||||||
|  |  | ||||||
| 	"github.com/defval/di" | 	"github.com/defval/di" | ||||||
| 	"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| var httpClientDiOptions = di.Options( | var httpClientDiOptions = di.Options( | ||||||
| @@ -12,7 +11,5 @@ var httpClientDiOptions = di.Options( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| func newHttpClient() *http.Client { | func newHttpClient() *http.Client { | ||||||
| 	return &http.Client{ | 	return &http.Client{} | ||||||
| 		Transport: otelhttp.NewTransport(http.DefaultTransport), |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -82,8 +82,6 @@ func newMojangTexturesBatchUUIDsProvider( | |||||||
| 	config.SetDefault("queue.batch_size", 10) | 	config.SetDefault("queue.batch_size", 10) | ||||||
| 	config.SetDefault("queue.strategy", "periodic") | 	config.SetDefault("queue.strategy", "periodic") | ||||||
|  |  | ||||||
| 	// TODO: healthcheck is broken |  | ||||||
|  |  | ||||||
| 	return mojang.NewBatchUuidsProvider( | 	return mojang.NewBatchUuidsProvider( | ||||||
| 		mojangApi.UsernamesToUuids, | 		mojangApi.UsernamesToUuids, | ||||||
| 		config.GetInt("queue.batch_size"), | 		config.GetInt("queue.batch_size"), | ||||||
|   | |||||||
| @@ -111,7 +111,7 @@ func (p *BatchUuidsProvider) fireRequest() { | |||||||
| 	for { | 	for { | ||||||
| 		foundJobs, left := p.queue.Dequeue(n) | 		foundJobs, left := p.queue.Dequeue(n) | ||||||
| 		for i := range foundJobs { | 		for i := range foundJobs { | ||||||
| 			p.metrics.QueueTime.Record(reqCtx, float64(time.Since(foundJobs[i].QueuingTime))) | 			p.metrics.QueueTime.Record(reqCtx, float64(time.Since(foundJobs[i].QueuingTime).Milliseconds())) | ||||||
| 			if foundJobs[i].Ctx.Err() != nil { | 			if foundJobs[i].Ctx.Err() != nil { | ||||||
| 				// If the job context has already ended, its result will be returned in the GetUuid method | 				// If the job context has already ended, its result will be returned in the GetUuid method | ||||||
| 				close(foundJobs[i].ResultChan) | 				close(foundJobs[i].ResultChan) | ||||||
| @@ -139,6 +139,7 @@ func (p *BatchUuidsProvider) fireRequest() { | |||||||
| 		usernames[i] = job.Username | 		usernames[i] = job.Username | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	p.metrics.Requests.Add(reqCtx, 1) | ||||||
| 	p.metrics.BatchSize.Record(reqCtx, int64(len(usernames))) | 	p.metrics.BatchSize.Record(reqCtx, int64(len(usernames))) | ||||||
|  |  | ||||||
| 	profiles, err := p.UsernamesToUuidsEndpoint(reqCtx, usernames) | 	profiles, err := p.UsernamesToUuidsEndpoint(reqCtx, usernames) | ||||||
| @@ -165,9 +166,23 @@ func newBatchUuidsProviderMetrics(meter metric.Meter, queue *utils.Queue[*job]) | |||||||
| 	m := &batchUuidsProviderMetrics{} | 	m := &batchUuidsProviderMetrics{} | ||||||
| 	var errors, err error | 	var errors, err error | ||||||
|  |  | ||||||
|  | 	m.Requests, err = meter.Int64Counter( | ||||||
|  | 		"uuids.batch.request.sent", | ||||||
|  | 		metric.WithDescription("Number of UUIDs requests sent to Mojang API"), | ||||||
|  | 		metric.WithUnit("1"), | ||||||
|  | 	) | ||||||
|  | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
|  | 	m.BatchSize, err = meter.Int64Histogram( | ||||||
|  | 		"uuids.batch.request.batch_size", | ||||||
|  | 		metric.WithDescription("The number of usernames in the query"), | ||||||
|  | 		metric.WithUnit("1"), | ||||||
|  | 	) | ||||||
|  | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
| 	m.QueueLength, err = meter.Int64ObservableGauge( | 	m.QueueLength, err = meter.Int64ObservableGauge( | ||||||
| 		"queue.length",             // TODO: look for better naming | 		"uuids.batch.queue.length", | ||||||
| 		metric.WithDescription(""), // TODO: description | 		metric.WithDescription("Number of tasks in the queue waiting for execution"), | ||||||
| 		metric.WithInt64Callback(func(_ context.Context, o metric.Int64Observer) error { | 		metric.WithInt64Callback(func(_ context.Context, o metric.Int64Observer) error { | ||||||
| 			o.Observe(int64(queue.Len())) | 			o.Observe(int64(queue.Len())) | ||||||
| 			return nil | 			return nil | ||||||
| @@ -176,23 +191,18 @@ func newBatchUuidsProviderMetrics(meter metric.Meter, queue *utils.Queue[*job]) | |||||||
| 	errors = multierr.Append(errors, err) | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
| 	m.QueueTime, err = meter.Float64Histogram( | 	m.QueueTime, err = meter.Float64Histogram( | ||||||
| 		"queue.duration", | 		"uuids.batch.queue.lag", | ||||||
| 		metric.WithDescription(""), // TODO: description | 		metric.WithDescription("Lag between placing a job in the queue and starting its processing"), | ||||||
| 		metric.WithUnit("ms"), | 		metric.WithUnit("ms"), | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
| 	m.BatchSize, err = meter.Int64Histogram( |  | ||||||
| 		"batch.size", |  | ||||||
| 		metric.WithDescription(""), // TODO: write description |  | ||||||
| 		metric.WithUnit("1"), |  | ||||||
| 	) |  | ||||||
| 	errors = multierr.Append(errors, err) | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
| 	return m, errors | 	return m, errors | ||||||
| } | } | ||||||
|  |  | ||||||
| type batchUuidsProviderMetrics struct { | type batchUuidsProviderMetrics struct { | ||||||
|  | 	Requests    metric.Int64Counter | ||||||
|  | 	BatchSize   metric.Int64Histogram | ||||||
| 	QueueLength metric.Int64ObservableGauge | 	QueueLength metric.Int64ObservableGauge | ||||||
| 	QueueTime   metric.Float64Histogram | 	QueueTime   metric.Float64Histogram | ||||||
| 	BatchSize   metric.Int64Histogram |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -77,7 +77,6 @@ func (c *MojangApi) UsernamesToUuids(ctx context.Context, usernames []string) ([ | |||||||
| // Obtains textures information for provided uuid | // Obtains textures information for provided uuid | ||||||
| // See https://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape | // See https://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape | ||||||
| func (c *MojangApi) UuidToTextures(ctx context.Context, uuid string, signed bool) (*ProfileResponse, error) { | func (c *MojangApi) UuidToTextures(ctx context.Context, uuid string, signed bool) (*ProfileResponse, error) { | ||||||
| 	// TODO: normalize request url for tracing |  | ||||||
| 	normalizedUuid := strings.ReplaceAll(uuid, "-", "") | 	normalizedUuid := strings.ReplaceAll(uuid, "-", "") | ||||||
| 	url := c.profileUrl + normalizedUuid | 	url := c.profileUrl + normalizedUuid | ||||||
| 	if signed { | 	if signed { | ||||||
|   | |||||||
| @@ -59,7 +59,13 @@ func (p *MojangTexturesProvider) GetForUsername(ctx context.Context, username st | |||||||
| 	username = strings.ToLower(username) | 	username = strings.ToLower(username) | ||||||
|  |  | ||||||
| 	result, err, shared := p.group.Do(username, func() (*ProfileResponse, error) { | 	result, err, shared := p.group.Do(username, func() (*ProfileResponse, error) { | ||||||
| 		profile, err := p.UuidsProvider.GetUuid(ctx, username) | 		var profile *ProfileInfo | ||||||
|  | 		var textures *ProfileResponse | ||||||
|  | 		var err error | ||||||
|  |  | ||||||
|  | 		defer p.recordMetrics(ctx, profile, textures, err) | ||||||
|  |  | ||||||
|  | 		profile, err = p.UuidsProvider.GetUuid(ctx, username) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, err | 			return nil, err | ||||||
| 		} | 		} | ||||||
| @@ -68,28 +74,36 @@ func (p *MojangTexturesProvider) GetForUsername(ctx context.Context, username st | |||||||
| 			return nil, nil | 			return nil, nil | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		return p.TexturesProvider.GetTextures(ctx, profile.Id) | 		textures, err = p.TexturesProvider.GetTextures(ctx, profile.Id) | ||||||
|  |  | ||||||
|  | 		return textures, err | ||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
| 	p.recordMetrics(ctx, shared, result, err) |  | ||||||
|  |  | ||||||
| 	return result, err |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (p *MojangTexturesProvider) recordMetrics(ctx context.Context, shared bool, result *ProfileResponse, err error) { |  | ||||||
| 	if shared { | 	if shared { | ||||||
| 		p.metrics.Shared.Add(ctx, 1) | 		p.metrics.Shared.Add(ctx, 1) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	return result, err | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (p *MojangTexturesProvider) recordMetrics(ctx context.Context, profile *ProfileInfo, textures *ProfileResponse, err error) { | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		p.metrics.Failed.Add(ctx, 1) | 		p.metrics.Failed.Add(ctx, 1) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if result != nil { | 	if profile == nil { | ||||||
| 		p.metrics.Found.Add(ctx, 1) | 		p.metrics.UsernameMissed.Add(ctx, 1) | ||||||
|  | 		p.metrics.TextureMissed.Add(ctx, 1) | ||||||
|  |  | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	p.metrics.UsernameFound.Add(ctx, 1) | ||||||
|  | 	if textures != nil { | ||||||
|  | 		p.metrics.TextureFound.Add(ctx, 1) | ||||||
| 	} else { | 	} else { | ||||||
| 		p.metrics.Missed.Add(ctx, 1) | 		p.metrics.TextureMissed.Add(ctx, 1) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -104,27 +118,45 @@ func newProviderMetrics(meter metric.Meter) (*providerMetrics, error) { | |||||||
| 	m := &providerMetrics{} | 	m := &providerMetrics{} | ||||||
| 	var errors, err error | 	var errors, err error | ||||||
|  |  | ||||||
| 	m.Found, err = meter.Int64Counter( | 	m.UsernameFound, err = meter.Int64Counter( | ||||||
| 		"results.found", | 		"provider.username_found", | ||||||
| 		metric.WithDescription(""), // TODO: description | 		metric.WithDescription("Number of queries for which username was found"), | ||||||
|  | 		metric.WithUnit("1"), | ||||||
| 	) | 	) | ||||||
| 	errors = multierr.Append(errors, err) | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
| 	m.Missed, err = meter.Int64Counter( | 	m.UsernameMissed, err = meter.Int64Counter( | ||||||
| 		"results.missed", | 		"provider.username_missed", | ||||||
| 		metric.WithDescription(""), // TODO: description | 		metric.WithDescription("Number of queries for which username was not found"), | ||||||
|  | 		metric.WithUnit("1"), | ||||||
|  | 	) | ||||||
|  | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
|  | 	m.TextureFound, err = meter.Int64Counter( | ||||||
|  | 		"provider.textures_found", | ||||||
|  | 		metric.WithDescription("Number of queries for which textures were successfully found"), | ||||||
|  | 		metric.WithUnit("1"), | ||||||
|  | 	) | ||||||
|  | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
|  | 	m.TextureMissed, err = meter.Int64Counter( | ||||||
|  | 		"provider.textures_missed", | ||||||
|  | 		metric.WithDescription("Number of queries for which no textures were found"), | ||||||
|  | 		metric.WithUnit("1"), | ||||||
| 	) | 	) | ||||||
| 	errors = multierr.Append(errors, err) | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
| 	m.Failed, err = meter.Int64Counter( | 	m.Failed, err = meter.Int64Counter( | ||||||
| 		"results.failed", | 		"provider.failed", | ||||||
| 		metric.WithDescription(""), // TODO: description | 		metric.WithDescription("Number of requests that ended in an error"), | ||||||
|  | 		metric.WithUnit("1"), | ||||||
| 	) | 	) | ||||||
| 	errors = multierr.Append(errors, err) | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
| 	m.Shared, err = meter.Int64Counter( | 	m.Shared, err = meter.Int64Counter( | ||||||
| 		"singleflight.shared", | 		"provider.singleflight.shared", | ||||||
| 		metric.WithDescription(""), // TODO: description | 		metric.WithDescription("Number of requests that are already being processed in another thread"), | ||||||
|  | 		metric.WithUnit("1"), | ||||||
| 	) | 	) | ||||||
| 	errors = multierr.Append(errors, err) | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
| @@ -132,8 +164,10 @@ func newProviderMetrics(meter metric.Meter) (*providerMetrics, error) { | |||||||
| } | } | ||||||
|  |  | ||||||
| type providerMetrics struct { | type providerMetrics struct { | ||||||
| 	Found  metric.Int64Counter | 	UsernameFound  metric.Int64Counter | ||||||
| 	Missed metric.Int64Counter | 	UsernameMissed metric.Int64Counter | ||||||
| 	Failed metric.Int64Counter | 	TextureFound   metric.Int64Counter | ||||||
| 	Shared metric.Int64Counter | 	TextureMissed  metric.Int64Counter | ||||||
|  | 	Failed         metric.Int64Counter | ||||||
|  | 	Shared         metric.Int64Counter | ||||||
| } | } | ||||||
|   | |||||||
| @@ -100,8 +100,8 @@ func newMojangApiTexturesProviderMetrics(meter metric.Meter) (*mojangApiTextures | |||||||
| 	var errors, err error | 	var errors, err error | ||||||
|  |  | ||||||
| 	m.Requests, err = meter.Int64Counter( | 	m.Requests, err = meter.Int64Counter( | ||||||
| 		"textures.requests", | 		"textures.request.sent", | ||||||
| 		metric.WithDescription(""), // TODO: write description | 		metric.WithDescription("Number of textures requests sent to Mojang API"), | ||||||
| 		metric.WithUnit("1"), | 		metric.WithUnit("1"), | ||||||
| 	) | 	) | ||||||
| 	errors = multierr.Append(errors, err) | 	errors = multierr.Append(errors, err) | ||||||
| @@ -119,14 +119,14 @@ func newTexturesProviderWithInMemoryCacheMetrics(meter metric.Meter) (*texturesP | |||||||
|  |  | ||||||
| 	m.Hits, err = meter.Int64Counter( | 	m.Hits, err = meter.Int64Counter( | ||||||
| 		"textures.cache.hit", | 		"textures.cache.hit", | ||||||
| 		metric.WithDescription(""), // TODO: write description | 		metric.WithDescription("Number of Mojang textures found in the local cache"), | ||||||
| 		metric.WithUnit("1"), | 		metric.WithUnit("1"), | ||||||
| 	) | 	) | ||||||
| 	errors = multierr.Append(errors, err) | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
| 	m.Misses, err = meter.Int64Counter( | 	m.Misses, err = meter.Int64Counter( | ||||||
| 		"textures.cache.miss", | 		"textures.cache.miss", | ||||||
| 		metric.WithDescription(""), // TODO: write description | 		metric.WithDescription("Number of Mojang textures missing from local cache"), | ||||||
| 		metric.WithUnit("1"), | 		metric.WithUnit("1"), | ||||||
| 	) | 	) | ||||||
| 	errors = multierr.Append(errors, err) | 	errors = multierr.Append(errors, err) | ||||||
|   | |||||||
| @@ -89,14 +89,14 @@ func newUuidsProviderWithCacheMetrics(meter metric.Meter) (*uuidsProviderWithCac | |||||||
|  |  | ||||||
| 	m.Hits, err = meter.Int64Counter( | 	m.Hits, err = meter.Int64Counter( | ||||||
| 		"uuids.cache.hit", | 		"uuids.cache.hit", | ||||||
| 		metric.WithDescription(""), // TODO: write description | 		metric.WithDescription("Number of Mojang UUIDs found in the local cache"), | ||||||
| 		metric.WithUnit("1"), | 		metric.WithUnit("1"), | ||||||
| 	) | 	) | ||||||
| 	errors = multierr.Append(errors, err) | 	errors = multierr.Append(errors, err) | ||||||
|  |  | ||||||
| 	m.Misses, err = meter.Int64Counter( | 	m.Misses, err = meter.Int64Counter( | ||||||
| 		"uuids.cache.miss", | 		"uuids.cache.miss", | ||||||
| 		metric.WithDescription(""), // TODO: write description | 		metric.WithDescription("Number of Mojang UUIDs missing from local cache"), | ||||||
| 		metric.WithUnit("1"), | 		metric.WithUnit("1"), | ||||||
| 	) | 	) | ||||||
| 	errors = multierr.Append(errors, err) | 	errors = multierr.Append(errors, err) | ||||||
|   | |||||||
| @@ -8,13 +8,11 @@ import ( | |||||||
|  |  | ||||||
| 	"github.com/agoda-com/opentelemetry-go/otelslog" | 	"github.com/agoda-com/opentelemetry-go/otelslog" | ||||||
| 	logsOtel "github.com/agoda-com/opentelemetry-logs-go" | 	logsOtel "github.com/agoda-com/opentelemetry-logs-go" | ||||||
| 	"github.com/agoda-com/opentelemetry-logs-go/exporters/otlp/otlplogs" | 	logsAutoconfig "github.com/agoda-com/opentelemetry-logs-go/autoconfigure/sdk/logs" | ||||||
| 	"github.com/agoda-com/opentelemetry-logs-go/sdk/logs" | 	"github.com/agoda-com/opentelemetry-logs-go/sdk/logs" | ||||||
| 	logsSdk "github.com/agoda-com/opentelemetry-logs-go/sdk/logs" | 	"go.opentelemetry.io/contrib/exporters/autoexport" | ||||||
| 	runtimeMetrics "go.opentelemetry.io/contrib/instrumentation/runtime" | 	runtimeMetrics "go.opentelemetry.io/contrib/instrumentation/runtime" | ||||||
| 	"go.opentelemetry.io/otel" | 	"go.opentelemetry.io/otel" | ||||||
| 	"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp" |  | ||||||
| 	"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" |  | ||||||
| 	"go.opentelemetry.io/otel/propagation" | 	"go.opentelemetry.io/otel/propagation" | ||||||
| 	"go.opentelemetry.io/otel/sdk/metric" | 	"go.opentelemetry.io/otel/sdk/metric" | ||||||
| 	"go.opentelemetry.io/otel/sdk/resource" | 	"go.opentelemetry.io/otel/sdk/resource" | ||||||
| @@ -122,43 +120,29 @@ func newResource(ctx context.Context) (*resource.Resource, error) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func newLoggerProvider(ctx context.Context, res *resource.Resource) (*logs.LoggerProvider, error) { | func newLoggerProvider(ctx context.Context, res *resource.Resource) (*logs.LoggerProvider, error) { | ||||||
| 	exporter, err := otlplogs.NewExporter(ctx) | 	return logsAutoconfig.NewLoggerProvider(ctx, logsAutoconfig.WithResource(res)), nil | ||||||
| 	if err != nil { |  | ||||||
| 		return nil, err |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	loggerProvider := logsSdk.NewLoggerProvider( |  | ||||||
| 		logsSdk.WithBatcher(exporter), |  | ||||||
| 		logsSdk.WithResource(res), |  | ||||||
| 	) |  | ||||||
|  |  | ||||||
| 	return loggerProvider, nil |  | ||||||
| } | } | ||||||
|  |  | ||||||
| func newTraceProvider(ctx context.Context, res *resource.Resource) (*trace.TracerProvider, error) { | func newTraceProvider(ctx context.Context, res *resource.Resource) (*trace.TracerProvider, error) { | ||||||
| 	traceExporter, err := otlptracehttp.New(ctx) | 	exporter, err := autoexport.NewSpanExporter(ctx) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	traceProvider := trace.NewTracerProvider( | 	return trace.NewTracerProvider( | ||||||
|  | 		trace.WithBatcher(exporter), | ||||||
| 		trace.WithResource(res), | 		trace.WithResource(res), | ||||||
| 		trace.WithBatcher(traceExporter), | 	), nil | ||||||
| 	) |  | ||||||
|  |  | ||||||
| 	return traceProvider, nil |  | ||||||
| } | } | ||||||
|  |  | ||||||
| func newMeterProvider(ctx context.Context, res *resource.Resource) (*metric.MeterProvider, error) { | func newMeterProvider(ctx context.Context, res *resource.Resource) (*metric.MeterProvider, error) { | ||||||
| 	metricExporter, err := otlpmetrichttp.New(ctx) | 	reader, err := autoexport.NewMetricReader(ctx) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	meterProvider := metric.NewMeterProvider( | 	return metric.NewMeterProvider( | ||||||
|  | 		metric.WithReader(reader), | ||||||
| 		metric.WithResource(res), | 		metric.WithResource(res), | ||||||
| 		metric.WithReader(metric.NewPeriodicReader(metricExporter)), | 	), nil | ||||||
| 	) |  | ||||||
|  |  | ||||||
| 	return meterProvider, nil |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user