mirror of
https://github.com/luxfi/kms.git
synced 2026-11-03 08:42:32 +00:00
ghcr.io/luxfi/kms-operator has had no new image since v1.12.3. The Build KMS
Operator workflow failed on every tag since (v1.12.4 … v1.12.7) while its
sibling Build KMS succeeded on the same tag, so the tags looked published.
Dockerfile.operator:27 builds with -mod=vendor, and vendor/ had drifted from
go.mod in both directions:
- go.opentelemetry.io/otel/{metric,trace}: in vendor/modules.txt, not in go.mod
- github.com/luxfi/{crypto,geth,ids,keys,zap,address,age,cache,constants,
container,formatting,math,go-bip32,go-bip39}: in go.mod, not marked explicit
`go mod vendor` alone could not fix it — it aborted first on go.sum entries
missing for the k8s packages cmd/kms-operator imports (k8s.io/api/core/v1,
k8s.io/apimachinery/..., k8s.io/client-go/{dynamic,kubernetes,rest}). So:
go mod tidy (adds them, drops now-unused indirects) then go mod vendor.
Verified by stash control:
operator, -mod=vendor: rc=1 -> rc=0 ("inconsistent vendoring" 1 -> 0)
server, -mod=vendor: rc=1 -> rc=1 (unchanged)
The server's vendor build was already broken and stays broken, for an unrelated
reason: blst.h has never been vendored (confirmed absent from HEAD's tree, so it
could not have worked before either) — go mod vendor does not copy cgo headers
that live outside the package dir. It is not a regression and does not affect
CI: the server's Dockerfile builds with GOFLAGS=-mod=mod after `rm -f go.sum &&
go mod download`, i.e. from the module cache, never from vendor/. The operator
is the only -mod=vendor consumer, which is exactly why it was the only failure.
Co-authored-by: Hanzo Dev <[email protected]>
119 lines
3.5 KiB
Go
119 lines
3.5 KiB
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package metric // import "go.opentelemetry.io/otel/metric"
|
|
|
|
import (
|
|
"slices"
|
|
|
|
"go.opentelemetry.io/otel/attribute"
|
|
)
|
|
|
|
// MeterConfig contains options for Meters.
|
|
type MeterConfig struct {
|
|
instrumentationVersion string
|
|
schemaURL string
|
|
attrs attribute.Set
|
|
|
|
// Ensure forward compatibility by explicitly making this not comparable.
|
|
noCmp [0]func() //nolint: unused // This is indeed used.
|
|
}
|
|
|
|
// InstrumentationVersion returns the version of the library providing
|
|
// instrumentation.
|
|
func (cfg MeterConfig) InstrumentationVersion() string {
|
|
return cfg.instrumentationVersion
|
|
}
|
|
|
|
// InstrumentationAttributes returns the attributes associated with the library
|
|
// providing instrumentation.
|
|
func (cfg MeterConfig) InstrumentationAttributes() attribute.Set {
|
|
return cfg.attrs
|
|
}
|
|
|
|
// SchemaURL is the schema_url of the library providing instrumentation.
|
|
func (cfg MeterConfig) SchemaURL() string {
|
|
return cfg.schemaURL
|
|
}
|
|
|
|
// MeterOption is an interface for applying Meter options.
|
|
type MeterOption interface {
|
|
// applyMeter is used to set a MeterOption value of a MeterConfig.
|
|
applyMeter(MeterConfig) MeterConfig
|
|
}
|
|
|
|
type experimentalOption interface {
|
|
Experimental()
|
|
}
|
|
|
|
// NewMeterConfig creates a new MeterConfig and applies
|
|
// all the given options.
|
|
func NewMeterConfig(opts ...MeterOption) MeterConfig {
|
|
var config MeterConfig
|
|
for _, o := range opts {
|
|
if _, ok := o.(experimentalOption); ok {
|
|
continue
|
|
}
|
|
config = o.applyMeter(config)
|
|
}
|
|
return config
|
|
}
|
|
|
|
type meterOptionFunc func(MeterConfig) MeterConfig
|
|
|
|
func (fn meterOptionFunc) applyMeter(cfg MeterConfig) MeterConfig {
|
|
return fn(cfg)
|
|
}
|
|
|
|
// WithInstrumentationVersion sets the instrumentation version.
|
|
func WithInstrumentationVersion(version string) MeterOption {
|
|
return meterOptionFunc(func(config MeterConfig) MeterConfig {
|
|
config.instrumentationVersion = version
|
|
return config
|
|
})
|
|
}
|
|
|
|
// WithInstrumentationAttributes adds the instrumentation attributes.
|
|
//
|
|
// This is equivalent to calling [WithInstrumentationAttributeSet] with an
|
|
// [attribute.Set] created from a clone of the passed attributes.
|
|
// [WithInstrumentationAttributeSet] is recommended for more control.
|
|
//
|
|
// If multiple [WithInstrumentationAttributes] or [WithInstrumentationAttributeSet]
|
|
// options are passed, the attributes will be merged together in the order
|
|
// they are passed. Attributes with duplicate keys will use the last value passed.
|
|
func WithInstrumentationAttributes(attr ...attribute.KeyValue) MeterOption {
|
|
set := attribute.NewSet(slices.Clone(attr)...)
|
|
return WithInstrumentationAttributeSet(set)
|
|
}
|
|
|
|
// WithInstrumentationAttributeSet adds the instrumentation attributes.
|
|
//
|
|
// If multiple [WithInstrumentationAttributes] or [WithInstrumentationAttributeSet]
|
|
// options are passed, the attributes will be merged together in the order
|
|
// they are passed. Attributes with duplicate keys will use the last value passed.
|
|
func WithInstrumentationAttributeSet(set attribute.Set) MeterOption {
|
|
if set.Len() == 0 {
|
|
return meterOptionFunc(func(config MeterConfig) MeterConfig {
|
|
return config
|
|
})
|
|
}
|
|
|
|
return meterOptionFunc(func(config MeterConfig) MeterConfig {
|
|
if config.attrs.Len() == 0 {
|
|
config.attrs = set
|
|
} else {
|
|
config.attrs = mergeSets(config.attrs, set)
|
|
}
|
|
return config
|
|
})
|
|
}
|
|
|
|
// WithSchemaURL sets the schema URL.
|
|
func WithSchemaURL(schemaURL string) MeterOption {
|
|
return meterOptionFunc(func(config MeterConfig) MeterConfig {
|
|
config.schemaURL = schemaURL
|
|
return config
|
|
})
|
|
}
|