Skip to content

Commit

Permalink
Added another otel.go & 🎨
Browse files Browse the repository at this point in the history
Took 17 minutes
  • Loading branch information
Fank committed Nov 8, 2024
1 parent cc55726 commit 650a0eb
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
5 changes: 3 additions & 2 deletions bitbucket/api_client_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ type Client struct {

// NewRequest creates an API request.
func (c *Client) NewRequest(ctx context.Context, method, urlStr, typ string, body interface{}) (*http.Request, error) {

ctx, span := tracer().Start(ctx, "(*Client).NewRequest")
defer span.End()

Expand Down Expand Up @@ -121,8 +120,10 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr, typ string, bod

// Call executes an API request and returns the response.
func (c *Client) Call(request *http.Request, structure interface{}) (*models.ResponseScheme, error) {
ctx, span := tracer().Start(request.Context(), "(*Client).Call")
defer span.End()

response, err := c.HTTP.Do(request)
response, err := c.HTTP.Do(request.WithContext(ctx))
if err != nil {
return nil, err
}
Expand Down
4 changes: 0 additions & 4 deletions bitbucket/internal/workspace_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ type internalWorkspaceServiceImpl struct {

// Get returns the requested workspace.
func (i *internalWorkspaceServiceImpl) Get(ctx context.Context, workspace string) (*model.WorkspaceScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspaceServiceImpl).Get")
defer span.End()

Expand All @@ -109,7 +108,6 @@ func (i *internalWorkspaceServiceImpl) Get(ctx context.Context, workspace string

// Members returns all members of the requested workspace.
func (i *internalWorkspaceServiceImpl) Members(ctx context.Context, workspace string) (*model.WorkspaceMembershipPageScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspaceServiceImpl).Members")
defer span.End()

Expand All @@ -135,7 +133,6 @@ func (i *internalWorkspaceServiceImpl) Members(ctx context.Context, workspace st

// Membership returns the workspace membership.
func (i *internalWorkspaceServiceImpl) Membership(ctx context.Context, workspace, memberID string) (*model.WorkspaceMembershipScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspaceServiceImpl).Membership")
defer span.End()

Expand Down Expand Up @@ -165,7 +162,6 @@ func (i *internalWorkspaceServiceImpl) Membership(ctx context.Context, workspace

// Projects returns the list of projects in this workspace.
func (i *internalWorkspaceServiceImpl) Projects(ctx context.Context, workspace string) (*model.BitbucketProjectPageScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspaceServiceImpl).Projects")
defer span.End()

Expand Down
10 changes: 4 additions & 6 deletions bitbucket/internal/workspace_permissions_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package internal
import (
"context"
"fmt"
model "github.com/ctreminiom/go-atlassian/v2/pkg/infra/models"
"github.com/ctreminiom/go-atlassian/v2/service"
"github.com/ctreminiom/go-atlassian/v2/service/bitbucket"
"net/http"
"net/url"
"strings"

model "github.com/ctreminiom/go-atlassian/v2/pkg/infra/models"
"github.com/ctreminiom/go-atlassian/v2/service"
"github.com/ctreminiom/go-atlassian/v2/service/bitbucket"
)

// NewWorkspacePermissionService creates a new WorkspacePermissionService instance.
Expand Down Expand Up @@ -72,7 +73,6 @@ type internalWorkspacePermissionServiceImpl struct {
}

func (i *internalWorkspacePermissionServiceImpl) Members(ctx context.Context, workspace, query string) (*model.WorkspaceMembershipPageScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspacePermissionServiceImpl).Members")
defer span.End()

Expand Down Expand Up @@ -106,7 +106,6 @@ func (i *internalWorkspacePermissionServiceImpl) Members(ctx context.Context, wo
}

func (i *internalWorkspacePermissionServiceImpl) Repositories(ctx context.Context, workspace, query, sort string) (*model.RepositoryPermissionPageScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspacePermissionServiceImpl).Repositories")
defer span.End()

Expand Down Expand Up @@ -144,7 +143,6 @@ func (i *internalWorkspacePermissionServiceImpl) Repositories(ctx context.Contex
}

func (i *internalWorkspacePermissionServiceImpl) Repository(ctx context.Context, workspace, repository, query, sort string) (*model.RepositoryPermissionPageScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspacePermissionServiceImpl).Repository")
defer span.End()

Expand Down
5 changes: 0 additions & 5 deletions bitbucket/internal/workspace_webhooks_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ type internalWorkspaceHookServiceImpl struct {
}

func (i *internalWorkspaceHookServiceImpl) Gets(ctx context.Context, workspace string) (*model.WebhookSubscriptionPageScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspaceHookServiceImpl).Gets")
defer span.End()

Expand All @@ -114,7 +113,6 @@ func (i *internalWorkspaceHookServiceImpl) Gets(ctx context.Context, workspace s
}

func (i *internalWorkspaceHookServiceImpl) Create(ctx context.Context, workspace string, payload *model.WebhookSubscriptionPayloadScheme) (*model.WebhookSubscriptionScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspaceHookServiceImpl).Create")
defer span.End()

Expand All @@ -139,7 +137,6 @@ func (i *internalWorkspaceHookServiceImpl) Create(ctx context.Context, workspace
}

func (i *internalWorkspaceHookServiceImpl) Get(ctx context.Context, workspace, webhookID string) (*model.WebhookSubscriptionScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspaceHookServiceImpl).Get")
defer span.End()

Expand Down Expand Up @@ -168,7 +165,6 @@ func (i *internalWorkspaceHookServiceImpl) Get(ctx context.Context, workspace, w
}

func (i *internalWorkspaceHookServiceImpl) Update(ctx context.Context, workspace, webhookID string, payload *model.WebhookSubscriptionPayloadScheme) (*model.WebhookSubscriptionScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspaceHookServiceImpl).Update")
defer span.End()

Expand Down Expand Up @@ -197,7 +193,6 @@ func (i *internalWorkspaceHookServiceImpl) Update(ctx context.Context, workspace
}

func (i *internalWorkspaceHookServiceImpl) Delete(ctx context.Context, workspace, webhookID string) (*model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalWorkspaceHookServiceImpl).Delete")
defer span.End()

Expand Down
6 changes: 4 additions & 2 deletions confluence/api_client_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ type Client struct {
}

func (c *Client) NewRequest(ctx context.Context, method, urlStr, contentType string, body interface{}) (*http.Request, error) {

ctx, span := tracer().Start(ctx, "(*Client).NewRequest")
defer span.End()

// Parse the relative URL.
rel, err := url.Parse(urlStr)
if err != nil {
return nil, err
Expand Down Expand Up @@ -134,8 +134,10 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr, contentType str
}

func (c *Client) Call(request *http.Request, structure interface{}) (*models.ResponseScheme, error) {
ctx, span := tracer().Start(request.Context(), "(*Client).Call")
defer span.End()

response, err := c.HTTP.Do(request)
response, err := c.HTTP.Do(request.WithContext(ctx))
if err != nil {
return nil, err
}
Expand Down
2 changes: 0 additions & 2 deletions confluence/internal/analytics_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ type internalAnalyticsServiceImpl struct {
}

func (i *internalAnalyticsServiceImpl) Get(ctx context.Context, contentID, fromDate string) (*model.ContentViewScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalAnalyticsServiceImpl).Get")
defer span.End()

Expand Down Expand Up @@ -88,7 +87,6 @@ func (i *internalAnalyticsServiceImpl) Get(ctx context.Context, contentID, fromD
}

func (i *internalAnalyticsServiceImpl) Distinct(ctx context.Context, contentID, fromDate string) (*model.ContentViewScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalAnalyticsServiceImpl).Distinct")
defer span.End()

Expand Down
10 changes: 4 additions & 6 deletions confluence/internal/attachment_content_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"bytes"
"context"
"fmt"
model "github.com/ctreminiom/go-atlassian/v2/pkg/infra/models"
"github.com/ctreminiom/go-atlassian/v2/service"
"github.com/ctreminiom/go-atlassian/v2/service/confluence"
"io"
"mime/multipart"
"net/http"
"net/url"
"strconv"
"strings"

model "github.com/ctreminiom/go-atlassian/v2/pkg/infra/models"
"github.com/ctreminiom/go-atlassian/v2/service"
"github.com/ctreminiom/go-atlassian/v2/service/confluence"
)

// NewContentAttachmentService creates a new instance of ContentAttachmentService.
Expand Down Expand Up @@ -81,7 +82,6 @@ type internalContentAttachmentImpl struct {
}

func (i *internalContentAttachmentImpl) Gets(ctx context.Context, contentID string, startAt, maxResults int, options *model.GetContentAttachmentsOptionsScheme) (*model.ContentPageScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalContentAttachmentImpl).Gets")
defer span.End()

Expand Down Expand Up @@ -126,7 +126,6 @@ func (i *internalContentAttachmentImpl) Gets(ctx context.Context, contentID stri
}

func (i *internalContentAttachmentImpl) CreateOrUpdate(ctx context.Context, attachmentID, status, fileName string, file io.Reader) (*model.ContentPageScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalContentAttachmentImpl).CreateOrUpdate")
defer span.End()

Expand Down Expand Up @@ -186,7 +185,6 @@ func (i *internalContentAttachmentImpl) CreateOrUpdate(ctx context.Context, atta
}

func (i *internalContentAttachmentImpl) Create(ctx context.Context, attachmentID, status, fileName string, file io.Reader) (*model.ContentPageScheme, *model.ResponseScheme, error) {

ctx, span := tracer().Start(ctx, "(*internalContentAttachmentImpl).Create")
defer span.End()

Expand Down
12 changes: 12 additions & 0 deletions jira/sm/internal/otel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package internal

Check warning

Code scanning / Revive (reported by Codacy)

should have a package comment Warning

should have a package comment

import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
)

const tracerName = "github.com/ctreminiom/go-atlassian/v2/jira/sm/internal"

func tracer(opts ...trace.TracerOption) trace.Tracer {
return otel.Tracer(tracerName, opts...)
}

0 comments on commit 650a0eb

Please sign in to comment.