Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temp for staging deploy after breaking ctx changes #896

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
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
41 changes: 22 additions & 19 deletions pkg/beholder/pb/base_message.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions pkg/beholder/pb/base_message.proto
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
syntax = "proto3";

import "values/pb/values.proto";

option go_package = "github.com/smartcontractkit/chainlink-common/pkg/beholder/pb/";

package pb;

// BaseMessage is a basic custom message, allowing the consumer to send
// a string msg with some key-value pairs for labels. Consumers can consume
// BaseMessage directly or extend it by addding use-case specific fields
// BaseMessage directly or extend it by adding use-case specific fields
// NOTE: do not compose protos for Beholder until INFOPLAT-1386 is completed
message BaseMessage {
string msg=1;
// https://protobuf.dev/programming-guides/proto3/#maps
// In go: if Value is empty for a key, nothing will be serialized
values.Map labels = 2;
map<string, string> labels = 2;
}
30 changes: 20 additions & 10 deletions pkg/capabilities/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/beholder"
"github.com/smartcontractkit/chainlink-common/pkg/beholder/pb"
"github.com/smartcontractkit/chainlink-common/pkg/values"
)

// Duplicates the attributes in beholder/message.go::Metadata
const (
// Duplicates the attributes in beholder/message.go::Metadata
LabelWorkflowOwner = "workflow_owner_address"
LabelWorkflowID = "workflow_id"
LabelWorkflowExecutionID = "workflow_execution_id"
Expand Down Expand Up @@ -167,16 +166,27 @@ func (e *Emitter) Emit(ctx context.Context, msg Message) error {
return errors.New("must provide workflow name to emit event")
}

wm, err := values.WrapMap(msg.Labels)
if err != nil {
return fmt.Errorf("could not wrap map: %w", err)
}

pm := values.ProtoMap(wm)
// TODO un-comment after INFOPLAT-1386
//wm, err := values.WrapMap(msg.Labels)
//if err != nil {
// return fmt.Errorf("could not wrap map: %w", err)
//}
//
//pm := values.ProtoMap(wm)

bytes, err := proto.Marshal(&pb.BaseMessage{
Labels: pm,
Msg: msg.Msg,
// any empty values will not be serialized (including the key)
Labels: map[string]string{
LabelWorkflowID: nmd.WorkflowID,
LabelWorkflowName: nmd.WorkflowName,
LabelWorkflowOwner: nmd.WorkflowOwner,
LabelCapabilityContractAddress: nmd.CapabilityContractAddress,
LabelCapabilityID: nmd.CapabilityID,
LabelCapabilityVersion: nmd.CapabilityVersion,
LabelCapabilityName: nmd.CapabilityName,
LabelWorkflowExecutionID: nmd.WorkflowExecutionID,
},
Msg: msg.Msg,
})
if err != nil {
return fmt.Errorf("could not marshal operational event: %w", err)
Expand Down
20 changes: 10 additions & 10 deletions pkg/custmsg/custom_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/beholder"
"github.com/smartcontractkit/chainlink-common/pkg/beholder/pb"
"github.com/smartcontractkit/chainlink-common/pkg/values"
)

type MessageEmitter interface {
Expand Down Expand Up @@ -94,21 +93,22 @@ func (l Labeler) SendLogAsCustomMessage(msg string) error {
}

func sendLogAsCustomMessageW(msg string, labels map[string]string) error {
// TODO un-comment after INFOPLAT-1386
// cast to map[string]any
newLabels := map[string]any{}
for k, v := range labels {
newLabels[k] = v
}
//newLabels := map[string]any{}
//for k, v := range labels {
// newLabels[k] = v
//}

m, err := values.NewMap(newLabels)
if err != nil {
return fmt.Errorf("could not wrap labels to map: %w", err)
}
//m, err := values.NewMap(newLabels)
//if err != nil {
// return fmt.Errorf("could not wrap labels to map: %w", err)
//}

// Define a custom protobuf payload to emit
payload := &pb.BaseMessage{
Msg: msg,
Labels: values.ProtoMap(m),
Labels: labels,
}
payloadBytes, err := proto.Marshal(payload)
if err != nil {
Expand Down
Loading