Skip to content

Commit

Permalink
Azure storage integration (#1247)
Browse files Browse the repository at this point in the history
This commit provides integrations for Azure storage, 
with the newer Azure.Storage.Blobs, Azure.Storage.Queues 
and Azure.Storage.Files.Shares nuget packages.

Closes #1156
Closes #1155
  • Loading branch information
russcam authored Apr 8, 2021
1 parent 9c1a355 commit 5db57e6
Show file tree
Hide file tree
Showing 32 changed files with 2,444 additions and 694 deletions.
3 changes: 2 additions & 1 deletion .ci/linux/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ declare -a projectsToPublish=(
"Elastic.Apm.GrpcClient"
"Elastic.Apm.Extensions.Logging"
"Elastic.Apm.StackExchange.Redis"
"Elastic.Apm.Azure.ServiceBus")
"Elastic.Apm.Azure.ServiceBus"
"Elastic.Apm.Azure.Storage")

for project in "${projectsToPublish[@]}"
do
Expand Down
15 changes: 14 additions & 1 deletion ElasticApmAgent.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30309.148
Expand Down Expand Up @@ -137,6 +136,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.Azure.ServiceBu
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.Azure.ServiceBus.Sample", "sample\Elastic.Apm.Azure.ServiceBus.Sample\Elastic.Apm.Azure.ServiceBus.Sample.csproj", "{27563B4E-ECB1-4F1B-B9F1-22C2C165B270}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.Azure.Storage", "src\Elastic.Apm.Azure.Storage\Elastic.Apm.Azure.Storage.csproj", "{E9C84C9D-7BEB-49E2-A955-04AD999C4266}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.Azure.Storage.Tests", "test\Elastic.Apm.Azure.Storage.Tests\Elastic.Apm.Azure.Storage.Tests.csproj", "{37BD6194-A47B-4D17-BB9A-642E8909DED9}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
test\Elastic.Apm.DatabaseTests.Common\Elastic.Apm.DatabaseTests.Common.projitems*{968e1e85-e996-42de-9845-d20dae16165a}*SharedItemsImports = 5
Expand Down Expand Up @@ -342,6 +345,14 @@ Global
{27563B4E-ECB1-4F1B-B9F1-22C2C165B270}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27563B4E-ECB1-4F1B-B9F1-22C2C165B270}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27563B4E-ECB1-4F1B-B9F1-22C2C165B270}.Release|Any CPU.Build.0 = Release|Any CPU
{E9C84C9D-7BEB-49E2-A955-04AD999C4266}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9C84C9D-7BEB-49E2-A955-04AD999C4266}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9C84C9D-7BEB-49E2-A955-04AD999C4266}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9C84C9D-7BEB-49E2-A955-04AD999C4266}.Release|Any CPU.Build.0 = Release|Any CPU
{37BD6194-A47B-4D17-BB9A-642E8909DED9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{37BD6194-A47B-4D17-BB9A-642E8909DED9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{37BD6194-A47B-4D17-BB9A-642E8909DED9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{37BD6194-A47B-4D17-BB9A-642E8909DED9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -396,6 +407,8 @@ Global
{1D43C8C5-4116-45C5-9F4B-56C1D926ED29} = {3734A52F-2222-454B-BF58-1BA5C1F29D77}
{D9CC53B2-5F6B-434B-8689-2350F3A9FB2D} = {267A241E-571F-458F-B04C-B6C4DE79E735}
{27563B4E-ECB1-4F1B-B9F1-22C2C165B270} = {3C791D9C-6F19-4F46-B367-2EC0F818762D}
{E9C84C9D-7BEB-49E2-A955-04AD999C4266} = {3734A52F-2222-454B-BF58-1BA5C1F29D77}
{37BD6194-A47B-4D17-BB9A-642E8909DED9} = {267A241E-571F-458F-B04C-B6C4DE79E735}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {69E02FD9-C9DE-412C-AB6B-5B8BECC6BFA5}
Expand Down
76 changes: 76 additions & 0 deletions build/terraform/azure/storage/test_resources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.46.0"
}
}
}

provider "azurerm" {
features {}
}

data "azurerm_client_config" "current" {
}

resource "random_uuid" "variables" {
}

variable "resource_group" {
type = string
description = "The name of the resource group to create"
}

variable "location" {
type = string
description = "The Azure location in which to deploy resources"
default = "westus"
}

variable "storage_account_name" {
type = string
description = "The name of the storage account to create"
}


resource "azurerm_resource_group" "storage_resource_group" {
name = var.resource_group
location = var.location
}

resource "azurerm_storage_account" "storage_account" {
name = var.storage_account_name
resource_group_name = azurerm_resource_group.storage_resource_group.name
location = azurerm_resource_group.storage_resource_group.location
account_tier = "Standard"
account_replication_type = "LRS"
enable_https_traffic_only = true
}

# random name to generate for the contributor role assignment
resource "random_uuid" "contributor_role" {
keepers = {
client_id = data.azurerm_client_config.current.client_id
}
}

resource "azurerm_role_assignment" "contributor_role" {
name = random_uuid.contributor_role.result
principal_id = data.azurerm_client_config.current.object_id
role_definition_name = "Contributor"
scope = azurerm_resource_group.storage_resource_group.id
depends_on = [azurerm_storage_account.storage_account]
}


# following role assignment, there can be a delay of up to ~1 minute
# for the assignments to propagate in Azure. You may need to introduce
# a wait before using the Azure resources created.

output "connection_string" {
value = azurerm_storage_account.storage_account.primary_connection_string
description = "The service bus primary connection string"
sensitive = true
}

53 changes: 52 additions & 1 deletion docs/setup.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ On .NET Core the agent also supports auto instrumentation without any code chang
* <<setup-sqlclient>>
* <<setup-stackexchange-redis>>
* <<setup-azure-servicebus>>
* <<setup-azure-storage>>
* <<setup-general>>

[float]
Expand Down Expand Up @@ -58,10 +59,14 @@ https://www.nuget.org/packages/Elastic.Apm.StackExchange.Redis[**Elastic.Apm.Sta

This packages contains instrumentation to capture spans for commands sent to redis with https://www.nuget.org/packages/StackExchange.Redis/[StackExchange.Redis] package.

https://www.nuget.org/packages/Elastic.Apm.StackExchange.Redis[**Elastic.Apm.Azure.ServiceBus**]::
https://www.nuget.org/packages/Elastic.Apm.Azure.ServiceBus[**Elastic.Apm.Azure.ServiceBus**]::

This packages contains instrumentation to capture transactions and spans for messages sent and received from Azure Service Bus with https://www.nuget.org/packages/Microsoft.Azure.ServiceBus/[Microsoft.Azure.ServiceBus] and https://www.nuget.org/packages/Azure.Messaging.ServiceBus/[Azure.Messaging.ServiceBus] packages.

https://www.nuget.org/packages/Elastic.Apm.Azure.Storage[**Elastic.Apm.Azure.Storage**]::

This packages contains instrumentation to capture spans for interaction with Azure Storage with https://www.nuget.org/packages/azure.storage.queues/[Azure.Storage.Queues], https://www.nuget.org/packages/azure.storage.blobs/[Azure.Storage.Blobs] and https://www.nuget.org/packages/azure.storage.files.shares/[Azure.Storage.Files.Shares] packages.


[[setup-dotnet-net-core]]
=== .NET Core
Expand Down Expand Up @@ -403,6 +408,52 @@ A new span is created when there is a current transaction, and when
* one or more messages are sent to a queue or topic.
* one or more messages are scheduled to a queue or a topic.

[[setup-azure-storage]]
=== Azure Storage

[float]
==== Quick start

Instrumentation can be enabled for Azure Storage by referencing https://www.nuget.org/packages/Elastic.Apm.Azure.Storage[`Elastic.Apm.Azure.Storage`] package and subscribing to diagnostic events using one of the subscribers:

. If the agent is included by referencing the `Elastic.Apm.NetCoreAll` package, the subscribers will be automatically subscribed with the agent, and no further action is required.
. If you're using `Azure.Storage.Blobs`, subscribe `AzureBlobStorageDiagnosticsSubscriber` with the agent
+
[source, csharp]
----
Agent.Subscribe(new AzureBlobStorageDiagnosticsSubscriber());
----
. If you're using `Azure.Storage.Queues`, subscribe `AzureQueueStorageDiagnosticsSubscriber` with the agent
+
[source, csharp]
----
Agent.Subscribe(new AzureQueueStorageDiagnosticsSubscriber());
----
. If you're using `Azure.Storage.Files.Shares`, subscribe `AzureFileShareStorageDiagnosticsSubscriber` with the agent
+
[source, csharp]
----
Agent.Subscribe(new AzureFileShareStorageDiagnosticsSubscriber());
----

For Azure Queue storage,

* A new transaction is created when one or more messages are received from a queue
* A new span is created when there is a current transaction, and when a message is sent to a queue

For Azure Blob storage, a new span is created when there is a current transaction and when

* A container is created, enumerated, or deleted
* A page blob is created, uploaded, downloaded, or deleted
* A block blob is created, copied, uploaded, downloaded or deleted

For Azure File Share storage, a new span is crated when there is a current transaction and when

* A share is created or deleted
* A directory is created or deleted
* A file is created, uploaded, or deleted.


[[setup-general]]
=== Other .NET applications

Expand Down
8 changes: 7 additions & 1 deletion docs/supported-technologies.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ Automatic instrumentation for the following cloud services
7.0.0+ for Azure.Messaging.ServiceBus
| A new transaction is created for received and
receive deferred messages. A new span is created for sent and scheduled messages if there's a current transaction.
| 1.9
| 1.10

| Azure Storage
| 12.8.0+ for Azure.Storage.Blobs
12.6.0+ for Azure.Storage.Queues and Azure.Storage.Files.Shares
|
| 1.10

|===
Loading

0 comments on commit 5db57e6

Please sign in to comment.