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

Adds date label to benthos metrics #2698

Merged
merged 3 commits into from
Sep 16, 2024
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
7 changes: 7 additions & 0 deletions backend/pkg/metrics/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ const (
TableNameLabel = "tableName"
JobTypeLabel = "jobType"
IsUpdateConfigLabel = "isUpdateConfig"

NeosyncDateLabel = "date"
NeosyncDateFormat = "2006-01-02"

TemporalWorkflowIdEnvKey = "TEMPORAL_WORKFLOW_ID"
TemporalRunIdEnvKey = "TEMPORAL_ENV_ID"
NeosyncDateEnvKey = "NEOSYNC_DATE"
)

func NewEqLabel(key, value string) MetricLabel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@
labels := metrics.MetricLabels{
metrics.NewEqLabel(metrics.AccountIdLabel, job.AccountId),
metrics.NewEqLabel(metrics.JobIdLabel, job.Id),
metrics.NewEqLabel(metrics.TemporalWorkflowId, "${TEMPORAL_WORKFLOW_ID}"),
metrics.NewEqLabel(metrics.TemporalRunId, "${TEMPORAL_RUN_ID}"),
metrics.NewEqLabel(metrics.TemporalWorkflowId, withEnvInterpolation(metrics.TemporalWorkflowIdEnvKey)),
metrics.NewEqLabel(metrics.TemporalRunId, withEnvInterpolation(metrics.TemporalRunIdEnvKey)),
metrics.NewEqLabel(metrics.NeosyncDateLabel, withEnvInterpolation(metrics.NeosyncDateEnvKey)),

Check warning on line 261 in worker/pkg/workflows/datasync/activities/gen-benthos-configs/benthos-builder.go

View check run for this annotation

Codecov / codecov/patch

worker/pkg/workflows/datasync/activities/gen-benthos-configs/benthos-builder.go#L259-L261

Added lines #L259 - L261 were not covered by tests
}
for _, resp := range responses {
joinedLabels := append(labels, resp.metriclabels...) //nolint:gocritic
Expand Down Expand Up @@ -292,6 +293,10 @@
}, nil
}

func withEnvInterpolation(input string) string {
return fmt.Sprintf("${%s}", input)

Check warning on line 297 in worker/pkg/workflows/datasync/activities/gen-benthos-configs/benthos-builder.go

View check run for this annotation

Codecov / codecov/patch

worker/pkg/workflows/datasync/activities/gen-benthos-configs/benthos-builder.go#L296-L297

Added lines #L296 - L297 were not covered by tests
}

// tries to get destination schema column info map
// if not uses source destination schema column info map
func (b *benthosBuilder) GetSqlSchemaColumnMap(
Expand Down
6 changes: 4 additions & 2 deletions worker/pkg/workflows/datasync/activities/sync/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
_ "github.com/warpstreamlabs/bento/public/components/sql"

neosynclogger "github.com/nucleuscloud/neosync/backend/pkg/logger"
"github.com/nucleuscloud/neosync/backend/pkg/metrics"
connectiontunnelmanager "github.com/nucleuscloud/neosync/worker/internal/connection-tunnel-manager"
"github.com/nucleuscloud/neosync/worker/internal/connection-tunnel-manager/providers"
"github.com/nucleuscloud/neosync/worker/internal/connection-tunnel-manager/providers/mongoprovider"
Expand Down Expand Up @@ -279,8 +280,9 @@ func (a *Activity) Sync(ctx context.Context, req *SyncRequest, metadata *SyncMet
}

envKeyMap := syncMapToStringMap(&envKeyDsnSyncMap)
envKeyMap["TEMPORAL_WORKFLOW_ID"] = info.WorkflowExecution.ID
envKeyMap["TEMPORAL_RUN_ID"] = info.WorkflowExecution.RunID
envKeyMap[metrics.TemporalWorkflowIdEnvKey] = info.WorkflowExecution.ID
envKeyMap[metrics.TemporalRunIdEnvKey] = info.WorkflowExecution.RunID
envKeyMap[metrics.NeosyncDateEnvKey] = time.Now().UTC().Format(metrics.NeosyncDateFormat)

streamBuilderMu.Lock()
streambldr := benthosenv.NewStreamBuilder()
Expand Down
Loading