Skip to content

Commit

Permalink
all: prefix span attributes with "achgateway."
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Nov 7, 2023
1 parent e01516f commit 001b4f4
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 58 deletions.
6 changes: 3 additions & 3 deletions internal/audittrail/storage_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func (bs *blobStorage) Close() error {

func (bs *blobStorage) SaveFile(ctx context.Context, path string, data []byte) error {
ctx, span := telemetry.StartSpan(ctx, "audittrail-save-file", trace.WithAttributes(
attribute.String("path", path),
attribute.Int("data_bytes", len(data)),
attribute.String("achgateway.path", path),
attribute.Int("achgateway.data_bytes", len(data)),
))
defer span.End()

Expand Down Expand Up @@ -114,7 +114,7 @@ func (bs *blobStorage) SaveFile(ctx context.Context, path string, data []byte) e

func (bs *blobStorage) GetFile(ctx context.Context, path string) (io.ReadCloser, error) {
ctx, span := telemetry.StartSpan(ctx, "audittrail-get-file", trace.WithAttributes(
attribute.String("path", path),
attribute.String("achgateway.path", path),
))
defer span.End()

Expand Down
8 changes: 4 additions & 4 deletions internal/incoming/odfi/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func deleteFilesOnRemote(ctx context.Context, logger log.Logger, agent upload.Ag
}

ctx, span := telemetry.StartSpan(ctx, "odfi-delete-files-on-remote", trace.WithAttributes(
attribute.String("dir", baseDir),
attribute.Int("files", len(infos)),
attribute.String("achgateway.dir", baseDir),
attribute.Int("achgateway.files", len(infos)),
))
defer span.End()

Expand Down Expand Up @@ -110,8 +110,8 @@ func deleteEmptyFiles(ctx context.Context, logger log.Logger, agent upload.Agent
}

ctx, span := telemetry.StartSpan(ctx, "odfi-delete-empty-files", trace.WithAttributes(
attribute.String("dir", baseDir),
attribute.Int("files", len(entries)),
attribute.String("achgateway.dir", baseDir),
attribute.Int("achgateway.files", len(entries)),
))
defer span.End()

Expand Down
4 changes: 2 additions & 2 deletions internal/incoming/odfi/corrections.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func (pc *correctionProcessor) Handle(ctx context.Context, logger log.Logger, fi
}

ctx, span := telemetry.StartSpan(ctx, "odfi-correction-file", trace.WithAttributes(
attribute.String("filepath", file.Filepath),
attribute.Int("corrections", len(file.ACHFile.NotificationOfChange)),
attribute.String("achgateway.filepath", file.Filepath),
attribute.Int("achgateway.corrections", len(file.ACHFile.NotificationOfChange)),
))
defer span.End()

Expand Down
4 changes: 2 additions & 2 deletions internal/incoming/odfi/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func (d *downloadedFiles) deleteEmptyDirs(ctx context.Context, agent upload.Agen
}

_, span := telemetry.StartSpan(ctx, "odfi-delete-empty-dirs", trace.WithAttributes(
attribute.String("path", path),
attribute.Int("files", len(infos)),
attribute.String("achgateway.path", path),
attribute.Int("achgateway.files", len(infos)),
))
defer span.End()

Expand Down
2 changes: 1 addition & 1 deletion internal/incoming/odfi/incoming.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (pc *incomingEmitter) Handle(ctx context.Context, logger log.Logger, file F
}

ctx, span := telemetry.StartSpan(ctx, "odfi-incoming-file", trace.WithAttributes(
attribute.String("filepath", file.Filepath),
attribute.String("achgateway.filepath", file.Filepath),
))
defer span.End()

Expand Down
2 changes: 1 addition & 1 deletion internal/incoming/odfi/prenotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (pc *prenoteEmitter) Handle(ctx context.Context, logger log.Logger, file Fi
}

ctx, span := telemetry.StartSpan(ctx, "odfi-prenotes-file", trace.WithAttributes(
attribute.String("filepath", file.Filepath),
attribute.String("achgateway.filepath", file.Filepath),
))
defer span.End()

Expand Down
2 changes: 1 addition & 1 deletion internal/incoming/odfi/reconciliation.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (pc *creditReconciliation) Handle(ctx context.Context, logger log.Logger, f
}

ctx, span := telemetry.StartSpan(ctx, "odfi-reconciliation-file", trace.WithAttributes(
attribute.String("filepath", file.Filepath),
attribute.String("achgateway.filepath", file.Filepath),
))
defer span.End()

Expand Down
4 changes: 2 additions & 2 deletions internal/incoming/odfi/returns.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func (pc *returnEmitter) Handle(ctx context.Context, logger log.Logger, file Fil
logger.Log("odfi: processing return file")

ctx, span := telemetry.StartSpan(ctx, "odfi-return-file", trace.WithAttributes(
attribute.String("filename", file.Filepath),
attribute.Int("return_entries", len(file.ACHFile.ReturnEntries)),
attribute.String("achgateway.filename", file.Filepath),
attribute.Int("achgateway.return_entries", len(file.ACHFile.ReturnEntries)),
))
defer span.End()

Expand Down
4 changes: 2 additions & 2 deletions internal/incoming/odfi/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (s *PeriodicScheduler) tickAll() error {
}

ctx, span := telemetry.StartSpan(context.Background(), "odfi-scheduler", trace.WithAttributes(
attribute.String("shard", shardName),
attribute.String("achgateway.shard", shardName),
))
defer span.End()

Expand All @@ -148,7 +148,7 @@ func (s *PeriodicScheduler) tickAll() error {

func (s *PeriodicScheduler) tick(ctx context.Context, logger log.Logger, shard *service.Shard) error {
ctx, span := telemetry.StartSpan(ctx, "odfi-scheduler-tick", trace.WithAttributes(
attribute.String("shard", shard.Name),
attribute.String("achgateway.shard", shard.Name),
))
defer span.End()

Expand Down
8 changes: 4 additions & 4 deletions internal/incoming/web/api_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func (c *FilesController) CreateFileHandler(w http.ResponseWriter, r *http.Reque
}

ctx, span := telemetry.StartSpan(r.Context(), "create-file-handler", trace.WithAttributes(
attribute.String("shardKey", shardKey),
attribute.String("fileID", fileID),
attribute.String("achgateway.shardKey", shardKey),
attribute.String("achgateway.fileID", fileID),
))
defer span.End()

Expand Down Expand Up @@ -161,8 +161,8 @@ func (c *FilesController) CancelFileHandler(w http.ResponseWriter, r *http.Reque
}

ctx, span := telemetry.StartSpan(r.Context(), "cancel-file-handler", trace.WithAttributes(
attribute.String("shardKey", shardKey),
attribute.String("fileID", fileID),
attribute.String("achgateway.shardKey", shardKey),
attribute.String("achgateway.fileID", fileID),
))
defer span.End()

Expand Down
12 changes: 6 additions & 6 deletions internal/pipeline/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ func (xfagg *aggregator) withEachFile(when time.Time) error {
}).Logf("ended %s %s cutoff window processing", window, tzname)

ctx, span := telemetry.StartSpan(context.Background(), "automated-cutoff", trace.WithAttributes(
attribute.String("shard", xfagg.shard.Name),
attribute.String("timezone", tzname),
attribute.String("window", window),
attribute.String("achgateway.shard", xfagg.shard.Name),
attribute.String("achgateway.timezone", tzname),
attribute.String("achgateway.window", window),
))
defer span.End()

Expand All @@ -207,7 +207,7 @@ func (xfagg *aggregator) manualCutoff(waiter manuallyTriggeredCutoff) {
logger.Info().Log("starting manual cutoff window processing")

ctx, span := telemetry.StartSpan(context.Background(), "manual-cutoff", trace.WithAttributes(
attribute.String("shard", xfagg.shard.Name),
attribute.String("achgateway.shard", xfagg.shard.Name),
))
defer span.End()

Expand Down Expand Up @@ -273,8 +273,8 @@ func (xfagg *aggregator) uploadFile(ctx context.Context, index int, agent upload
}

ctx, span := telemetry.StartSpan(ctx, "upload-file", trace.WithAttributes(
attribute.String("filename", filename),
attribute.String("shard", xfagg.shard.Name),
attribute.String("achgateway.filename", filename),
attribute.String("achgateway.shard", xfagg.shard.Name),
))
defer span.End()

Expand Down
2 changes: 1 addition & 1 deletion internal/pipeline/events_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (fr *FileReceiver) manuallyProduceFileUploaded() http.HandlerFunc {
}

ctx, span := telemetry.StartSpan(r.Context(), "pipeline-manual-file-uploaded", trace.WithAttributes(
attribute.String("dir", dir),
attribute.String("achgateway.dir", dir),
))
defer span.End()

Expand Down
26 changes: 13 additions & 13 deletions internal/pipeline/merging.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ func (m *filesystemMerging) isolateMergableDir(ctx context.Context) (string, err
newdir := filepath.Join(fmt.Sprintf("%s-%v", m.shard.Name, time.Now().Format("20060102-150405")))

_, span := telemetry.StartSpan(ctx, "isolate-mergable-dir", trace.WithAttributes(
attribute.String("shard", m.shard.Name),
attribute.String("dir", newdir),
attribute.String("achgateway.shard", m.shard.Name),
attribute.String("achgateway.dir", newdir),
))
defer span.End()

Expand All @@ -152,8 +152,8 @@ func (m *filesystemMerging) isolateMergableDir(ctx context.Context) (string, err

func (m *filesystemMerging) getNonCanceledMatches(ctx context.Context, dir string) ([]string, error) {
_, span := telemetry.StartSpan(ctx, "get-non-canceled-matches", trace.WithAttributes(
attribute.String("shard", m.shard.Name),
attribute.String("dir", dir),
attribute.String("achgateway.shard", m.shard.Name),
attribute.String("achgateway.dir", dir),
))
defer span.End()

Expand All @@ -167,8 +167,8 @@ func (m *filesystemMerging) getNonCanceledMatches(ctx context.Context, dir strin
}

span.SetAttributes(
attribute.Int("positive_matches", len(positiveMatches)),
attribute.Int("negative_matches", len(negativeMatches)),
attribute.Int("achgateway.positive_matches", len(positiveMatches)),
attribute.Int("achgateway.negative_matches", len(negativeMatches)),
)

var out []string
Expand Down Expand Up @@ -259,8 +259,8 @@ func (m *filesystemMerging) WithEachMerged(ctx context.Context, f func(context.C
}

_, span := telemetry.StartSpan(ctx, "with-each-merged", trace.WithAttributes(
attribute.String("shard", m.shard.Name),
attribute.String("dir", dir),
attribute.String("achgateway.shard", m.shard.Name),
attribute.String("achgateway.dir", dir),
))
defer span.End()

Expand Down Expand Up @@ -350,7 +350,7 @@ func (m *filesystemMerging) WithEachMerged(ctx context.Context, f func(context.C
logger.Logf("wrote %d of %d files to remote agent", successfulRemoteWrites, len(files))

span.SetAttributes(
attribute.Int("successful_remote_writes", successfulRemoteWrites),
attribute.Int("achgateway.successful_remote_writes", successfulRemoteWrites),
)

if !el.Empty() {
Expand Down Expand Up @@ -379,10 +379,10 @@ func makeIndices(total, groups int) []int {
}

func (m *filesystemMerging) chunkFilesTogether(ctx context.Context, indices []int, matches []string, conditions ach.Conditions) ([]*ach.File, error) {
_, span := telemetry.StartSpan(context.Background(), "chunk-files-together", trace.WithAttributes(
attribute.String("shard", m.shard.Name),
attribute.Int("indices_num", len(indices)),
attribute.Int("matches", len(matches)),
_, span := telemetry.StartSpan(ctx, "chunk-files-together", trace.WithAttributes(
attribute.String("achgateway.shard", m.shard.Name),
attribute.Int("achgateway.indices_num", len(indices)),
attribute.Int("achgateway.matches", len(matches)),
))
defer span.End()

Expand Down
16 changes: 8 additions & 8 deletions internal/upload/ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ func (agent *FTPTransferAgent) Hostname() string {

func (agent *FTPTransferAgent) Delete(ctx context.Context, path string) error {
_, span := telemetry.StartSpan(ctx, "agent-ftp-delete", trace.WithAttributes(
attribute.String("hostname", agent.Hostname()),
attribute.String("path", path),
attribute.String("achgateway.hostname", agent.Hostname()),
attribute.String("achgateway.path", path),
))
defer span.End()

Expand All @@ -136,8 +136,8 @@ func (agent *FTPTransferAgent) UploadFile(ctx context.Context, f File) error {
pathToWrite := filepath.Join(agent.OutboundPath(), f.Filepath)

_, span := telemetry.StartSpan(ctx, "agent-ftp-upload", trace.WithAttributes(
attribute.String("hostname", agent.Hostname()),
attribute.String("path", pathToWrite),
attribute.String("achgateway.hostname", agent.Hostname()),
attribute.String("achgateway.path", pathToWrite),
))
defer span.End()

Expand All @@ -146,8 +146,8 @@ func (agent *FTPTransferAgent) UploadFile(ctx context.Context, f File) error {

func (agent *FTPTransferAgent) ReadFile(ctx context.Context, path string) (*File, error) {
_, span := telemetry.StartSpan(ctx, "agent-ftp-read", trace.WithAttributes(
attribute.String("hostname", agent.Hostname()),
attribute.String("path", path),
attribute.String("achgateway.hostname", agent.Hostname()),
attribute.String("achgateway.path", path),
))
defer span.End()

Expand Down Expand Up @@ -175,8 +175,8 @@ func (agent *FTPTransferAgent) GetReturnFiles(ctx context.Context) ([]string, er

func (agent *FTPTransferAgent) readFilepaths(ctx context.Context, dir string) ([]string, error) {
_, span := telemetry.StartSpan(ctx, "agent-ftp-list", trace.WithAttributes(
attribute.String("hostname", agent.Hostname()),
attribute.String("path", dir),
attribute.String("achgateway.hostname", agent.Hostname()),
attribute.String("achgateway.path", dir),
))
defer span.End()

Expand Down
16 changes: 8 additions & 8 deletions internal/upload/sftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func (agent *SFTPTransferAgent) Hostname() string {

func (agent *SFTPTransferAgent) Delete(ctx context.Context, path string) error {
_, span := telemetry.StartSpan(ctx, "agent-sftp-delete", trace.WithAttributes(
attribute.String("hostname", agent.Hostname()),
attribute.String("path", path),
attribute.String("achgateway.hostname", agent.Hostname()),
attribute.String("achgateway.path", path),
))
defer span.End()

Expand All @@ -117,8 +117,8 @@ func (agent *SFTPTransferAgent) UploadFile(ctx context.Context, f File) error {
pathToWrite := filepath.Join(agent.OutboundPath(), filepath.Base(f.Filepath))

_, span := telemetry.StartSpan(ctx, "agent-sftp-upload", trace.WithAttributes(
attribute.String("hostname", agent.Hostname()),
attribute.String("path", pathToWrite),
attribute.String("achgateway.hostname", agent.Hostname()),
attribute.String("achgateway.path", pathToWrite),
))
defer span.End()

Expand All @@ -127,8 +127,8 @@ func (agent *SFTPTransferAgent) UploadFile(ctx context.Context, f File) error {

func (agent *SFTPTransferAgent) ReadFile(ctx context.Context, path string) (*File, error) {
_, span := telemetry.StartSpan(ctx, "agent-sftp-read", trace.WithAttributes(
attribute.String("hostname", agent.Hostname()),
attribute.String("path", path),
attribute.String("achgateway.hostname", agent.Hostname()),
attribute.String("achgateway.path", path),
))
defer span.End()

Expand Down Expand Up @@ -156,8 +156,8 @@ func (agent *SFTPTransferAgent) GetReturnFiles(ctx context.Context) ([]string, e

func (agent *SFTPTransferAgent) readFilepaths(ctx context.Context, dir string) ([]string, error) {
_, span := telemetry.StartSpan(ctx, "agent-sftp-list", trace.WithAttributes(
attribute.String("hostname", agent.Hostname()),
attribute.String("path", dir),
attribute.String("achgateway.hostname", agent.Hostname()),
attribute.String("achgateway.path", dir),
))
defer span.End()

Expand Down

0 comments on commit 001b4f4

Please sign in to comment.