Skip to content

Commit

Permalink
fix: some test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Lifosmin Simon committed Oct 21, 2024
1 parent 147f725 commit ee217c7
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/gate/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewClient(baseURL string, opts ...ClientOption) (*Client, error) {
client := &Client{
baseURL: url,
options: &options{
httpClient: opentelemetry.NewHttpClient(context.Background(), "GateClient"),
httpClient: opentelemetry.NewHttpClient("GateClient"),
},
}
for _, o := range opts {
Expand Down
13 changes: 1 addition & 12 deletions pkg/opentelemetry/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.20.0"
"google.golang.org/api/option"
"google.golang.org/api/transport"
"google.golang.org/grpc/encoding/gzip"
)

Expand Down Expand Up @@ -130,21 +128,12 @@ func initGlobalTracer(ctx context.Context, res *resource.Resource, cfg Config) (
}, nil
}

func NewHttpClient(ctx context.Context, name string, opts ...option.ClientOption) *http.Client {
func NewHttpClient(name string) *http.Client {
otelOpts := []otelhttp.Option{
otelhttp.WithSpanNameFormatter(func(operation string, r *http.Request) string {
return fmt.Sprintf("%s %s", name, operation)
}),
}
if len(opts) > 0 {
credsClient, _, err := transport.NewHTTPClient(ctx, opts...)
if err != nil {
return nil
}

credsClient.Transport = otelhttp.NewTransport(credsClient.Transport, otelOpts...)
return credsClient
}

return &http.Client{
Transport: otelhttp.NewTransport(http.DefaultTransport, otelOpts...),
Expand Down
2 changes: 1 addition & 1 deletion plugins/providers/bigquery/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ func (s *BigQueryProviderTestSuite) TestListAccess() {
},
}, []*domain.Resource{})

s.EqualError(err, "initializing bigquery client: invalid character 'i' looking for beginning of value")
s.EqualError(err, "initializing bigquery client: failed to obtain credentials: invalid character 'i' looking for beginning of value")
})

s.Run("return nil error on success", func() {
Expand Down
3 changes: 1 addition & 2 deletions plugins/providers/grafana/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package grafana

import (
"bytes"
"context"
b64 "encoding/base64"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -63,7 +62,7 @@ func NewClient(config *ClientConfig) (*client, error) {

httpClient := config.HTTPClient
if httpClient == nil {
httpClient = opentelemetry.NewHttpClient(context.Background(), "GrafanaHttpClient", nil)
httpClient = opentelemetry.NewHttpClient("GrafanaHttpClient")
}

baseURL, err := url.Parse(config.Host)
Expand Down
2 changes: 1 addition & 1 deletion plugins/providers/metabase/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func NewClient(config *ClientConfig, logger log.Logger) (*client, error) {

httpClient := config.HTTPClient
if httpClient == nil {
httpClient = opentelemetry.NewHttpClient(context.Background(), "MetabaseHttpClient", nil)
httpClient = opentelemetry.NewHttpClient("MetabaseHttpClient")
}

c := &client{
Expand Down
2 changes: 1 addition & 1 deletion plugins/providers/shield/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func NewClient(config *ClientConfig, logger log.Logger) (*client, error) {

httpClient := config.HTTPClient
if httpClient == nil {
httpClient = opentelemetry.NewHttpClient(context.Background(), "ShieldHttpClient", nil)
httpClient = opentelemetry.NewHttpClient("ShieldHttpClient")
}

c := &client{
Expand Down
3 changes: 1 addition & 2 deletions plugins/providers/tableau/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tableau

import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -604,7 +603,7 @@ func NewClient(config *ClientConfig) (*client, error) {

httpClient := config.HTTPClient
if httpClient == nil {
httpClient = opentelemetry.NewHttpClient(context.Background(), "TableauHttpClient", nil)
httpClient = opentelemetry.NewHttpClient("TableauHttpClient")
}

c := &client{
Expand Down

0 comments on commit ee217c7

Please sign in to comment.