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

Add a little bit more tracing to enrollment #1564

Merged
merged 2 commits into from
Jan 30, 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
4 changes: 4 additions & 0 deletions pkg/osquery/enrollment_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ import (
"github.com/kolide/launcher/ee/agent"
"github.com/kolide/launcher/pkg/osquery/runsimple"
"github.com/kolide/launcher/pkg/service"
"github.com/kolide/launcher/pkg/traces"
"github.com/pkg/errors"
)

func getEnrollDetails(ctx context.Context, osquerydPath string) (service.EnrollmentDetails, error) {
ctx, span := traces.StartSpan(ctx)
defer span.End()

var details service.EnrollmentDetails

// To facilitate manual testing around missing enrollment details,
Expand Down
5 changes: 5 additions & 0 deletions pkg/osquery/runsimple/osqueryrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"io"
"os/exec"
"runtime"

"github.com/kolide/launcher/pkg/traces"
)

// osqueryProcess is a very simple osquery runtime manager. It's designed to start and stop osquery. It has
Expand Down Expand Up @@ -72,6 +74,9 @@ func NewOsqueryProcess(osquerydPath string, opts ...osqueryProcessOpt) (*osquery
// trailing semicolon, but it's real weird about line breaks, an may return as multiline json output. It
// is the responsibility of the caller to get the details right.
func (p osqueryProcess) RunSql(ctx context.Context, sql []byte) error {
ctx, span := traces.StartSpan(ctx)
defer span.End()

args := []string{
"-S",
"--config_path", "/dev/null",
Expand Down
4 changes: 4 additions & 0 deletions pkg/service/request_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/kolide/kit/contexts/uuid"

pb "github.com/kolide/launcher/pkg/pb/launcher"
"github.com/kolide/launcher/pkg/traces"
)

type configRequest struct {
Expand Down Expand Up @@ -108,6 +109,9 @@ func MakeRequestConfigEndpoint(svc KolideService) endpoint.Endpoint {

// RequestConfig implements KolideService.RequestConfig.
func (e Endpoints) RequestConfig(ctx context.Context, nodeKey string) (string, bool, error) {
ctx, span := traces.StartSpan(ctx)
defer span.End()

newCtx, cancel := context.WithTimeout(ctx, requestTimeout)
defer cancel()
request := configRequest{NodeKey: nodeKey}
Expand Down
4 changes: 4 additions & 0 deletions pkg/service/request_enrollment.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/kolide/kit/contexts/uuid"

pb "github.com/kolide/launcher/pkg/pb/launcher"
"github.com/kolide/launcher/pkg/traces"
)

type enrollmentRequest struct {
Expand Down Expand Up @@ -168,6 +169,9 @@ const requestTimeout = 60 * time.Second

// RequestEnrollment implements KolideService.RequestEnrollment
func (e Endpoints) RequestEnrollment(ctx context.Context, enrollSecret, hostIdentifier string, details EnrollmentDetails) (string, bool, error) {
ctx, span := traces.StartSpan(ctx)
defer span.End()

newCtx, cancel := context.WithTimeout(ctx, requestTimeout)
defer cancel()

Expand Down
Loading