-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add instrumentation for Azure Service Bus (#1225)
This commit adds instrumentation for Azure Service Bus when an application is using Microsoft.Azure.ServiceBus 3.0.0+ or Azure.Messaging.ServiceBus 7.0.0+ nuget packages. Two IDiagnosticListener implementations, one for Microsoft.Azure.ServiceBus and another for Azure.Messaging.ServiceBus, create transactions and spans for received and sent messages: A new transaction is created when - one or more messages are received from a queue or topic subscription. - a message is receive deferred from a queue or topic subscription. 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. The diagnostic events do not expose details about sent or received messages. The trace ids of messages are exposed but are not currently captured in this implementation. Messages are often received in batches, and it is possible for each message to have its own trace id, but the APM implementation does not have a concept for capturing such data right now. See elastic/apm#122 A terraform template file is used to create a resource group, Azure Service Bus namespace resource in the resource group, and set RBAC rules to allow the Service Principal that issues the creation access to the resources. The Service Principal credentials can are sourced from a .credentials.json file in the root of the repository for CI, and from an account authenticated with az for local development. A default location is set within the template, but all variables can be passed using standard Terraform input variable conventions. Closes #1157
- Loading branch information
Showing
58 changed files
with
2,217 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
terraform { | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "=2.46.0" | ||
} | ||
} | ||
} | ||
|
||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
# configuration is sourced from the following environment variables: | ||
# ARM_CLIENT_ID | ||
# ARM_CLIENT_SECRET | ||
# ARM_SUBSCRIPTION_ID | ||
# ARM_TENANT_ID | ||
# | ||
# See https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/service_principal_client_secret | ||
# for creating a Service Principal and Client Secret | ||
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 "servicebus_namespace" { | ||
type = string | ||
description = "The name of the servicebus namespace to create" | ||
} | ||
|
||
resource "azurerm_resource_group" "servicebus_resource_group" { | ||
name = var.resource_group | ||
location = var.location | ||
} | ||
|
||
resource "azurerm_servicebus_namespace" "servicebus_namespace" { | ||
location = azurerm_resource_group.servicebus_resource_group.location | ||
name = var.servicebus_namespace | ||
resource_group_name = azurerm_resource_group.servicebus_resource_group.name | ||
sku = "Standard" | ||
depends_on = [azurerm_resource_group.servicebus_resource_group] | ||
} | ||
|
||
# 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.servicebus_resource_group.id | ||
depends_on = [azurerm_servicebus_namespace.servicebus_namespace] | ||
} | ||
|
||
# random name to generate for the contributor role assignment | ||
resource "random_uuid" "data_owner_role" { | ||
keepers = { | ||
client_id = data.azurerm_client_config.current.client_id | ||
} | ||
} | ||
|
||
resource "azurerm_role_assignment" "servicebus_data_owner_role" { | ||
name = random_uuid.data_owner_role.result | ||
principal_id = data.azurerm_client_config.current.object_id | ||
role_definition_name = "Azure Service Bus Data Owner" | ||
scope = azurerm_resource_group.servicebus_resource_group.id | ||
depends_on = [azurerm_servicebus_namespace.servicebus_namespace] | ||
} | ||
|
||
# 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_servicebus_namespace.servicebus_namespace.default_primary_connection_string | ||
description = "The service bus primary connection string" | ||
sensitive = true | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
sample/Elastic.Apm.Azure.ServiceBus.Sample/Elastic.Apm.Azure.ServiceBus.Sample.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="3.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Elastic.Apm.Azure.ServiceBus\Elastic.Apm.Azure.ServiceBus.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.