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

fix: Add missing telemetry for Templates API endpoints #2154

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
4 changes: 2 additions & 2 deletions internal/pkg/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (p *Project) MappersFor(state *state.State) (mapper.Mappers, error) {
return MappersFor(state, p.deps)
}

func (p *Project) LoadState(options loadState.Options, d dependencies) (*State, error) {
func (p *Project) LoadState(ctx context.Context, options loadState.Options, d dependencies) (*State, error) {
p.deps = d

// Use filter from the project manifest
Expand All @@ -106,7 +106,7 @@ func (p *Project) LoadState(options loadState.Options, d dependencies) (*State,
}

// Load state
s, err := loadState.Run(p.ctx, p, loadOptionsWithFilter, d)
s, err := loadState.Run(ctx, p, loadOptionsWithFilter, d)
if err != nil {
return nil, err
}
Expand Down
11 changes: 10 additions & 1 deletion internal/pkg/service/templates/api/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
"github.com/keboola/go-client/pkg/keboola"
"github.com/keboola/go-utils/pkg/deepcopy"
"github.com/spf13/cast"
"go.opentelemetry.io/otel/attribute"

"github.com/keboola/keboola-as-code/internal/pkg/filesystem"
"github.com/keboola/keboola-as-code/internal/pkg/filesystem/aferofs"
"github.com/keboola/keboola-as-code/internal/pkg/log"
"github.com/keboola/keboola-as-code/internal/pkg/model"
"github.com/keboola/keboola-as-code/internal/pkg/project"
"github.com/keboola/keboola-as-code/internal/pkg/service/common/ctxattr"
. "github.com/keboola/keboola-as-code/internal/pkg/service/common/errors"
"github.com/keboola/keboola-as-code/internal/pkg/service/common/etcdop"
"github.com/keboola/keboola-as-code/internal/pkg/service/common/task"
Expand Down Expand Up @@ -212,7 +214,7 @@
prj := project.NewWithManifest(ctx, fs, m)

// Load project state
prjState, err := prj.LoadState(loadState.Options{LoadRemoteState: true}, d)

Check failure on line 217 in internal/pkg/service/templates/api/service/service.go

View workflow job for this annotation

GitHub Actions / E2E: Templates / test

not enough arguments in call to prj.LoadState

Check failure on line 217 in internal/pkg/service/templates/api/service/service.go

View workflow job for this annotation

GitHub Actions / Lint / lint

not enough arguments in call to prj.LoadState
if err != nil {
return task.ErrResult(err)
}
Expand Down Expand Up @@ -318,7 +320,7 @@
prj := project.NewWithManifest(ctx, fs, m)

// Load project state
prjState, err := prj.LoadState(loadState.Options{LoadRemoteState: true}, d)

Check failure on line 323 in internal/pkg/service/templates/api/service/service.go

View workflow job for this annotation

GitHub Actions / E2E: Templates / test

not enough arguments in call to prj.LoadState

Check failure on line 323 in internal/pkg/service/templates/api/service/service.go

View workflow job for this annotation

GitHub Actions / Lint / lint

not enough arguments in call to prj.LoadState
if err != nil {
return task.ErrResult(err)
}
Expand Down Expand Up @@ -365,6 +367,9 @@
}

func (s *service) InstancesIndex(ctx context.Context, d dependencies.ProjectRequestScope, payload *InstancesIndexPayload) (res *Instances, err error) {
_, span := d.Telemetry().Tracer().Start(ctx, "api.server.templates.service.InstancesIndex")
defer span.End(&err)

branchKey, err := getBranch(ctx, d, payload.Branch)
if err != nil {
return nil, err
Expand All @@ -380,8 +385,12 @@
m.Filter().SetAllowedBranches(model.AllowedBranches{model.AllowedBranch(cast.ToString(branchKey.ID))})
prj := project.NewWithManifest(ctx, fs, m)

ctx = ctxattr.ContextWith(ctx,
attribute.String("branch.id", branchKey.ID.String()),
attribute.String("project.id", d.ProjectID().String()),
)
// Load project state
prjState, err := prj.LoadState(loadState.Options{LoadRemoteState: true}, d)
prjState, err := prj.LoadState(ctx, loadState.Options{LoadRemoteState: true}, d)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -409,7 +418,7 @@
prj := project.NewWithManifest(ctx, fs, m)

// Load project state
prjState, err := prj.LoadState(loadState.Options{LoadRemoteState: true}, d)

Check failure on line 421 in internal/pkg/service/templates/api/service/service.go

View workflow job for this annotation

GitHub Actions / E2E: Templates / test

not enough arguments in call to prj.LoadState

Check failure on line 421 in internal/pkg/service/templates/api/service/service.go

View workflow job for this annotation

GitHub Actions / Lint / lint

not enough arguments in call to prj.LoadState
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -804,7 +813,7 @@
prj := project.NewWithManifest(ctx, fs, m)

// Load project state
prjState, err := prj.LoadState(loadState.Options{LoadRemoteState: true}, d)

Check failure on line 816 in internal/pkg/service/templates/api/service/service.go

View workflow job for this annotation

GitHub Actions / E2E: Templates / test

not enough arguments in call to prj.LoadState

Check failure on line 816 in internal/pkg/service/templates/api/service/service.go

View workflow job for this annotation

GitHub Actions / Lint / lint

not enough arguments in call to prj.LoadState
if err != nil {
return nil, branchKey, nil, err
}
Expand Down
Loading