Skip to content

Commit

Permalink
feat(client): user-agent telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
Serpentiel committed Apr 9, 2024
1 parent d69a715 commit ea29e75
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
WITH_V: true
DRY_RUN: true
- run: |
tee version.go << END
package aiven
// Version returns aiven-go-client version string
func Version() string {
return "${{ steps.version.outputs.new_tag }}"
}
END
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "chore(version.go): update go-client-codegen version"
git push
- id: sha
run: |
GIT_SHA=$(git rev-parse HEAD)
Expand Down
11 changes: 10 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"os"
"reflect"
"strings"
"time"

"github.com/hashicorp/go-multierror"
Expand Down Expand Up @@ -128,7 +130,14 @@ func (d *aivenClient) do(ctx context.Context, method, path string, v any) (*http
}

req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", d.UserAgent)
req.Header.Set(
"User-Agent",
strings.TrimSpace(fmt.Sprintf(
"go-client-codegen/%s %s",
strings.TrimLeft(Version(), "v"),
d.UserAgent,
)),
)
req.Header.Set("Authorization", "aivenv1 "+d.Token)

// TODO: BAD hack to get around pagination in most cases
Expand Down
6 changes: 6 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package aiven

// Version returns aiven-go-client version string
func Version() string {
return "v0.4.0"
}

0 comments on commit ea29e75

Please sign in to comment.