mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-23 00:33:50 +01:00
[bugfix/tracing] fix broken tracing due to conflicting schema url (#2712)
The OpenTelemetry SDK is very strict about the schema version when the `Resource` is initialized. Specifically, different schema versions _CANNOT_ be mixed, and since the default SDK resource (which is merged with the user-defined one) defines a schema URL, the `semconv` imports are really prone to being out-of-sync. The best way to avoid this is to merge a _schemaless_ resource. This is fine...there's plenty of other ways to get `semconv` out of sync, and the core service attributes (e.g. `service.name`) should not ever change. Additionally, any errors here are now propagated so that they'll be visible instead of silently swallowed.
This commit is contained in:
parent
c7845c70d6
commit
66d9297e64
@ -34,8 +34,8 @@
|
|||||||
"go.opentelemetry.io/otel/propagation"
|
"go.opentelemetry.io/otel/propagation"
|
||||||
"go.opentelemetry.io/otel/sdk/resource"
|
"go.opentelemetry.io/otel/sdk/resource"
|
||||||
"go.opentelemetry.io/otel/sdk/trace"
|
"go.opentelemetry.io/otel/sdk/trace"
|
||||||
semconv "go.opentelemetry.io/otel/semconv/v1.20.0"
|
"go.opentelemetry.io/otel/semconv/v1.20.0/httpconv"
|
||||||
httpconv "go.opentelemetry.io/otel/semconv/v1.20.0/httpconv"
|
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||||
oteltrace "go.opentelemetry.io/otel/trace"
|
oteltrace "go.opentelemetry.io/otel/trace"
|
||||||
|
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||||
@ -84,13 +84,16 @@ func Initialize() error {
|
|||||||
default:
|
default:
|
||||||
return fmt.Errorf("invalid tracing transport: %s", config.GetTracingTransport())
|
return fmt.Errorf("invalid tracing transport: %s", config.GetTracingTransport())
|
||||||
}
|
}
|
||||||
r, _ := resource.Merge(
|
r, err := resource.Merge(
|
||||||
resource.Default(),
|
resource.Default(),
|
||||||
resource.NewWithAttributes(
|
resource.NewSchemaless(
|
||||||
semconv.SchemaURL,
|
|
||||||
semconv.ServiceName("GoToSocial"),
|
semconv.ServiceName("GoToSocial"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
// this can happen if semconv versioning is out-of-sync
|
||||||
|
return fmt.Errorf("building tracing resource: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
tp := trace.NewTracerProvider(
|
tp := trace.NewTracerProvider(
|
||||||
tpo,
|
tpo,
|
||||||
|
Loading…
Reference in New Issue
Block a user