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

feat(instrumentation): add snyk-request-id header to interaction request CLI-325 #5243

Closed
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
25 changes: 17 additions & 8 deletions cliv2/cmd/cliv2/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

// !!! This import needs to be the first import, please do not change this !!!
import _ "github.com/snyk/go-application-framework/pkg/networking/fips_enable"

import (
"context"
"encoding/json"
Expand All @@ -14,10 +12,8 @@ import (
"strings"
"time"

"github.com/hashicorp/go-uuid"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/snyk/cli-extension-dep-graph/pkg/depgraph"
"github.com/snyk/cli-extension-iac-rules/iacrules"
"github.com/snyk/cli-extension-sbom/pkg/sbom"
Expand All @@ -26,6 +22,10 @@ import (
"github.com/snyk/go-application-framework/pkg/app"
"github.com/snyk/go-application-framework/pkg/auth"
"github.com/snyk/go-application-framework/pkg/configuration"
_ "github.com/snyk/go-application-framework/pkg/networking/fips_enable"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

localworkflows "github.com/snyk/go-application-framework/pkg/local_workflows"
"github.com/snyk/go-application-framework/pkg/local_workflows/content_type"
"github.com/snyk/go-application-framework/pkg/local_workflows/json_schemas"
Expand All @@ -35,12 +35,12 @@ import (
"github.com/snyk/go-application-framework/pkg/workflow"
"github.com/snyk/go-httpauth/pkg/httpauth"
"github.com/snyk/snyk-iac-capture/pkg/capture"
snykls "github.com/snyk/snyk-ls/ls_extension"

"github.com/snyk/go-application-framework/pkg/ui"

"github.com/snyk/cli/cliv2/internal/cliv2"
"github.com/snyk/cli/cliv2/internal/constants"
"github.com/snyk/go-application-framework/pkg/ui"
snykls "github.com/snyk/snyk-ls/ls_extension"

cli_errors "github.com/snyk/cli/cliv2/internal/errors"
"github.com/snyk/cli/cliv2/pkg/basic_workflows"
)
Expand Down Expand Up @@ -463,6 +463,15 @@ func MainWithErrorCode() int {
networking.UaWithOS(internalOS)).String(),
)

// Generate interaction UUID
interactionId, err := uuid.GenerateUUID()
if err != nil {
globalLogger.Print("Failed to generate interaction UUID!", err)
} else {
// Add interaction id to request header
networkAccess.AddHeaderField("snyk-request-id", interactionId)
}

if debugEnabled {
writeLogHeader(globalConfiguration, networkAccess)
}
Expand Down
Loading