Skip to content
Merged
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
4 changes: 2 additions & 2 deletions buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ deps:
commit: 62f35d8aed1149c291d606d958a7ce32
digest: b5:d66bf04adc77a0870bdc9328aaf887c7188a36fb02b83a480dc45ef9dc031b4d39fc6e9dc6435120ccf4fe5bfd5c6cb6592533c6c316595571f9a31420ab47fe
- name: buf.build/grpc-ecosystem/grpc-gateway
commit: 6467306b4f624747aaf6266762ee7a1c
digest: b5:c2caa61467d992749812c909f93c07e9a667da33c758a7c1973d63136c23b3cafcc079985b12cdf54a10049ed3297418f1eda42cdffdcf34113792dcc3a990af
commit: 4836b6d552304e1bbe47e66a523f0daa
digest: b5:c3fefd4d3dfa9b0478bbb1a4ad87d7b38146e3ce6eff4214e32f2c5834c2e4afc3be218316f0fbd53e925a001c3ed1e2fc99fb76b3121ede642989f0d0d7c71c
8 changes: 8 additions & 0 deletions flytestdlib/contextutils/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const (
ResourceVersionKey Key = "res_ver"
SignalIDKey Key = "signal"
RequestIDKey Key = "x-request-id"
OrganizationKey Key = "org"
ServiceNameKey Key = "service_name"
ClusterNameKey Key = "cluster_id"
Comment thread
SVilgelm marked this conversation as resolved.
Comment thread
SVilgelm marked this conversation as resolved.
)

func (k Key) String() string {
Expand All @@ -39,6 +42,7 @@ var logKeys = []Key{
AppNameKey,
JobIDKey,
NamespaceKey,
OrganizationKey,
ExecIDKey,
NodeIDKey,
WorkflowIDKey,
Expand All @@ -48,6 +52,10 @@ var logKeys = []Key{
LaunchPlanIDKey,
ResourceVersionKey,
RequestIDKey,
ProjectKey,
DomainKey,
ServiceNameKey,
ClusterNameKey,
}

// MetricKeysFromStrings is a convenience method to convert a slice of strings into a slice of Keys
Expand Down
9 changes: 9 additions & 0 deletions flytestdlib/contextutils/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,19 @@ func TestWithSignalID(t *testing.T) {
func TestGetFields(t *testing.T) {
ctx := context.Background()
ctx = WithRequestID(WithJobID(WithNamespace(ctx, "ns123"), "job123"), "req123")
ctx = WithProjectDomain(ctx, "proj1", "dev")
ctx = context.WithValue(ctx, OrganizationKey, "org1")
ctx = context.WithValue(ctx, ServiceNameKey, "svc1")
ctx = context.WithValue(ctx, ClusterNameKey, "cluster1")
m := GetLogFields(ctx)
assert.Equal(t, "ns123", m[NamespaceKey.String()])
assert.Equal(t, "job123", m[JobIDKey.String()])
assert.Equal(t, "req123", m[RequestIDKey.String()])
assert.Equal(t, "proj1", m[ProjectKey.String()])
assert.Equal(t, "dev", m[DomainKey.String()])
assert.Equal(t, "org1", m[OrganizationKey.String()])
assert.Equal(t, "svc1", m[ServiceNameKey.String()])
assert.Equal(t, "cluster1", m[ClusterNameKey.String()])
}

func TestValues(t *testing.T) {
Expand Down
Loading