X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3121f0dfb9262ccd50d0637c9f7cedf9191f69bf..87275ec769831e04982a714049ee9d67b6342d68:/services/keepstore/azure_blob_volume.go diff --git a/services/keepstore/azure_blob_volume.go b/services/keepstore/azure_blob_volume.go index 383759803c..4839e3f682 100644 --- a/services/keepstore/azure_blob_volume.go +++ b/services/keepstore/azure_blob_volume.go @@ -106,26 +106,6 @@ type AzureBlobVolume struct { bsClient *azureBlobClient } -// azureBlobClient wraps storage.BlobStorageClient in order to count -// I/O and API usage stats. -type azureBlobClient struct { - client *storage.BlobStorageClient - stats azureBlobStats -} - -type azureBlobStats struct { - statsTicker - Ops uint64 - GetOps uint64 - GetRangeOps uint64 - CreateOps uint64 - SetMetadataOps uint64 - DelOps uint64 - ListOps uint64 - - lock sync.Mutex -} - // Examples implements VolumeWithExamples. func (*AzureBlobVolume) Examples() []Volume { return []Volume{ @@ -652,6 +632,38 @@ func (v *AzureBlobVolume) InternalStats() interface{} { return &v.bsClient.stats } +type azureBlobStats struct { + statsTicker + Ops uint64 + GetOps uint64 + GetRangeOps uint64 + GetMetadataOps uint64 + GetPropertiesOps uint64 + CreateOps uint64 + SetMetadataOps uint64 + DelOps uint64 + ListOps uint64 +} + +func (s *azureBlobStats) TickErr(err error) { + if err == nil { + return + } + errType := fmt.Sprintf("%T", err) + if err, ok := err.(storage.AzureStorageServiceError); ok { + errType = errType + fmt.Sprintf(" %d (%s)", err.StatusCode, err.Code) + } + log.Printf("errType %T, err %s", err, err) + s.statsTicker.TickErr(err, errType) +} + +// azureBlobClient wraps storage.BlobStorageClient in order to count +// I/O and API usage stats. +type azureBlobClient struct { + client *storage.BlobStorageClient + stats azureBlobStats +} + func (c *azureBlobClient) ContainerExists(cname string) (bool, error) { c.stats.Tick(&c.stats.Ops) ok, err := c.client.ContainerExists(cname) @@ -660,14 +672,14 @@ func (c *azureBlobClient) ContainerExists(cname string) (bool, error) { } func (c *azureBlobClient) GetBlobMetadata(cname, bname string) (map[string]string, error) { - c.stats.Tick(&c.stats.Ops) + c.stats.Tick(&c.stats.Ops, &c.stats.GetMetadataOps) m, err := c.client.GetBlobMetadata(cname, bname) c.stats.TickErr(err) return m, err } func (c *azureBlobClient) GetBlobProperties(cname, bname string) (*storage.BlobProperties, error) { - c.stats.Tick(&c.stats.Ops) + c.stats.Tick(&c.stats.Ops, &c.stats.GetPropertiesOps) p, err := c.client.GetBlobProperties(cname, bname) c.stats.TickErr(err) return p, err