Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cosmos DB support #1239

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 8 additions & 3 deletions .ci/docker/sdk-linux/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0.102-ca-patch-buster-slim
FROM mcr.microsoft.com/dotnet/sdk:5.0

ENV DOTNET_ROOT=/usr/share/dotnet
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${DOTNET_ROOT}/tools:${DOTNET_ROOT}
Expand All @@ -11,7 +11,6 @@ RUN /bin/bash ./dotnet-install.sh --install-dir "${DOTNET_ROOT}" -version "2.1.5
RUN /bin/bash ./dotnet-install.sh --install-dir "${DOTNET_ROOT}" -version "3.0.103"
RUN /bin/bash ./dotnet-install.sh --install-dir "${DOTNET_ROOT}" -version "3.1.100"


# Install docker
RUN apt update \
&& apt-get -qq install -y apt-transport-https ca-certificates curl \
Expand All @@ -21,4 +20,10 @@ RUN apt update \
&& apt -qq update \
&& apt-get -qq install -y docker-ce docker-ce-cli containerd.io \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/*

# Install terraform
RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - \
&& apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" \
&& apt-get update \
&& apt-get install terraform
6 changes: 5 additions & 1 deletion .ci/linux/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ declare -a projectsToPublish=(
"Elastic.Apm.Extensions.Hosting"
"Elastic.Apm.GrpcClient"
"Elastic.Apm.Extensions.Logging"
"Elastic.Apm.StackExchange.Redis")
"Elastic.Apm.StackExchange.Redis"
"Elastic.Apm.Azure.ServiceBus"
"Elastic.Apm.Azure.Storage"
"Elastic.Apm.MongoDb"
)

for project in "${projectsToPublish[@]}"
do
Expand Down
1 change: 1 addition & 0 deletions .ci/windows/dotnet.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dotnet sln remove src/Elastic.Apm.AspNetFullFramework/Elastic.Apm.AspNetFullFram
dotnet sln remove test/Elastic.Apm.AspNetFullFramework.Tests/Elastic.Apm.AspNetFullFramework.Tests.csproj
dotnet sln remove test/Elastic.Apm.SqlClient.Tests/Elastic.Apm.SqlClient.Tests.csproj
dotnet sln remove test/Elastic.Apm.EntityFramework6.Tests/Elastic.Apm.EntityFramework6.Tests.csproj
dotnet sln remove test/Elastic.Apm.MongoDb.Tests/Elastic.Apm.MongoDb.Tests.csproj

:: Remove startup hooks tests, which are tested separately- require agent zip to be built
dotnet sln remove test/Elastic.Apm.StartupHook.Tests/Elastic.Apm.StartupHook.Tests.csproj
Expand Down
1 change: 1 addition & 0 deletions .ci/windows/prepare-test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dotnet sln remove src/Elastic.Apm.AspNetFullFramework/Elastic.Apm.AspNetFullFram
dotnet sln remove test/Elastic.Apm.AspNetFullFramework.Tests/Elastic.Apm.AspNetFullFramework.Tests.csproj
dotnet sln remove test/Elastic.Apm.SqlClient.Tests/Elastic.Apm.SqlClient.Tests.csproj
dotnet sln remove test/Elastic.Apm.EntityFramework6.Tests/Elastic.Apm.EntityFramework6.Tests.csproj
dotnet sln remove test/Elastic.Apm.MongoDb.Tests/Elastic.Apm.MongoDb.Tests.csproj
6 changes: 6 additions & 0 deletions .ci/windows/test-tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ if (!$codecov) {
dotnet tool install -g Codecov.Tool --version 1.2.0
}

# Install terraform
choco install terraform -m -y --no-progress --force -r --version=0.14.8
if ($LASTEXITCODE -ne 0) {
Write-Host "terraform installation failed."
exit 1
}
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,14 @@ html_docs
build/output/

# Generated .NET core sln file
ElasticApmAgent.NetCore.sln
ElasticApmAgent.NetCore.sln

# Terraform configuration state files
.terraform
.terraform.lock.hcl
terraform.tfstate
terraform.tfstate.backup
.terraform.tfstate.lock.info

# Azure credentials file
.credentials.json
16 changes: 16 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ endif::[]
[[release-notes-1.x]]
=== .NET Agent version 1.x

[[release-notes-1.9.0]]
==== 1.9.0

[float]
===== Features
- {pull}925[#925] Add GC time (issue: {issue}922[#922])
- {pull}1147[#1147] Propagate sample rate through `tracestate` (issue: {issue}1021[#1021])

[float]
===== Bug fixes
- {pull}1189[#1189] Get transaction name from Web API controller route template

[float]
===== Breaking changes
- {pull}1161[#1161] and {pull}1162[#1162] The agent tries to never throw any exception. Specifically instead of throwing `InstanceAlreadyCreatedException`, it will print an error log.

[[release-notes-1.8.1]]
==== 1.8.1

Expand Down
72 changes: 66 additions & 6 deletions ElasticApmAgent.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30309.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3734A52F-2222-454B-BF58-1BA5C1F29D77}"
ProjectSection(SolutionItems) = preProject
src\Directory.Build.props = src\Directory.Build.props
src\Directory.Build.targets = src\Directory.Build.targets
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{3C791D9C-6F19-4F46-B367-2EC0F818762D}"
Expand Down Expand Up @@ -129,12 +129,27 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.StartupHook.Tes
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.Extensions.Logging", "src\Elastic.Apm.Extensions.Logging\Elastic.Apm.Extensions.Logging.csproj", "{9BAEEF56-4061-488A-8FB8-28BDBBB26C3D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.Extensions.Logging.Tests", "test\Elastic.Apm.Extensions.Logging.Tests\Elastic.Apm.Extensions.Logging.Tests.csproj", "{B235B13F-42AE-42DA-A3C8-20D047F38685}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.Extensions.Logging.Tests", "test\Elastic.Apm.Extensions.Logging.Tests\Elastic.Apm.Extensions.Logging.Tests.csproj", "{B235B13F-42AE-42DA-A3C8-20D047F38685}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.MongoDb", "src\Elastic.Apm.MongoDb\Elastic.Apm.MongoDb.csproj", "{11C16D17-C0D0-48C3-B3A6-E9248C515976}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elastic.Apm.MongoDb.Tests", "test\Elastic.Apm.MongoDb.Tests\Elastic.Apm.MongoDb.Tests.csproj", "{FB07C133-C353-4061-A308-B9A6EF48AB7E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.Azure.ServiceBus", "src\Elastic.Apm.Azure.ServiceBus\Elastic.Apm.Azure.ServiceBus.csproj", "{1D43C8C5-4116-45C5-9F4B-56C1D926ED29}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.Azure.ServiceBus.Tests", "test\Elastic.Apm.Azure.ServiceBus.Tests\Elastic.Apm.Azure.ServiceBus.Tests.csproj", "{D9CC53B2-5F6B-434B-8689-2350F3A9FB2D}"
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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.Azure.CosmosDb.Tests", "test\Elastic.Apm.Azure.CosmosDb.Tests\Elastic.Apm.Azure.CosmosDb.Tests.csproj", "{852CB8AB-43B6-4CFD-9D2F-4520971217B3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Apm.Azure.CosmosDb", "src\Elastic.Apm.Azure.CosmosDb\Elastic.Apm.Azure.CosmosDb.csproj", "{35370BB1-79BE-4D4A-A770-DAD63FBF7A33}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
test\Elastic.Apm.DatabaseTests.Common\Elastic.Apm.DatabaseTests.Common.projitems*{968e1e85-e996-42de-9845-d20dae16165a}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand Down Expand Up @@ -324,6 +339,42 @@ Global
{B235B13F-42AE-42DA-A3C8-20D047F38685}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B235B13F-42AE-42DA-A3C8-20D047F38685}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B235B13F-42AE-42DA-A3C8-20D047F38685}.Release|Any CPU.Build.0 = Release|Any CPU
{1D43C8C5-4116-45C5-9F4B-56C1D926ED29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D43C8C5-4116-45C5-9F4B-56C1D926ED29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D43C8C5-4116-45C5-9F4B-56C1D926ED29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D43C8C5-4116-45C5-9F4B-56C1D926ED29}.Release|Any CPU.Build.0 = Release|Any CPU
{D9CC53B2-5F6B-434B-8689-2350F3A9FB2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9CC53B2-5F6B-434B-8689-2350F3A9FB2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9CC53B2-5F6B-434B-8689-2350F3A9FB2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9CC53B2-5F6B-434B-8689-2350F3A9FB2D}.Release|Any CPU.Build.0 = Release|Any CPU
{27563B4E-ECB1-4F1B-B9F1-22C2C165B270}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
{852CB8AB-43B6-4CFD-9D2F-4520971217B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{852CB8AB-43B6-4CFD-9D2F-4520971217B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{852CB8AB-43B6-4CFD-9D2F-4520971217B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{852CB8AB-43B6-4CFD-9D2F-4520971217B3}.Release|Any CPU.Build.0 = Release|Any CPU
{11C16D17-C0D0-48C3-B3A6-E9248C515976}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11C16D17-C0D0-48C3-B3A6-E9248C515976}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11C16D17-C0D0-48C3-B3A6-E9248C515976}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11C16D17-C0D0-48C3-B3A6-E9248C515976}.Release|Any CPU.Build.0 = Release|Any CPU
{FB07C133-C353-4061-A308-B9A6EF48AB7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB07C133-C353-4061-A308-B9A6EF48AB7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB07C133-C353-4061-A308-B9A6EF48AB7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB07C133-C353-4061-A308-B9A6EF48AB7E}.Release|Any CPU.Build.0 = Release|Any CPU
{35370BB1-79BE-4D4A-A770-DAD63FBF7A33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35370BB1-79BE-4D4A-A770-DAD63FBF7A33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35370BB1-79BE-4D4A-A770-DAD63FBF7A33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35370BB1-79BE-4D4A-A770-DAD63FBF7A33}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -375,6 +426,15 @@ Global
{9AE4805D-2586-4FA5-A0D0-885264EBC565} = {267A241E-571F-458F-B04C-B6C4DE79E735}
{9BAEEF56-4061-488A-8FB8-28BDBBB26C3D} = {3734A52F-2222-454B-BF58-1BA5C1F29D77}
{B235B13F-42AE-42DA-A3C8-20D047F38685} = {267A241E-571F-458F-B04C-B6C4DE79E735}
{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}
{852CB8AB-43B6-4CFD-9D2F-4520971217B3} = {267A241E-571F-458F-B04C-B6C4DE79E735}
{11C16D17-C0D0-48C3-B3A6-E9248C515976} = {3734A52F-2222-454B-BF58-1BA5C1F29D77}
{FB07C133-C353-4061-A308-B9A6EF48AB7E} = {267A241E-571F-458F-B04C-B6C4DE79E735}
{35370BB1-79BE-4D4A-A770-DAD63FBF7A33} = {3734A52F-2222-454B-BF58-1BA5C1F29D77}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {69E02FD9-C9DE-412C-AB6B-5B8BECC6BFA5}
Expand Down
11 changes: 8 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ pipeline {
retry(3) {
bat label: 'Build', script: '.ci/windows/dotnet.bat'
}
bat label: 'Test & coverage', script: '.ci/windows/test.bat'
withAzureCredentials(path: "${HOME}", credentialsFile: '.credentials.json') {
bat label: 'Test & coverage', script: '.ci/windows/test.bat'
}
}
}
}
Expand Down Expand Up @@ -520,8 +522,11 @@ def cleanDir(path){
def dotnet(Closure body){
def dockerTagName = 'docker.elastic.co/observability-ci/apm-agent-dotnet-sdk-linux:latest'
sh label: 'Docker build', script: "docker build --tag ${dockerTagName} .ci/docker/sdk-linux"
docker.image("${dockerTagName}").inside("-e HOME='${env.WORKSPACE}/${env.BASE_DIR}' -v /var/run/docker.sock:/var/run/docker.sock"){
body()
def homePath = "${env.WORKSPACE}/${env.BASE_DIR}"
docker.image("${dockerTagName}").inside("-e HOME='${homePath}' -v /var/run/docker.sock:/var/run/docker.sock"){
withAzureCredentials(path: "${homePath}", credentialsFile: '.credentials.json') {
body()
}
}
}

Expand Down
83 changes: 83 additions & 0 deletions build/terraform/azure/cosmosdb/test_resources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
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" {
}

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 "cosmos_db_account_name" {
type = string
description = "The name of the cosmos db account to create"
}

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

resource "azurerm_cosmosdb_account" "cosmos_db_account" {
name = var.cosmos_db_account_name
location = azurerm_resource_group.cosmos_db_resource_group.location
resource_group_name = azurerm_resource_group.cosmos_db_resource_group.name
offer_type = "Standard"
kind = "GlobalDocumentDB"
enable_automatic_failover = false

capabilities {
name = "EnableAggregationPipeline"
}

capabilities {
name = "mongoEnableDocLevelTTL"
}

capabilities {
name = "MongoDBv3.4"
}

consistency_policy {
consistency_level = "Strong"
}

geo_location {
location = azurerm_resource_group.cosmos_db_resource_group.location
failover_priority = 0
}
}

output "endpoint" {
value = azurerm_cosmosdb_account.cosmos_db_account.endpoint
}

output "primary_master_key" {
value = azurerm_cosmosdb_account.cosmos_db_account.primary_master_key
sensitive = true
}
Loading