Skip to content

Commit

Permalink
Update MongoDb integration (#421)
Browse files Browse the repository at this point in the history
* Add MongoDB integration

* Start mongodb service for mac

* run mongodb directly windows
  • Loading branch information
RassK authored Apr 26, 2022
1 parent c529510 commit 47f16b5
Show file tree
Hide file tree
Showing 20 changed files with 678 additions and 901 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
3.1.x
5.0.x
6.0.x
- name: Start MongoDB service
if: ${{ runner.os == 'macOS' }}
run: brew services start mongodb-community
- run: ./build.cmd Workflow
- name: Upload logs
uses: actions/[email protected]
Expand Down
30 changes: 30 additions & 0 deletions OpenTelemetry.AutoInstrumentation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests.Http", "te
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.CoreAppOldReference", "examples\CoreAppOldReference\Examples.CoreAppOldReference.csproj", "{6ACF2A48-427F-4EF2-81B5-EE9CDB0476C6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests.MongoDB", "test\integration-tests\IntegrationTests.MongoDB\IntegrationTests.MongoDB.csproj", "{75EB97DD-E191-4BDF-83DE-E26785567710}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.MongoDB", "test\test-applications\integrations\TestApplication.MongoDB\TestApplication.MongoDB.csproj", "{3B77F975-BF66-4218-9982-F48D3271DDFE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -539,6 +543,30 @@ Global
{6ACF2A48-427F-4EF2-81B5-EE9CDB0476C6}.Release|x64.Build.0 = Release|Any CPU
{6ACF2A48-427F-4EF2-81B5-EE9CDB0476C6}.Release|x86.ActiveCfg = Release|Any CPU
{6ACF2A48-427F-4EF2-81B5-EE9CDB0476C6}.Release|x86.Build.0 = Release|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Debug|x64.ActiveCfg = Debug|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Debug|x64.Build.0 = Debug|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Debug|x86.ActiveCfg = Debug|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Debug|x86.Build.0 = Debug|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Release|Any CPU.Build.0 = Release|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Release|x64.ActiveCfg = Release|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Release|x64.Build.0 = Release|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Release|x86.ActiveCfg = Release|Any CPU
{75EB97DD-E191-4BDF-83DE-E26785567710}.Release|x86.Build.0 = Release|Any CPU
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Debug|Any CPU.ActiveCfg = Debug|x64
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Debug|Any CPU.Build.0 = Debug|x64
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Debug|x64.ActiveCfg = Debug|x64
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Debug|x64.Build.0 = Debug|x64
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Debug|x86.ActiveCfg = Debug|x86
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Debug|x86.Build.0 = Debug|x86
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Release|Any CPU.ActiveCfg = Release|x64
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Release|Any CPU.Build.0 = Release|x64
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Release|x64.ActiveCfg = Release|x64
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Release|x64.Build.0 = Release|x64
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Release|x86.ActiveCfg = Release|x86
{3B77F975-BF66-4218-9982-F48D3271DDFE}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -585,6 +613,8 @@ Global
{4E17BE29-B227-41D8-97FE-26F674951E26} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
{413326C3-4B8F-4C44-93C8-0E20EFB97DB4} = {357C3F25-98CA-41C6-BA2C-20968695D026}
{6ACF2A48-427F-4EF2-81B5-EE9CDB0476C6} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A}
{75EB97DD-E191-4BDF-83DE-E26785567710} = {357C3F25-98CA-41C6-BA2C-20968695D026}
{3B77F975-BF66-4218-9982-F48D3271DDFE} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F}
Expand Down
28 changes: 28 additions & 0 deletions integrations.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
[
{
"name": "MongoDb",
"method_replacements": [
{
"caller": {},
"target": {
"assembly": "MongoDB.Driver",
"type": "MongoDB.Driver.MongoClient",
"method": ".ctor",
"signature_types": [
"System.Void",
"MongoDB.Driver.MongoClientSettings"
],
"minimum_major": 2,
"minimum_minor": 0,
"minimum_patch": 0,
"maximum_major": 2,
"maximum_minor": 65535,
"maximum_patch": 65535
},
"wrapper": {
"assembly": "OpenTelemetry.AutoInstrumentation",
"type": "OpenTelemetry.AutoInstrumentation.Instrumentations.MongoDb.MongoClientIntegration",
"action": "CallTargetModification"
}
}
]
},
{
"name": "GraphQL",
"method_replacements": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<ItemGroup>
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.DiagnosticSources" Version="1.1.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2472,7 +2472,7 @@ size_t CorProfiler::CallTarget_RequestRejitForModule(ModuleID module_id, ModuleM
if (numOfArgs != integration.replacement.target_method.signature_types.size() - 1)
{
Logger::Debug("The caller for the methoddef: ", integration.replacement.target_method.method_name,
" doesn't have the right number of arguments.");
" doesn't have the right number of arguments(", numOfArgs, " arguments).");
enumIterator = ++enumIterator;
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ internal static class EnvironmentConfigurationHelper
{
[Instrumentation.HttpClient] = builder => builder.AddHttpClientInstrumentation(),
[Instrumentation.AspNet] = builder => builder.AddSdkAspNetInstrumentation(),
[Instrumentation.SqlClient] = builder => builder.AddSqlClientInstrumentation()
[Instrumentation.SqlClient] = builder => builder.AddSqlClientInstrumentation(),
[Instrumentation.MongoDb] = builder => builder.AddSource("MongoDB.Driver.Core.Extensions.DiagnosticSources")
};

public static TracerProviderBuilder UseEnvironmentVariables(this TracerProviderBuilder builder, Settings settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ public enum Instrumentation
/// GraphQL instrumentation.
/// </summary>
GraphQL,

/// <summary>
/// MongoDb instrumentation.
/// </summary>
MongoDb
}
67 changes: 0 additions & 67 deletions src/OpenTelemetry.AutoInstrumentation/Emit/DelegateMetadata.cs

This file was deleted.

Loading

0 comments on commit 47f16b5

Please sign in to comment.