Skip to content

Updated ocr3 Metadata type to include Encoding and Decoding and updated common beholder code #1160

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

Merged
merged 38 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3e73f11
Updated ocr3 Metadata type to include Encoding and Decoding
silaslenihan Apr 25, 2025
0b88e24
Merge branch 'main' into update-ocr3-metadata
silaslenihan Apr 30, 2025
ea228d8
Merge branch 'main' into update-ocr3-metadata
silaslenihan May 7, 2025
1ef8a0f
Merge branch 'main' into update-ocr3-metadata
silaslenihan May 13, 2025
b60cf42
Merge branch 'main' into update-ocr3-metadata
silaslenihan May 13, 2025
a973d22
Merge branch 'main' into update-ocr3-metadata
silaslenihan May 14, 2025
6cfaac2
Merge branch 'main' into update-ocr3-metadata
silaslenihan May 19, 2025
f3ed96e
Revert "add GetEstimateFee (#1196)"
silaslenihan May 19, 2025
3277762
Reapply "add GetEstimateFee (#1196)"
silaslenihan May 20, 2025
d8e352f
Merge branch 'main' into update-ocr3-metadata
silaslenihan May 23, 2025
46548a5
addressed feedback
silaslenihan May 23, 2025
9aa700e
Merge branch 'main' into update-ocr3-metadata
silaslenihan May 27, 2025
5ca7af8
Moved proto emitter and helpers to common
silaslenihan May 27, 2025
7d73232
Published common attritutes
silaslenihan May 27, 2025
acf7933
addressed feedback
silaslenihan May 28, 2025
630467f
Merge branch 'main' into update-ocr3-metadata
silaslenihan May 28, 2025
9084a34
Merge branch 'main' into update-ocr3-metadata
silaslenihan May 30, 2025
4563985
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 3, 2025
a99824a
added beholder attribute data_type
silaslenihan Jun 3, 2025
6bd2efa
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 4, 2025
55281bb
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 4, 2025
f63d042
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 5, 2025
64c6a47
removed behodler for attr keys'
silaslenihan Jun 5, 2025
bc72ed9
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 5, 2025
1ff9a46
Revert "pkg/loop: expand EnvConfig and make available from Server (#1…
silaslenihan Jun 5, 2025
6dcd6de
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 6, 2025
5981ca5
Reapply "pkg/loop: expand EnvConfig and make available from Server (#…
silaslenihan Jun 6, 2025
51de512
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 9, 2025
54755c8
Revert "Seed random for setup and modes (#1236)"
silaslenihan Jun 10, 2025
491d1b2
Reapply "Seed random for setup and modes (#1236)"
silaslenihan Jun 10, 2025
d504298
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 11, 2025
eb6b357
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 11, 2025
00a1fdb
Revert "requests handling (#1247)"
silaslenihan Jun 11, 2025
938ff7f
Reapply "requests handling (#1247)"
silaslenihan Jun 11, 2025
e845ca6
Made ToSchemaFullName public
silaslenihan Jun 11, 2025
9f01f00
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 17, 2025
fad1860
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 17, 2025
e2cdf99
Merge branch 'main' into update-ocr3-metadata
silaslenihan Jun 18, 2025
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
8 changes: 8 additions & 0 deletions pkg/beholder/attributes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package beholder

