storage

package
v0.0.0-...-9bf41b3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2022 License: MIT Imports: 13 Imported by: 0

README

Instana instrumentation for Google Cloud Storage

This module contains instrumentation code for Google Cloud Storage clients that use cloud.google.com/go/storage library starting from v1.7.0 and above.

GoDoc

Installation

To add the module to your go.mod file run the following command in your project directory:

$ go get github.com/mier85/go-sensor/instrumentation/cloud.google.com/go/storage

Usage

This module is a drop-in replacement for cloud.google.com/go/storage. However, if your code references any value types, e.g. cloud.google.com/go/storage.ObjectAttrs, you might need to add a named import for the original library as well.

The instrumentation is implemented as a thin wrapper around service object methods and does not change their behavior. Thus, any limitations/usage patterns/recommendations for the original method also apply to the wrapped one.

In most cases changing the import path of cloud.google.com/go/storage should be enough:

package main

import (
	"google.golang.org/api/iterator"
	"github.com/mier85/go-sensor/instrumentation/cloud.google.com/go/storage" // replaces "cloud.google.com/go/storage"
	gstorage "cloud.google.com/go/storage" // in case your code references value types
)

func main() {
	c, _ := storage.NewClient(context.Background()) // creates an instrumented GCS client

	// use wrapped client as usual
	it := c.Buckets(context.Background(), "my-gcp-project")
	for {
	    bucket, err := buckets.Next()
		if err != nil {
			if err == iterator.Done {
				break
			}
		}

		// process bucket
	}
}

Documentation

Overview

Package storage provides Instana tracing instrumentation for Google Cloud Storage clients that use cloud.google.com/go/storage

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ACLHandle

type ACLHandle struct {
	*storage.ACLHandle
	Bucket  string
	Object  string
	Default bool
}

ACLHandle is an instrumented wrapper for cloud.google.com/go/storage.ACLHandle that traces calls made to Google Cloud Storage API.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ACLHandle for further details on wrapped type.

func (*ACLHandle) Delete

func (a *ACLHandle) Delete(ctx context.Context, entity storage.ACLEntity) (err error)

Delete calls and traces the Delete() method of the wrapped cloud.google.com/go/storage.ACLHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ACLHandle.Delete for further details on wrapped method.

func (*ACLHandle) List

func (a *ACLHandle) List(ctx context.Context) (rules []storage.ACLRule, err error)

List calls and traces the List() method of the wrapped cloud.google.com/go/storage.ACLHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ACLHandle.List for further details on wrapped method.

func (*ACLHandle) Set

func (a *ACLHandle) Set(ctx context.Context, entity storage.ACLEntity, role storage.ACLRole) (err error)

Set calls and traces the Set() method of the wrapped cloud.google.com/go/storage.ACLHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ACLHandle.Set for further details on wrapped method.

type BucketHandle

type BucketHandle struct {
	*storage.BucketHandle
	Name string
}

BucketHandle is an instrumented wrapper for cloud.google.com/go/storage.BucketHandle that traces calls made to Google Cloud Storage API.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle for further details on wrapped type.

func (*BucketHandle) ACL

func (b *BucketHandle) ACL() *ACLHandle

ACL returns an instrumented cloud.google.com/go/storage.ACLHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.ACL for further details on wrapped method.

func (*BucketHandle) Attrs

func (b *BucketHandle) Attrs(ctx context.Context) (attrs *storage.BucketAttrs, err error)

Attrs calls and traces the Attrs() method of the wrapped cloud.google.com/go/storage.BucketHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.Attrs for further details on wrapped method.

func (*BucketHandle) Create

func (b *BucketHandle) Create(ctx context.Context, projectID string, attrs *storage.BucketAttrs) (err error)

Create calls and traces the Create() method of the wrapped cloud.google.com/go/storage.BucketHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.Create for further details on wrapped method.

func (*BucketHandle) DefaultObjectACL

func (b *BucketHandle) DefaultObjectACL() *ACLHandle

DefaultObjectACL returns an instrumented cloud.google.com/go/storage.ACLHandle, which provides access to the bucket's default object ACLs.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.DefaultObjectACL for further details on wrapped method.

func (*BucketHandle) Delete

func (b *BucketHandle) Delete(ctx context.Context) (err error)

Delete calls and traces the Delete() method of the wrapped cloud.google.com/go/storage.BucketHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.Delete for further details on wrapped method.

func (*BucketHandle) IAM

func (b *BucketHandle) IAM() *iam.Handle

