From 14f654883d0976b9524471a8e4a6eaa7a97b6173 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Tue, 16 Aug 2022 11:32:14 +0100
Subject: [PATCH] Upgrade ai3/go-common

---
 go.mod                                        |  2 +-
 go.sum                                        |  6 ++----
 .../ai3/go-common/tracing/tracing.go          | 21 ++++++++++++-------
 vendor/modules.txt                            |  2 +-
 4 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/go.mod b/go.mod
index 10091e0..fd34d95 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module git.autistici.org/id/usermetadb
 go 1.14
 
 require (
-	git.autistici.org/ai3/go-common v0.0.0-20220814151247-39e01d32d5ee
+	git.autistici.org/ai3/go-common v0.0.0-20220816100049-520c8598dc2f
 	github.com/google/go-cmp v0.5.8
 	github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
 	golang.org/x/sys v0.0.0-20220317061510-51cd9980dadf // indirect
diff --git a/go.sum b/go.sum
index a39bc53..d6ce39d 100644
--- a/go.sum
+++ b/go.sum
@@ -50,10 +50,8 @@ contrib.go.opencensus.io/exporter/stackdriver v0.13.5/go.mod h1:aXENhDJ1Y4lIg4EU
 contrib.go.opencensus.io/integrations/ocsql v0.1.4/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE=
 contrib.go.opencensus.io/resource v0.1.1/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA=
 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
-git.autistici.org/ai3/go-common v0.0.0-20220814124137-4f7bac42fbdb h1:SNnhiNFAy64wKkk+Wxq1lotFPvaQY8GP+Z27wqpIN8E=
-git.autistici.org/ai3/go-common v0.0.0-20220814124137-4f7bac42fbdb/go.mod h1:yhMB8VKJBBr+EKMft7MtqHVO73vkwdq/O5sVDTs/CNI=
-git.autistici.org/ai3/go-common v0.0.0-20220814151247-39e01d32d5ee h1:EPfpfiG3vK9xoMt2sGclSaEXLikOCX1NfqUFRJXV4nk=
-git.autistici.org/ai3/go-common v0.0.0-20220814151247-39e01d32d5ee/go.mod h1:yhMB8VKJBBr+EKMft7MtqHVO73vkwdq/O5sVDTs/CNI=
+git.autistici.org/ai3/go-common v0.0.0-20220816100049-520c8598dc2f h1:GtBwLJtpkkFYWCMnBgu2PP7DBov5WLf1erxtMvW2JWU=
+git.autistici.org/ai3/go-common v0.0.0-20220816100049-520c8598dc2f/go.mod h1:yhMB8VKJBBr+EKMft7MtqHVO73vkwdq/O5sVDTs/CNI=
 github.com/Azure/azure-amqp-common-go/v2 v2.1.0/go.mod h1:R8rea+gJRuJR6QxTir/XuEd+YuKoUiazDC/N96FiDEU=
 github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4=
 github.com/Azure/azure-sdk-for-go v29.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
diff --git a/vendor/git.autistici.org/ai3/go-common/tracing/tracing.go b/vendor/git.autistici.org/ai3/go-common/tracing/tracing.go
index d418501..000ceb5 100644
--- a/vendor/git.autistici.org/ai3/go-common/tracing/tracing.go
+++ b/vendor/git.autistici.org/ai3/go-common/tracing/tracing.go
@@ -72,15 +72,18 @@ func getServiceName() string {
 	if s := os.Getenv("TRACING_SERVICE"); s != "" {
 		return s
 	}
-	return filepath.Base(os.Args[0])
+	if s, err := os.Executable(); err == nil {
+		return filepath.Base(s)
+	}
+	return "unknown_service"
 }
 
-func defaultResource() *resource.Resource {
+func defaultResource(serviceName string) *resource.Resource {
 	r, _ := resource.Merge(
 		resource.Default(),
 		resource.NewWithAttributes(
 			semconv.SchemaURL,
-			semconv.ServiceNameKey.String(getServiceName()),
+			semconv.ServiceNameKey.String(serviceName),
 		),
 	)
 	return r
@@ -128,8 +131,8 @@ func initTracing(serviceName string) {
 
 		tp := trace.NewTracerProvider(
 			trace.WithSampler(sampler),
-			trace.WithResource(defaultResource()),
 			trace.WithBatcher(ze),
+			trace.WithResource(defaultResource(serviceName)),
 		)
 
 		otel.SetTracerProvider(tp)
@@ -143,7 +146,7 @@ func initTracing(serviceName string) {
 
 // Init tracing support, if not using WrapHandler.
 func Init() {
-	initTracing("")
+	initTracing(getServiceName())
 }
 
 // WrapTransport optionally wraps a http.RoundTripper with OpenCensus
@@ -152,7 +155,7 @@ func Init() {
 // Must call Init() first.
 func WrapTransport(t http.RoundTripper) http.RoundTripper {
 	if Enabled {
-		t = othttp.NewTransport(t)
+		t = othttp.NewTransport(t, othttp.WithPublicEndpoint())
 	}
 	return t
 }
@@ -165,5 +168,9 @@ func WrapHandler(h http.Handler, endpointAddr string) http.Handler {
 	if !Enabled {
 		return h
 	}
-	return othttp.NewHandler(h, serviceName)
+
+	// Format span names with the request URL path.
+	return othttp.NewHandler(h, serviceName, othttp.WithSpanNameFormatter(func(op string, r *http.Request) string {
+		return r.URL.Path
+	}))
 }
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 309df36..20b8de7 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -1,4 +1,4 @@
-# git.autistici.org/ai3/go-common v0.0.0-20220814151247-39e01d32d5ee
+# git.autistici.org/ai3/go-common v0.0.0-20220816100049-520c8598dc2f
 ## explicit
 git.autistici.org/ai3/go-common
 git.autistici.org/ai3/go-common/clientutil
-- 
GitLab