diff --git a/cmd/ftl/cmd_serve.go b/cmd/ftl/cmd_serve.go index 001de80f35..fa2909094c 100644 --- a/cmd/ftl/cmd_serve.go +++ b/cmd/ftl/cmd_serve.go @@ -84,6 +84,10 @@ func (s *serveCmd) run(ctx context.Context, projConfig projectconfig.Config, ini return errors.New(ftlRunningErrorMsg) } + if err := observability.Init(ctx, "ftl-dev", ftl.Version, s.ObservabilityConfig); err != nil { + return fmt.Errorf("failed to initialize observability: %w", err) + } + logger.Infof("Starting FTL with %d controller(s)", s.Controllers) // Bring up the DB and DAL. diff --git a/internal/observability/metrics/attributes.go b/internal/observability/metrics/attributes.go new file mode 100644 index 0000000000..b29a438335 --- /dev/null +++ b/internal/observability/metrics/attributes.go @@ -0,0 +1,20 @@ +package metrics + +import ( + "github.com/TBD54566975/ftl/backend/schema" + "go.opentelemetry.io/otel/attribute" +) + +// FeatureNameAttribute identifies the feature (e.g. verb) that the associated +// metric originates from. The entire module qualified name is used: +// e.g. {module.verb} +func FeatureNameAttribute(ref schema.Ref) attribute.KeyValue { + return attribute.String("ftl.feature.name", ref.Name) +} + +// DestinationVerbAttribute identifies the target verb associated metric. This +// attribute is relevant for metrics involving verb invocations. The entire +// module qualified name is used: e.g. {module.verb} +func DestinationVerbAttribute(ref schema.Ref) attribute.KeyValue { + return attribute.String("ftl.dest.verb", ref.Name) +}