apm-agent-dotnet icon indicating copy to clipboard operation
apm-agent-dotnet copied to clipboard

[BUG] The build fails when using side-by-side with Mongo Driver 3.0

Open quixoticaxis opened this issue 1 year ago • 3 comments

APM Agent version

1.30.1

Environment

Does not matter.

.NET Framework/Core name and version : 9.0.100

Application Target Framework(s) : net9

Describe the bug

After adding Elastic.Apm.NetCoreAll package to a new service, the service fails to compile.

To Reproduce

Add the package MongoDB.Driver, which, at the time of writing, has a version 3.0.0. Add the package Elastic.Apm.NetCoreAll, which, at the time of writing, has a version 1.30.1. Use any Mongo abstraction, for example, ReadConcern in your project. Build the project.

Expected behavior

The build completes.

Actual behavior

/***/***.cs(30,30): error CS0433: The type 'ReadPreference' exists in both 'MongoDB.Driver.Core, Version=2.28.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321' and 'MongoDB.Driver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'

/***/***.cs(31,27): error CS0433: The type 'ReadConcern' exists in both 'MongoDB.Driver.Core, Version=2.28.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321' and 'MongoDB.Driver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'

/***/***.cs(32,28): error CS0433: The type 'WriteConcern' exists in both 'MongoDB.Driver.Core, Version=2.28.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321' and 'MongoDB.Driver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'

/***/***.cs(40,38): error CS0433: The type 'ReadConcern' exists in both 'MongoDB.Driver.Core, Version=2.28.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321' and 'MongoDB.Driver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'

/***/***.cs(41,41): error CS0433: The type 'ReadPreference' exists in both 'MongoDB.Driver.Core, Version=2.28.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321' and 'MongoDB.Driver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'

/***/***.cs(42,39): error CS0433: The type 'WriteConcern' exists in both 'MongoDB.Driver.Core, Version=2.28.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321' and 'MongoDB.Driver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'

/***/***.cs(48,16): warning CS8619: Nullability of reference types in value of type '?' doesn't match target type 'IClientSessionHandle'.

/***/***.cs(223,16): error CS0433: The type 'MongoException' exists in both 'MongoDB.Driver.Core, Version=2.28.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321' and 'MongoDB.Driver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'

/***/***.cs(228,62): error CS0433: The type 'ServerErrorCategory' exists in both 'MongoDB.Driver.Core, Version=2.28.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321' and 'MongoDB.Driver, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'

quixoticaxis avatar Nov 28 '24 12:11 quixoticaxis

Downgrading the service to use Mongo.Driver 2.30.0 is a valid workaround.

quixoticaxis avatar Nov 28 '24 13:11 quixoticaxis

Are there any plans to upgrade the MongoDB instrumentation project to rely on MongoDB.Driver instead of MongoDB.Driver.Core since MongoDB.Driver.Core has been deprecated and moved into MongoDB.Driver (per this article - https://www.mongodb.com/developer/languages/csharp/new-version-3-driver-whats-new/?msockid=28ec60e1e262615e32c57325e3e660a6)

MarkAD88 avatar Mar 07 '25 01:03 MarkAD88

fixed by this PR: https://github.com/elastic/apm-agent-dotnet/pull/2580

badge2033 avatar Apr 14 '25 11:04 badge2033