IAM returns an instrumented wrapper for cloud.google.com/go/iam.Handle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.IAM for further details on wrapped method.

func (*BucketHandle) If

If returns an instrumented cloud.google.com/go/storage.BucketHandle that applies a set of preconditions.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.If for further details on wrapped method.

func (*BucketHandle) LockRetentionPolicy

func (b *BucketHandle) LockRetentionPolicy(ctx context.Context) (err error)

LockRetentionPolicy calls and traces the LockRetentionPolicy() method of the wrapped cloud.google.com/go/storage.BucketHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.LockRetentionPolicy for further details on wrapped method.

func (*BucketHandle) Object

func (b *BucketHandle) Object(name string) *ObjectHandle

Object returns an instrumented cloud.google.com/go/storage.ObjectHandle, which provides operations on the named object.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.Object for further details on wrapped method.

func (*BucketHandle) Objects

func (b *BucketHandle) Objects(ctx context.Context, q *storage.Query) *ObjectIterator

Objects returns an instrumented object iterator that traces and proxies requests to the underlying cloud.google.com/go/storage.ObjectIterator.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.Objects for further details on wrapped method.

func (*BucketHandle) Update

func (b *BucketHandle) Update(ctx context.Context, uattrs storage.BucketAttrsToUpdate) (attrs *storage.BucketAttrs, err error)

Update calls and traces the Update() method of the wrapped cloud.google.com/go/storage.BucketHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.Update for further details on wrapped method.

func (*BucketHandle) UserProject

func (b *BucketHandle) UserProject(projectID string) *BucketHandle

UserProject returns an instrumented cloud.google.com/go/storage.BucketHandle that passes the project ID as the user project for all subsequent calls.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketHandle.UserProject for further details on wrapped method.

type BucketIterator

type BucketIterator struct {
	*storage.BucketIterator
	// contains filtered or unexported fields
}

BucketIterator is an instrumented wrapper for cloud.google.com/go/storage.BucketIterator.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketIterator for further details on wrapped type.

func (*BucketIterator) Next

func (it *BucketIterator) Next() (attrs *storage.BucketAttrs, err error)

Next calls the Next() method of the wrapped iterator and creates a span for each call that results in an API request.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#BucketIterator.Next for further details on wrapped method.

type Client

type Client struct {
	*storage.Client
}

Client is an instrumented wrapper for cloud.google.com/go/storage.Client that traces calls made to Google Cloud Storage API.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Client for further details on wrapped type.

func NewClient

func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error)

NewClient returns a new wrapped cloud.google.com/go/storage.Client.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#NewClient for further details on wrapped method.

func (*Client) Bucket

func (c *Client) Bucket(name string) *BucketHandle

Bucket returns an instrumented cloud.google.com/go/storage.BucketHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Client.Bucket for further details on wrapped method.

func (*Client) Buckets

func (c *Client) Buckets(ctx context.Context, projectID string) *BucketIterator

Buckets returns an instrumented bucket iterator that traces and proxies requests to the underlying cloud.google.com/go/storage.BucketIterator.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Client.Buckets for further details on wrapped method.

func (*Client) CreateHMACKey

func (c *Client) CreateHMACKey(ctx context.Context, projectID, serviceAccountEmail string, opts ...storage.HMACKeyOption) (hk *storage.HMACKey, err error)

CreateHMACKey calls and traces the CreateHMACKey() method of the wrapped cloud.google.com/go/storage.Client.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Client.CreateHMACKey for further details on wrapped method.

func (*Client) HMACKeyHandle

func (c *Client) HMACKeyHandle(projectID, accessID string) *HMACKeyHandle

HMACKeyHandle returns an instrumented cloud.google.com/go/storage.HMACKeyHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Client.HMACKeyHandle for further details on wrapped method.

func (*Client) ListHMACKeys

func (c *Client) ListHMACKeys(ctx context.Context, projectID string, opts ...storage.HMACKeyOption) *HMACKeysIterator

ListHMACKeys returns an instrumented object iterator that traces and proxies requests to the underlying cloud.google.com/go/storage.HMACKeysIterator.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Client.ListHMACKeys for further details on wrapped method.

func (*Client) ServiceAccount

func (c *Client) ServiceAccount(ctx context.Context, projectID string) (email string, err error)

ServiceAccount calls and traces the ServiceAccount() method of the wrapped cloud.google.com/go/storage.Client.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Client.ServiceAccount for further details on wrapped method.

type Composer

type Composer struct {
	*storage.Composer
	DestinationBucket, DestinationName string
	SourceObjects                      []string
}

