Files
de61635b81 refactor: move all packages under pkg/ for v5 (#559)
* refactor: move all packages under pkg/ for v5

Move all 13 top-level Go packages into pkg/ for a cleaner repository
structure. All internal import paths updated from
github.com/formancehq/go-libs/v5/<pkg> to
github.com/formancehq/go-libs/v5/pkg/<pkg>.

Also includes cleanup:
- Fix .golangci.yml stale v4 CircuitBreaker path
- Replace deprecated str.Contains with stdlib slices.Contains
- Update TODO(v4) markers to TODO
- Delete stale coverage.txt
- Fix pgtesting timeout not being propagated to docker pool
- Update docs/ARCHITECTURE.md to reflect new structure

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* chore: remove compatibility aliases, unused params, and stub files

- Remove unused type aliases (Authenticator, KeySet) from authnfx
- Remove unused `debug` parameter from S3ModuleFromFlags
- Delete comment-only stub files in messaging/publish/circuit/

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* chore: rename cli.go to flags.go for consistency

Standardize naming across all packages: cli.go -> flags.go
since these files all serve the same purpose (flag definitions).

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* chore: rename

* chore(deps): update all dependencies

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix: resolve package name mismatches in generated mocks

Generated mock files had stale package names from before the pkg/ move,
causing import cycles and build failures with --build-tags it.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
2026-03-20 09:17:12 +00:00

43 lines
1.2 KiB
Go

package observe
import (
"fmt"
"strings"
flag "github.com/spf13/pflag"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/resource"
)
const (
OtelResourceAttributesFlag = "otel-resource-attributes"
OtelServiceNameFlag = "otel-service-name"
)
func AddFlags(flags *flag.FlagSet) {
if flags.Lookup(OtelServiceNameFlag) == nil {
flags.String(OtelServiceNameFlag, "", "OpenTelemetry service name")
flags.StringSlice(OtelResourceAttributesFlag, []string{}, "Additional OTLP resource attributes")
}
}
func BuildResource(serviceName string, resourceAttributes []string, version string) (*resource.Resource, error) {
defaultResource := resource.Default()
attributes := make([]attribute.KeyValue, 0)
if serviceName != "" {
attributes = append(attributes, attribute.String("service.name", serviceName))
}
if version != "" {
attributes = append(attributes, attribute.String("service.version", version))
}
for _, ra := range resourceAttributes {
parts := strings.SplitN(ra, "=", 2)
if len(parts) < 2 {
return nil, fmt.Errorf("malformed otlp attribute: %s", ra)
}
attributes = append(attributes, attribute.String(parts[0], parts[1]))
}
return resource.Merge(defaultResource, resource.NewSchemaless(attributes...))
}