4d2a324fce
This commit switches our code to use semconv 1.21, which is the version matching the OTEL modules, as well as the containerd code. The BuildKit 0.12.x module currently uses an older version of the OTEL modules, and uses the semconv 0.17 schema. Mixing schema-versions is problematic, but we still want to consume BuildKit's "detect" package to wire-up other parts of OTEL. To align the versions in our code, this patch sets the BuildKit detect.Resource with the correct semconv version. It's worth noting that the BuildKit package has a custom "serviceNameDetector"; https://github.com/moby/buildkit/blob/v0.12.4/util/tracing/detect/detect.go#L153-L169 Whith is merged with OTEL's default resource: https://github.com/moby/buildkit/blob/v0.12.4/util/tracing/detect/detect.go#L100-L107 There's no need to duplicate that code, as OTEL's `resource.Default()` already provides this functionality: - It uses fromEnv{} detector internally: https://github.com/open-telemetry/opentelemetry-go/blob/v1.19.0/sdk/resource/resource.go#L208 - fromEnv{} detector reads OTEL_SERVICE_NAME: https://github.com/open-telemetry/opentelemetry-go/blob/v1.19.0/sdk/resource/env.go#L53 This patch also removes uses of the httpconv package, which is no longer included in semconv 1.21 and now an internal package. Removing the use of this package means that hijacked connections will not have the HTTP attributes on the Moby client span, which isn't ideal, but a limited loss that'd impact exec/attach. The span itself will still exist, it just won't the additional attributes that are added by that package. Alternatively, the httpconv call COULD remain - it will not error and will send syntactically valid spans but we would be mixing & matching semconv versions, so won't be compliant. Some parts of the httpconv package were preserved through a very minimal local implementation; a variant of `httpconv.ClientStatus(resp.StatusCode))` is added to set the span status (`span.SetStatus()`). The `httpconv` package has complex logic for this, but mostly drills down to HTTP status range (1xx/2xx/3xx/4xx/5xx) to determine if the status was successfull or non-successful (4xx/5xx). The additional logic it provided was to validate actual status-codes, and to convert "bogus" status codes in "success" ranges (1xx, 2xx) into an error. That code seemed over-reaching (and not accounting for potential future _valid_ status codes). Let's assume we only get valid status codes. - https://github.com/open-telemetry/opentelemetry-go/blob/v1.21.0/semconv/v1.17.0/httpconv/http.go#L85-L89 - https://github.com/open-telemetry/opentelemetry-go/blob/v1.21.0/semconv/internal/v2/http.go#L322-L330 - https://github.com/open-telemetry/opentelemetry-go/blob/v1.21.0/semconv/internal/v2/http.go#L356-L404 Signed-off-by: Sebastiaan van Stijn <github@gone.nl> |
||
---|---|---|
.. | ||
daemon | ||
environment | ||
fakecontext | ||
fakegit | ||
fakestorage | ||
fixtures | ||
registry | ||
request | ||
doc.go | ||
helper.go | ||
helpers.go | ||
stringutils.go | ||
stringutils_test.go |