Skip to content

Commit

Permalink
initializes otel metric collection for ftl dev and introduces a coupl…
Browse files Browse the repository at this point in the history
…e shared otel metric attributes
  • Loading branch information
jonathanj-square committed Jul 23, 2024
1 parent 48ea4a6 commit 4f2a0ff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/ftl/cmd_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 20 additions & 0 deletions internal/observability/metrics/attributes.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 4f2a0ff

Please sign in to comment.