Composer is an instrumented wrapper for cloud.google.com/go/storage.Composer. that traces calls made to Google Cloud Storage API

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Composer for further details on wrapped type.

func (*Composer) Run

func (c *Composer) Run(ctx context.Context) (attrs *storage.ObjectAttrs, err error)

Run calls and traces the Run() method of the wrapped cloud.google.com/go/storage.Composer.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Composer.Run for further details on wrapped method.

type Copier

type Copier struct {
	*storage.Copier
	SourceBucket, SourceName           string
	DestinationBucket, DestinationName string
}

Copier is an instrumented wrapper for cloud.google.com/go/storage.Copier that traces calls made to Google Cloud Storage API.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Copier for further details on wrapped type.

func (*Copier) Run

func (c *Copier) Run(ctx context.Context) (attrs *storage.ObjectAttrs, err error)

Run calls and traces the Run() method of the wrapped Copier.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Copier.Run for further details on wrapped method.

type HMACKeyHandle

type HMACKeyHandle struct {
	*storage.HMACKeyHandle
	ProjectID string
	AccessID  string
}

HMACKeyHandle is an instrumented wrapper for cloud.google.com/go/storage.HMACKeyHandle that traces calls made to Google Cloud Storage API.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#HMACKeyHandle for further details on wrapped type.

func (*HMACKeyHandle) Delete

func (hkh *HMACKeyHandle) Delete(ctx context.Context, opts ...storage.HMACKeyOption) (err error)

Delete calls and traces the Delete() method of the wrapped cloud.google.com/go/storage.HMACKeyHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#HMACKeyHandle.Delete for further details on wrapped method.

func (*HMACKeyHandle) Get

func (hkh *HMACKeyHandle) Get(ctx context.Context, opts ...storage.HMACKeyOption) (hk *storage.HMACKey, err error)

Get calls and traces the Get() method of the wrapped cloud.google.com/go/storage.HMACKeyHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#HMACKeyHandle.Get for further details on wrapped method.

func (*HMACKeyHandle) Update

Update calls and traces the Update() method of the wrapped cloud.google.com/go/storage.HMACKeyHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#HMACKeyHandle.Update for further details on wrapped method.

type HMACKeysIterator

type HMACKeysIterator struct {
	*storage.HMACKeysIterator
	ProjectID string
	// contains filtered or unexported fields
}

HMACKeysIterator is an instrumented wrapper for cloud.google.com/go/storage.HMACKeysIterator that traces calls made to Google Cloud Storage API.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#HMACKeysIterator for further details on wrapped type.

func (*HMACKeysIterator) Next

func (it *HMACKeysIterator) Next() (hk *storage.HMACKey, err error)

Next calls the Next() method of the wrapped iterator and creates a span for each call that results in an API request.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#HMACKeysIterator.Next for further details on wrapped method.

type ObjectHandle

type ObjectHandle struct {
	*storage.ObjectHandle
	Bucket string
	Name   string
}

ObjectHandle is an instrumented wrapper for cloud.google.com/go/storage.ObjectHandle that traces calls made to Google Cloud Storage API.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle for further details on wrapped type.

func (*ObjectHandle) ACL

func (o *ObjectHandle) ACL() *ACLHandle

ACL returns an instrumented cloud.google.com/go/storage.ACLHandle that provides access to the object's access control list.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.ACL for further details on wrapped method.

func (*ObjectHandle) Attrs

func (o *ObjectHandle) Attrs(ctx context.Context) (attrs *storage.ObjectAttrs, err error)

Attrs calls and traces the Attrs() method of the wrapped cloud.google.com/go/storage.ObjectHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.Attrs for further details on wrapped method.

func (*ObjectHandle) ComposerFrom

func (o *ObjectHandle) ComposerFrom(srcs ...*ObjectHandle) *Composer

ComposerFrom returns an instrumented cloud.google.com/go/storage.Composer.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.ComposerFrom for further details on wrapped method.

func (*ObjectHandle) CopierFrom

func (o *ObjectHandle) CopierFrom(src *ObjectHandle) *Copier

CopierFrom returns an instrumented cloud.google.com/go/storage.Copier.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.CopierFrom for further details on wrapped method.

func (*ObjectHandle) Delete

func (o *ObjectHandle) Delete(ctx context.Context) (err error)

Delete calls and traces the Delete() method of the wrapped cloud.google.com/go/storage.ObjectHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.Delete for further details on wrapped method.

func (*ObjectHandle) Generation