const (
AttrKeyDataSchema = "beholder_data_schema"
AttrKeyEntity = "beholder_entity"
AttrKeyDomain = "beholder_domain"
AttrKeyDataType = "beholder_data_type"
)
4 changes: 2 additions & 2 deletions pkg/beholder/chip_ingress_emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ func ExtractSourceAndType(attrKVs ...any) (string, string, error) {
for key, value := range attributes {

// Retrieve source and type using either ChIP or legacy attribute names, prioritizing source/type
if key == "source" || (key == "beholder_domain" && sourceDomain == "") {
if key == "source" || (key == AttrKeyDomain && sourceDomain == "") {
if val, ok := value.(string); ok {
sourceDomain = val
}
}
if key == "type" || (key == "beholder_entity" && entityType == "") {
if key == "type" || (key == AttrKeyEntity && entityType == "") {
if val, ok := value.(string); ok {
entityType = val
}
Expand Down
34 changes: 17 additions & 17 deletions pkg/beholder/chip_ingress_emitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestChipIngressEmit(t *testing.T) {
emitter, err := beholder.NewChipIngressEmitter(clientMock)
require.NoError(t, err)

err = emitter.Emit(t.Context(), body, "beholder_domain", domain, "beholder_entity", entity)
err = emitter.Emit(t.Context(), body, beholder.AttrKeyDomain, domain, beholder.AttrKeyEntity, entity)
require.NoError(t, err)

clientMock.AssertExpectations(t)
Expand All @@ -59,7 +59,7 @@ func TestChipIngressEmit(t *testing.T) {
emitter, err := beholder.NewChipIngressEmitter(clientMock)
require.NoError(t, err)

err = emitter.Emit(t.Context(), body, "beholder_domain", domain)
err = emitter.Emit(t.Context(), body, beholder.AttrKeyDomain, domain)
assert.Error(t, err)
})

Expand All @@ -74,7 +74,7 @@ func TestChipIngressEmit(t *testing.T) {
emitter, err := beholder.NewChipIngressEmitter(clientMock)
require.NoError(t, err)

err = emitter.Emit(t.Context(), body, "beholder_domain", domain, "beholder_entity", entity)
err = emitter.Emit(t.Context(), body, beholder.AttrKeyDomain, domain, beholder.AttrKeyEntity, entity)
require.Error(t, err)

clientMock.AssertExpectations(t)
Expand All @@ -92,7 +92,7 @@ func TestExtractSourceAndType(t *testing.T) {
}{
{
name: "happy path - domain and entity exist",
attrs: []any{map[string]any{"beholder_domain": "test-domain", "beholder_entity": "test-entity"}},
attrs: []any{map[string]any{beholder.AttrKeyDomain: "test-domain", beholder.AttrKeyEntity: "test-entity"}},
wantDomain: "test-domain",
wantEntity: "test-entity",
wantErr: false,
Expand All @@ -106,22 +106,22 @@ func TestExtractSourceAndType(t *testing.T) {
},
{
name: "happy path - domain and entity exist - uses source/type",
attrs: []any{map[string]any{"source": "other-domain", "beholder_domain": "test-domain", "beholder_entity": "test-entity", "type": "other-entity"}},
attrs: []any{map[string]any{"source": "other-domain", beholder.AttrKeyDomain: "test-domain", beholder.AttrKeyEntity: "test-entity", "type": "other-entity"}},
wantDomain: "other-domain",
wantEntity: "other-entity",
wantErr: false,
},
{
name: "missing domain/source",
attrs: []any{map[string]any{"beholder_entity": "test-entity"}},
attrs: []any{map[string]any{beholder.AttrKeyEntity: "test-entity"}},
wantDomain: "",
wantEntity: "",
wantErr: true,
expectedError: "source/beholder_domain not found in provided key/value attributes",
},
{
name: "missing entity/type",
attrs: []any{map[string]any{"beholder_domain": "test-domain"}},
attrs: []any{map[string]any{beholder.AttrKeyDomain: "test-domain"}},
wantDomain: "",
wantEntity: "",
wantErr: true,
Expand All @@ -146,10 +146,10 @@ func TestExtractSourceAndType(t *testing.T) {
{
name: "domain and entity with additional attributes",
attrs: []any{map[string]any{
"other_key": "other_value",
"beholder_domain": "test-domain",
"beholder_entity": "test-entity",
"something_else": 123,
"other_key": "other_value",
beholder.AttrKeyDomain: "test-domain",
beholder.AttrKeyEntity: "test-entity",
"something_else": 123,
}},
wantDomain: "test-domain",
wantEntity: "test-entity",
Expand All @@ -158,9 +158,9 @@ func TestExtractSourceAndType(t *testing.T) {
{
name: "non-string keys ignored",
attrs: []any{map[string]any{
"other_value": "value",
"beholder_domain": "test-domain",
"beholder_entity": "test-entity",
"other_value": "value",
beholder.AttrKeyDomain: "test-domain",
beholder.AttrKeyEntity: "test-entity",
}, 123, "other_key"},
wantDomain: "test-domain",
wantEntity: "test-entity",
Expand All @@ -169,9 +169,9 @@ func TestExtractSourceAndType(t *testing.T) {
{
name: "non-string values handled",
attrs: []any{map[string]any{
"other_key": 123,
"beholder_domain": "test-domain",
"beholder_entity": "test-entity",
"other_key": 123,
beholder.AttrKeyDomain: "test-domain",
beholder.AttrKeyEntity: "test-entity",
}},
wantDomain: "test-domain",
wantEntity: "test-entity",
Expand Down
4 changes: 2 additions & 2 deletions pkg/beholder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func NewGRPCClient(cfg Config, otlploggrpcNew otlploggrpcFactory) (*Client, erro
}

loggerAttributes := []attribute.KeyValue{
attribute.String("beholder_data_type", "zap_log_message"),
attribute.String(AttrKeyDataType, "zap_log_message"),
}
loggerResource, err := sdkresource.Merge(
sdkresource.NewSchemaless(loggerAttributes...),
Expand Down Expand Up @@ -195,7 +195,7 @@ func NewGRPCClient(cfg Config, otlploggrpcNew otlploggrpcFactory) (*Client, erro
}

messageAttributes := []attribute.KeyValue{
attribute.String("beholder_data_type", "custom_message"),
attribute.String(AttrKeyDataType, "custom_message"),
}
messageLoggerResource, err := sdkresource.Merge(
sdkresource.NewSchemaless(messageAttributes...),
Expand Down
24 changes: 12 additions & 12 deletions pkg/beholder/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ func (m *MockExporter) ForceFlush(ctx context.Context) error {
func TestClient(t *testing.T) {
defaultCustomAttributes := func() map[string]any {
return map[string]any{
"int_key_1": 123,
"int64_key_1": int64(123),
"int32_key_1": int32(123),
"str_key_1": "str_val_1",
"bool_key_1": true,
"float_key_1": 123.456,
"byte_key_1": []byte("byte_val_1"),
"str_slice_key_1": []string{"str_val_1", "str_val_2"},
"nil_key_1": nil,
"beholder_domain": "TestDomain", // Required field
"beholder_entity": "TestEntity", // Required field
"beholder_data_schema": "/schemas/ids/1001", // Required field, URI
"int_key_1": 123,
"int64_key_1": int64(123),
"int32_key_1": int32(123),
"str_key_1": "str_val_1",
"bool_key_1": true,
"float_key_1": 123.456,
"byte_key_1": []byte("byte_val_1"),
"str_slice_key_1": []string{"str_val_1", "str_val_2"},
"nil_key_1": nil,
beholder.AttrKeyDomain: "TestDomain", // Required field
beholder.AttrKeyEntity: "TestEntity", // Required field
beholder.AttrKeyDataSchema: "/schemas/ids/1001", // Required field, URI
}
}
defaultMessageBody := []byte("body bytes")
Expand Down
14 changes: 7 additions & 7 deletions pkg/beholder/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ func ExampleNewClient() {
fmt.Println("Emit custom messages")
for range 10 {
err := beholder.GetEmitter().Emit(context.Background(), payloadBytes,
"beholder_data_schema", "/custom-message/versions/1", // required
"beholder_domain", "ExampleDomain", // required
"beholder_entity", "ExampleEntity", // required
"beholder_data_type", "custom_message",
beholder.AttrKeyDataSchema, "/custom-message/versions/1", // required
beholder.AttrKeyDomain, "ExampleDomain", // required
beholder.AttrKeyEntity, "ExampleEntity", // required
beholder.AttrKeyDataType, "custom_message",
"foo", "bar",
)
if err != nil {
Expand Down Expand Up @@ -106,9 +106,9 @@ func ExampleNewNoopClient() {
fmt.Println("Emitting custom message via noop otel client")

err := beholder.GetEmitter().Emit(context.Background(), []byte("test message"),
"beholder_data_schema", "/custom-message/versions/1", // required
"beholder_domain", "ExampleDomain", // required
"beholder_entity", "ExampleEntity", // required
beholder.AttrKeyDataSchema, "/custom-message/versions/1", // required
beholder.AttrKeyDomain, "ExampleDomain", // required
beholder.AttrKeyEntity, "ExampleEntity", // required
)
if err != nil {
log.Printf("Error emitting message: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/beholder/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func NewHTTPClient(cfg Config, otlploghttpNew otlploghttpFactory) (*Client, erro
loggerProcessor = sdklog.NewSimpleProcessor(sharedLogExporter)
}
loggerAttributes := []attribute.KeyValue{
attribute.String("beholder_data_type", "zap_log_message"),
attribute.String(AttrKeyDataType, "zap_log_message"),
}
loggerResource, err := sdkresource.Merge(
sdkresource.NewSchemaless(loggerAttributes...),
Expand Down Expand Up @@ -160,7 +160,7 @@ func NewHTTPClient(cfg Config, otlploghttpNew otlploghttpFactory) (*Client, erro
}

messageAttributes := []attribute.KeyValue{
attribute.String("beholder_data_type", "custom_message"),
attribute.String(AttrKeyDataType, "custom_message"),
}
messageLoggerResource, err := sdkresource.Merge(
sdkresource.NewSchemaless(messageAttributes...),
Expand Down
12 changes: 6 additions & 6 deletions pkg/beholder/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ func (m Metadata) Attributes() Attributes {
"workflow_owner_address": m.WorkflowOwnerAddress,
"workflow_spec_id": m.WorkflowSpecID,
"workflow_execution_id": m.WorkflowExecutionID,
"beholder_domain": m.BeholderDomain,
"beholder_entity": m.BeholderEntity,
"beholder_data_schema": m.BeholderDataSchema,
AttrKeyDomain: m.BeholderDomain,
AttrKeyEntity: m.BeholderEntity,
AttrKeyDataSchema: m.BeholderDataSchema,
"capability_contract_address": m.CapabilityContractAddress,
"capability_id": m.CapabilityID,
"capability_version": m.CapabilityVersion,
Expand Down Expand Up @@ -206,11 +206,11 @@ func (m *Metadata) FromAttributes(attrs Attributes) *Metadata {
m.WorkflowSpecID = v.(string)
case "workflow_execution_id":
m.WorkflowExecutionID = v.(string)
case "beholder_domain":
case AttrKeyDomain:
m.BeholderDomain = v.(string)
case "beholder_entity":
case AttrKeyEntity:
m.BeholderEntity = v.(string)
case "beholder_data_schema":
case AttrKeyDataSchema:
m.BeholderDataSchema = v.(string)
case "capability_contract_address":
m.CapabilityContractAddress = v.(string)
Expand Down
42 changes: 21 additions & 21 deletions pkg/beholder/message_emitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,49 +44,49 @@ func TestEmitterMessageValidation(t *testing.T) {
{
name: "Invalid URI not causing error",
attrs: beholder.Attributes{
"beholder_domain": "TestDomain",
"beholder_entity": "TestEntity",
"beholder_data_schema": "example-schema",
beholder.AttrKeyDomain: "TestDomain",
beholder.AttrKeyEntity: "TestEntity",
beholder.AttrKeyDataSchema: "example-schema",
},
exporterCalledTimes: 1,
expectedError: "",
},
{
name: "Invalid Beholder domain (double underscore)",
attrs: beholder.Attributes{
"beholder_data_schema": "/example-schema/versions/1",
"beholder_entity": "TestEntity",
"beholder_domain": "Test__Domain",
beholder.AttrKeyDataSchema: "/example-schema/versions/1",
beholder.AttrKeyEntity: "TestEntity",
beholder.AttrKeyDomain: "Test__Domain",
},
exporterCalledTimes: 0,
expectedError: "'Metadata.BeholderDomain' Error:Field validation for 'BeholderDomain' failed on the 'domain_entity' tag",
},
{
name: "Invalid Beholder domain (special characters)",
attrs: beholder.Attributes{
"beholder_data_schema": "/example-schema/versions/1",
"beholder_entity": "TestEntity",
"beholder_domain": "TestDomain*$",
beholder.AttrKeyDataSchema: "/example-schema/versions/1",
beholder.AttrKeyEntity: "TestEntity",
beholder.AttrKeyDomain: "TestDomain*$",
},
exporterCalledTimes: 0,
expectedError: "'Metadata.BeholderDomain' Error:Field validation for 'BeholderDomain' failed on the 'domain_entity' tag",
},
{
name: "Invalid Beholder entity (double underscore)",
attrs: beholder.Attributes{
"beholder_data_schema": "/example-schema/versions/1",
"beholder_entity": "Test__Entity",
"beholder_domain": "TestDomain",
beholder.AttrKeyDataSchema: "/example-schema/versions/1",
beholder.AttrKeyEntity: "Test__Entity",
beholder.AttrKeyDomain: "TestDomain",
},
exporterCalledTimes: 0,
expectedError: "'Metadata.BeholderEntity' Error:Field validation for 'BeholderEntity' failed on the 'domain_entity' tag",
},
{
name: "Invalid Beholder entity (special characters)",
attrs: beholder.Attributes{
"beholder_data_schema": "/example-schema/versions/1",
"beholder_entity": "TestEntity*$",
"beholder_domain": "TestDomain",
beholder.AttrKeyDataSchema: "/example-schema/versions/1",
beholder.AttrKeyEntity: "TestEntity*$",
beholder.AttrKeyDomain: "TestDomain",
},
exporterCalledTimes: 0,
expectedError: "'Metadata.BeholderEntity' Error:Field validation for 'BeholderEntity' failed on the 'domain_entity' tag",
Expand All @@ -95,19 +95,19 @@ func TestEmitterMessageValidation(t *testing.T) {
name: "Valid Attributes",
exporterCalledTimes: 1,
attrs: beholder.Attributes{
"beholder_domain": "TestDomain",
"beholder_entity": "TestEntity",
"beholder_data_schema": "/example-schema/versions/1",
beholder.AttrKeyDomain: "TestDomain",
beholder.AttrKeyEntity: "TestEntity",
beholder.AttrKeyDataSchema: "/example-schema/versions/1",
},
expectedError: "",
},
{
name: "Valid Attributes (special characters)",
exporterCalledTimes: 1,
attrs: beholder.Attributes{
"beholder_domain": "Test.Domain_42-1",
"beholder_entity": "Test.Entity_42-1",
"beholder_data_schema": "/example-schema/versions/1",
beholder.AttrKeyDomain: "Test.Domain_42-1",
beholder.AttrKeyEntity: "Test.Entity_42-1",
beholder.AttrKeyDataSchema: "/example-schema/versions/1",
},
expectedError: "",
},
Expand Down
Loading
Loading