Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/capabilities/compute/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
wasmpb "github.com/smartcontractkit/chainlink-common/pkg/workflows/wasm/pb"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/validation"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/webapi"
"github.com/smartcontractkit/chainlink/v2/core/custmsgtypes"
"github.com/smartcontractkit/chainlink/v2/core/platform"
ghcapabilities "github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers/capabilities"
)
Expand Down Expand Up @@ -453,7 +454,7 @@ func NewAction(

var (
lggr = logger.Named(log, "CustomCompute")
labeler = custmsg.NewLabeler()
labeler = custmsg.NewLabeler().WithType(custmsgtypes.TypeCompute)
compute = &Compute{
stopCh: make(services.StopChan),
log: lggr,
Expand Down
3 changes: 2 additions & 1 deletion core/capabilities/compute/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/capabilities"
"github.com/smartcontractkit/chainlink-common/pkg/custmsg"
"github.com/smartcontractkit/chainlink/v2/core/custmsgtypes"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/workflows/wasm/host"
"github.com/smartcontractkit/chainlink-protos/cre/go/values"
Expand Down Expand Up @@ -89,7 +90,7 @@ func Test_transformer(t *testing.T) {
t.Parallel()
var (
lgger = logger.Test(t)
emitter = custmsg.NewLabeler()
emitter = custmsg.NewLabeler().WithType(custmsgtypes.TypeCompute)
)
t.Run("success", func(t *testing.T) {
t.Parallel()
Expand Down
4 changes: 2 additions & 2 deletions core/cmd/shell_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
"github.com/smartcontractkit/chainlink/v2/core/sessions"
"github.com/smartcontractkit/chainlink/v2/core/shutdown"
"github.com/smartcontractkit/chainlink/v2/core/custmsgtypes"
"github.com/smartcontractkit/chainlink/v2/core/static"
"github.com/smartcontractkit/chainlink/v2/core/store"
"github.com/smartcontractkit/chainlink/v2/core/store/migrate"
Expand Down Expand Up @@ -335,13 +336,12 @@ const ownerPermsMask = os.FileMode(0o700)

// EmitNodeConfig emits the node configuration through beholder as a pb.BaseMessage
func (s *Shell) EmitNodeConfig(ctx context.Context) {
cme := custmsg.NewLabeler()
labels := map[string]string{
"system": "Application",
"version": static.Version,
"commit": static.Sha,
}
emitter := cme.WithMapLabels(labels)
emitter := custmsg.NewLabeler().WithLabelsAndType(labels, custmsgtypes.TypeNodeConfig)

// Get the effective TOML configuration (with defaults applied)
_, effectiveTOML := s.Config.ConfigTOML()
Expand Down
1 change: 1 addition & 0 deletions core/cmd/shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,5 @@ func TestShell_emitNodeConfig(t *testing.T) {
require.Equal(t, "Application", baseMsg.Labels["system"])
require.Equal(t, static.Version, baseMsg.Labels["version"])
require.Equal(t, static.Sha, baseMsg.Labels["commit"])
require.Equal(t, "NodeConfig", baseMsg.Labels["type"])
}
11 changes: 11 additions & 0 deletions core/custmsgtypes/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Package custmsgtypes defines stable type label values for custmsg BaseMessage emissions.
package custmsgtypes

const (
TypeNodeConfig = "NodeConfig"
TypeHeartbeat = "Heartbeat"
TypeWorkflowEngine = "WorkflowEngine"
TypeWorkflowSyncer = "WorkflowSyncer"
TypeWorkflowArtifact = "WorkflowArtifact"
TypeCompute = "Compute"
)
5 changes: 2 additions & 3 deletions core/services/chainlink/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
commonservices "github.com/smartcontractkit/chainlink-common/pkg/services"
"github.com/smartcontractkit/chainlink-common/pkg/timeutil"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/custmsgtypes"
"github.com/smartcontractkit/chainlink/v2/core/static"

"github.com/smartcontractkit/chainlink-common/pkg/beholder"
Expand Down Expand Up @@ -59,7 +60,6 @@ func NewHeartbeatConfig(cfg ApplicationOpts) HeartbeatConfig {
// Update the constructor to accept optional emitter and meter
func NewHeartbeat(cfg HeartbeatConfig, opts ...HeartbeatOpt) Heartbeat {
// setup default emitter and meter
cme := custmsg.NewLabeler()
labels := map[string]string{"system": "Application", "version": static.Version, "commit": static.Sha}
if cfg.P2P != "" {
labels["peer_id"] = cfg.P2P
Expand All @@ -71,11 +71,10 @@ func NewHeartbeat(cfg HeartbeatConfig, opts ...HeartbeatOpt) Heartbeat {
labels["csa_key"] = cfg.CSAPublicKey
}

cme.WithMapLabels(labels)
h := Heartbeat{
beat: cfg.Beat,
opts: cfg,
emitter: cme.WithMapLabels(labels),
emitter: custmsg.NewLabeler().WithLabelsAndType(labels, custmsgtypes.TypeHeartbeat),
meter: beholder.GetMeter(),
}

Expand Down
9 changes: 5 additions & 4 deletions core/services/cre/cre.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
linkingclient "github.com/smartcontractkit/chainlink-protos/linking-service/go/v1"

"github.com/smartcontractkit/chainlink/v2/core/capabilities"
"github.com/smartcontractkit/chainlink/v2/core/custmsgtypes"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/compute"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/confidentialrelay"
gatewayconnector "github.com/smartcontractkit/chainlink/v2/core/capabilities/gateway_connector"
Expand Down Expand Up @@ -804,7 +805,7 @@ func newWorkflowRegistrySyncerV1(
fetcherFunc,
clockwork.NewRealClock(),
key,
custmsg.NewLabeler(),
custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowArtifact),
artifactsV1.WithMaxArtifactSize(
artifactsV1.ArtifactConfig{
MaxBinarySize: uint64(capCfg.WorkflowRegistry().MaxBinarySize()),
Expand Down Expand Up @@ -838,7 +839,7 @@ func newWorkflowRegistrySyncerV1(
dontimeStore,
opts.UseLocalTimeProvider,
engineRegistry,
custmsg.NewLabeler(),
custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowSyncer),
engineLimiters,
featureFlags,
workflowRateLimiter,
Expand Down Expand Up @@ -950,7 +951,7 @@ func newWorkflowRegistrySyncerV2(
retrieverFunc,
clockwork.NewRealClock(),
key,
custmsg.NewLabeler(),
custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowArtifact),
lf,
artifactsV2.WithConfig(artifactsV2.StoreConfig{
ArtifactStorageHost: wfReg.WorkflowStorage().ArtifactStorageHost(),
Expand Down Expand Up @@ -1083,7 +1084,7 @@ func newWorkflowRegistrySyncerV2(
opts.CapabilitiesRegistry,
opts.ExecutionHandlers,
engineRegistry,
custmsg.NewLabeler(),
custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowSyncer),
engineLimiters,
featureFlags,
workflowRateLimiter,
Expand Down
7 changes: 4 additions & 3 deletions core/services/workflows/artifacts/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/smartcontractkit/chainlink-common/keystore/corekeys/workflowkey"
"github.com/smartcontractkit/chainlink-common/pkg/custmsg"
"github.com/smartcontractkit/chainlink/v2/core/custmsgtypes"
"github.com/smartcontractkit/chainlink-common/pkg/workflows/secrets"
"github.com/smartcontractkit/chainlink/v2/core/logger"
ghcapabilities "github.com/smartcontractkit/chainlink/v2/core/services/gateway/handlers/capabilities"
Expand Down Expand Up @@ -72,7 +73,7 @@ func Test_Handler_SecretsFor(t *testing.T) {
fetcher.Fetch,
clockwork.NewFakeClock(),
encryptionKey,
custmsg.NewLabeler(),
custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowArtifact),
)
expectedSecrets := map[string]string{
"Foo": "Bar",
Expand Down Expand Up @@ -136,7 +137,7 @@ func Test_Handler_SecretsFor_RefreshesSecrets(t *testing.T) {
fetcher.Fetch,
clockwork.NewFakeClock(),
encryptionKey,
custmsg.NewLabeler(),
custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowArtifact),
)

expectedSecrets := map[string]string{
Expand Down Expand Up @@ -203,7 +204,7 @@ func Test_Handler_SecretsFor_RefreshLogic(t *testing.T) {
fetcher.Fetch,
clock,
encryptionKey,
custmsg.NewLabeler(),
custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowArtifact),
)

expectedSecrets := map[string]string{
Expand Down
11 changes: 6 additions & 5 deletions core/services/workflows/artifacts/v2/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/smartcontractkit/chainlink-common/keystore/corekeys/workflowkey"
"github.com/smartcontractkit/chainlink-common/pkg/contexts"
"github.com/smartcontractkit/chainlink-common/pkg/custmsg"
"github.com/smartcontractkit/chainlink/v2/core/custmsgtypes"
"github.com/smartcontractkit/chainlink-common/pkg/settings/limits"
storage_service "github.com/smartcontractkit/chainlink-protos/storage-service/go"
"github.com/smartcontractkit/chainlink/v2/core/logger"
Expand Down Expand Up @@ -78,7 +79,7 @@ func Test_Store_DeleteWorkflowArtifacts(t *testing.T) {
fetcher.RetrieveURL,
clockwork.NewFakeClock(),
encryptionKey,
custmsg.NewLabeler(),
custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowArtifact),
limits.Factory{Logger: lggr},
WithConfig(StoreConfig{
ArtifactStorageHost: "example.com",
Expand Down Expand Up @@ -127,7 +128,7 @@ func Test_Store_DeleteWorkflowArtifactsBatch(t *testing.T) {
fetcher := &mockFetcher{}
h, err := NewStore(
lggr, orm, fetcher.Fetch, fetcher.RetrieveURL,
clockwork.NewFakeClock(), encryptionKey, custmsg.NewLabeler(),
clockwork.NewFakeClock(), encryptionKey, custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowArtifact),
limits.Factory{Logger: lggr},
WithConfig(StoreConfig{ArtifactStorageHost: "example.com"}),
)
Expand Down Expand Up @@ -178,7 +179,7 @@ func Test_Store_FetchWorkflowArtifacts_WithStorage(t *testing.T) {
fetcher.RetrieveURL,
clockwork.NewFakeClock(),
encryptionKey,
custmsg.NewLabeler(),
custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowArtifact),
limits.Factory{Logger: lggr},
WithConfig(StoreConfig{
ArtifactStorageHost: "storage.chain.link",
Expand Down Expand Up @@ -222,7 +223,7 @@ func Test_Store_FetchWorkflowArtifacts_WithoutStorage(t *testing.T) {
fetcher.RetrieveURL,
clockwork.NewFakeClock(),
encryptionKey,
custmsg.NewLabeler(),
custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowArtifact),
limits.Factory{Logger: lggr},
WithConfig(StoreConfig{
ArtifactStorageHost: "storage.chain.link",
Expand Down Expand Up @@ -266,7 +267,7 @@ func Test_Store_FetchWorkflowArtifacts_SkipsRetrieving(t *testing.T) {
nil, // No retrieval function provided, so it should skip retrieving
clockwork.NewFakeClock(),
encryptionKey,
custmsg.NewLabeler(),
custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowArtifact),
limits.Factory{Logger: lggr},
WithConfig(StoreConfig{
ArtifactStorageHost: "example.com",
Expand Down
4 changes: 2 additions & 2 deletions core/services/workflows/cmd/cre/utils/standalone_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
workflowSettingsCfgFn func(*cresettings.Workflows),
) (services.Service, []*sdkpb.TriggerSubscription, error) {
ctx = contexts.WithCRE(ctx, contexts.CRE{Owner: defaultOwner, Workflow: defaultWorkflowID})
labeler := custmsg.NewLabeler()
labeler := custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowEngine)

Check failure on line 69 in core/services/workflows/cmd/cre/utils/standalone_engine.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: custmsgtypes

Check failure on line 69 in core/services/workflows/cmd/cre/utils/standalone_engine.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_race_tests)

undefined: custmsgtypes

Check failure on line 69 in core/services/workflows/cmd/cre/utils/standalone_engine.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

undefined: custmsgtypes

Check failure on line 69 in core/services/workflows/cmd/cre/utils/standalone_engine.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

undefined: custmsgtypes
moduleConfig := &host.ModuleConfig{
Logger: lggr,
Labeler: labeler,
Expand Down Expand Up @@ -198,7 +198,7 @@
FeatureFlags: featureFlags,
GlobalWorkflowLimit: workflowLimits,

BeholderEmitter: custmsg.NewLabeler(),
BeholderEmitter: custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowEngine),

Check failure on line 201 in core/services/workflows/cmd/cre/utils/standalone_engine.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

undefined: custmsgtypes

Check failure on line 201 in core/services/workflows/cmd/cre/utils/standalone_engine.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_race_tests)

undefined: custmsgtypes

Check failure on line 201 in core/services/workflows/cmd/cre/utils/standalone_engine.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

undefined: custmsgtypes

Check failure on line 201 in core/services/workflows/cmd/cre/utils/standalone_engine.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

undefined: custmsgtypes

BillingClient: billingClient,
Hooks: lifecycleHooks,
Expand Down
3 changes: 2 additions & 1 deletion core/services/workflows/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/platform"
"github.com/smartcontractkit/chainlink/v2/core/custmsgtypes"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/workflows/metering"
"github.com/smartcontractkit/chainlink/v2/core/services/workflows/store"
Expand Down Expand Up @@ -65,7 +66,7 @@ func (d *Delegate) OnDeleteJob(context.Context, job.Job) error { return nil }

// ServicesForSpec satisfies the job.Delegate interface.
func (d *Delegate) ServicesForSpec(ctx context.Context, spec job.Job) ([]job.ServiceCtx, error) {
cma := custmsg.NewLabeler().With(platform.KeyWorkflowID, spec.WorkflowSpec.WorkflowID, platform.KeyWorkflowOwner, spec.WorkflowSpec.WorkflowOwner, platform.KeyWorkflowName, spec.WorkflowSpec.WorkflowName)
cma := custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowEngine).With(platform.KeyWorkflowID, spec.WorkflowSpec.WorkflowID, platform.KeyWorkflowOwner, spec.WorkflowSpec.WorkflowOwner, platform.KeyWorkflowName, spec.WorkflowSpec.WorkflowName)
sdkSpec, err := spec.WorkflowSpec.SDKSpec(ctx)
if err != nil {
logCustMsg(ctx, cma, fmt.Sprintf("failed to start workflow engine: failed to get workflow sdk spec: %v", err), d.logger)
Expand Down
3 changes: 2 additions & 1 deletion core/services/workflows/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/workflows/ratelimiter"
"github.com/smartcontractkit/chainlink/v2/core/services/workflows/shardownership"

"github.com/smartcontractkit/chainlink/v2/core/custmsgtypes"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/transmission"
"github.com/smartcontractkit/chainlink/v2/core/platform"
"github.com/smartcontractkit/chainlink/v2/core/services/shardorchestrator"
Expand Down Expand Up @@ -1489,7 +1490,7 @@ func NewEngine(ctx context.Context, cfg Config) (engine *Engine, err error) {
cfg.WorkflowRegistryAddress = "0xv1EngineDefault"
}

cma := custmsg.NewLabeler().With(platform.KeyWorkflowID, cfg.WorkflowID,
cma := custmsg.NewLabeler().WithType(custmsgtypes.TypeWorkflowEngine).With(platform.KeyWorkflowID, cfg.WorkflowID,
platform.KeyWorkflowOwner, cfg.WorkflowOwner,
platform.KeyWorkflowName, cfg.WorkflowName.String(),
platform.KeyWorkflowVersion, platform.ValueWorkflowVersion,
Expand Down
Loading
Loading