func (o *ObjectHandle) Generation(gen int64) *ObjectHandle

Generation returns an instrumented cloud.google.com/go/storage.ObjectHandle that operates on a specific generation of the object.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.Generation for further details on wrapped method.

func (*ObjectHandle) If

If returns an instrumented cloud.google.com/go/storage.ObjectHandle that applies a set of preconditions.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.If for further details on wrapped method.

func (*ObjectHandle) Key

func (o *ObjectHandle) Key(encryptionKey []byte) *ObjectHandle

Key returns an instrumented cloud.google.com/go/storage.ObjectHandle that uses the supplied encryption key to encrypt and decrypt the object's contents.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.Key for further details on wrapped method.

func (*ObjectHandle) NewRangeReader

func (o *ObjectHandle) NewRangeReader(ctx context.Context, offset, length int64) (r *Reader, err error)

NewRangeReader returns an instrumented wrapper for cloud.google.com/go/storage.Reader that reads the object partially.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.NewRangeReader for further details on wrapped method.

func (*ObjectHandle) NewReader

func (o *ObjectHandle) NewReader(ctx context.Context) (*Reader, error)

NewReader returns an instrumented wrapper for cloud.google.com/go/storage.Reader for an object.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.NewReader for further details on wrapped method.

func (*ObjectHandle) NewWriter

func (o *ObjectHandle) NewWriter(ctx context.Context) *Writer

NewWriter returns an instrumented cloud.google.com/go/storage.Writer that traces calls made to Google Cloud Storage API.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.NewWriter for further details on wrapped method.

func (*ObjectHandle) ReadCompressed

func (o *ObjectHandle) ReadCompressed(compressed bool) *ObjectHandle

ReadCompressed returns an instrumented cloud.google.com/go/storage.ObjectHandle that performs reads without decompressing when given true as an argument.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.ReadCompressed for further details on wrapped method.

func (*ObjectHandle) Update

func (o *ObjectHandle) Update(ctx context.Context, uattrs storage.ObjectAttrsToUpdate) (oa *storage.ObjectAttrs, err error)

Update calls and traces the Update() method of the wrapped cloud.google.com/go/storage.ObjectHandle.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectHandle.Update for further details on wrapped method.

type ObjectIterator

type ObjectIterator struct {
	*storage.ObjectIterator
	Bucket string
	// contains filtered or unexported fields
}

ObjectIterator is an instrumented wrapper for cloud.google.com/go/storage.ObjectIterator that traces calls made to Google Cloud Storage API.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectIterator for further details on wrapped type.

func (*ObjectIterator) Next

func (it *ObjectIterator) Next() (attrs *storage.ObjectAttrs, err error)

Next calls the Next() method of the wrapped iterator and creates a span for each call that results in an API request.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#ObjectIterator.Next for further details on wrapped method.

type Reader

type Reader struct {
	*storage.Reader

	Bucket string
	Name   string
	// contains filtered or unexported fields
}

Reader is an instrumented wrapper for cloud.google.com/go/storage.Reader that traces calls made to Google Cloud Storage API.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Reader for further details on wrapped type.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read calls and traces the Read() method of the wrapped cloud.google.com/go.Reader.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Reader.Read for further details on wrapped method.

type Writer

type Writer struct {
	*storage.Writer
	Bucket string
	// contains filtered or unexported fields
}

Writer is an instrumented wrapper for cloud.google.com/go/storage.Writer that traces calls made to Google Cloud Storage API.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Writer for further details on wrapped type.

func (*Writer) Close

func (w *Writer) Close() error

Close closes the underlying cloud.google.com/go/storage.Writer and finalizes current exit span.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Writer.Close for further details on wrapped method.

func (*Writer) CloseWithError deprecated

func (w *Writer) CloseWithError(err error) error

CloseWithError terminates any writes performed by this Writer with an error and finalizes current exit span.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Writer.CloseWithError for further details on wrapped method.

Deprecated: this method is added for compatibility with the cloud.google.com/go/storage.Writer interface, however it is recommended to cancel the write operation using the context passed to NewWriter instead.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write calls the Write() method of the wrapped cloud.google.com/go/storage.Writer and initiates an exit span. Note that this span will be finished only when Close() is called, since writes are performed asynchronously and only guaranteed to be finished upon close. Thus each created span represents a single object insertion operation regardless of the number of Write() calls before the Writer is closed.

See https://pkg.go.dev/cloud.google.com/go/storage?tab=doc#Writer.Write for further details on wrapped method.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL