C
C#6mo ago
M.H

✅ Open telemetry & asp.net core

Hello guys! I'm trying to setup the open telemetry within my asp.net core project I've took the inital code from offical repository - https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/examples/AspNetCore But i still have some problem:
builder.Services.AddOpenTelemetry()
builder.Services.AddOpenTelemetry()
0>Program.cs(46,1): Error CS1929 : 'IServiceCollection' does not contain a definition for 'AddOpenTelemetry' and the best extension method overload 'OpenTelemetryLoggingExtensions.AddOpenTelemetry(ILoggingBuilder)' requires a receiver of type 'Microsoft.Extensions.Logging.ILoggingBuilder'
0>Program.cs(46,1): Error CS1929 : 'IServiceCollection' does not contain a definition for 'AddOpenTelemetry' and the best extension method overload 'OpenTelemetryLoggingExtensions.AddOpenTelemetry(ILoggingBuilder)' requires a receiver of type 'Microsoft.Extensions.Logging.ILoggingBuilder'
I'm pretty sure that i have problems with versions but i can't figure out which versions i need to install 😦
46 Replies
M.H
M.HOP6mo ago
The code line above (AddOpenTelemetry) in the original repo is here - https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/examples/AspNetCore/Program.cs#L36
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
What do you mean 'you have in mind'? I dont understand you well 😦
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
I'm just trying follow the officialexample from this repo https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/examples/AspNetCore
GitHub
opentelemetry-dotnet/examples/AspNetCore at main · open-telemetry/o...
The OpenTelemetry .NET Client. Contribute to open-telemetry/opentelemetry-dotnet development by creating an account on GitHub.
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
>I mean "what are you guessing is the issue behind this error" Aww, ok As i mentioned before, i guess, there are problems with versions For the true, i had the same problems but with another project (even language) and it was really painful
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
Here's a cool story... I'm a newbie in .NET, so I can only guess how it works I've installed the latest versions
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>

<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.1"/>

<PackageReference Include="OpenTelemetry.Extensions" Version="1.0.0-beta.5" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.9.0-beta.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.9.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>

<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.1"/>

<PackageReference Include="OpenTelemetry.Extensions" Version="1.0.0-beta.5" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.9.0-beta.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="1.9.0" />
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
This is my csproj for now)
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
>or did you just took all the latest yea, you're right There isn't a single version that's the same for all of them. If i'm not mistaken))
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
oh my...interesting one Thank you for your advice
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
I have just started a fresh project, which I created just an hour ago.
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
About versions - they are using the latest one... probably because of
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Extensions.Hosting\OpenTelemetry.Extensions.Hosting.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.OpenTelemetryProtocol\OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Prometheus.AspNetCore\OpenTelemetry.Exporter.Prometheus.AspNetCore.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Zipkin\OpenTelemetry.Exporter.Zipkin.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Extensions.Hosting\OpenTelemetry.Extensions.Hosting.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.OpenTelemetryProtocol\OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Prometheus.AspNetCore\OpenTelemetry.Exporter.Prometheus.AspNetCore.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Zipkin\OpenTelemetry.Exporter.Zipkin.csproj" />
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
I'm 99% sure you're missing a nuget
Nah, Rider has done this for me
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
No description
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX6mo ago
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
BlazeBin - wtbwntkxfehv
A tool for sharing your source code with the world!
M.H
M.HOP6mo ago
yea, it's the webapi or web..i'm not sure here sorry if there is any difference between web and web api
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
oh my fucking goodnes really..
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
that's why i hate these fucking extensions with fucking magic i will try now
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
oh my.. you're right it's fine now
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
Seriously... why did they decide to do it with magic over extension 😦 I prefer to manually create an instance and provide it... darn)) Thank you so much! I'll remember how to solve...just looking definition of the functions...it's good one)
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
Ok, ok, I got it. That's helpful information i see
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
:HmmCouncilRTX3: It looks so simple... I feel dumb about my previous problem )) Thank you for the information Very helpful!
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
:kekw: I had the problem with the versions in Go, as I mentioned before. There's no magic like that, so... By the way, it was an interesting experience. I see, OpenTelemetry (especially Google, I believe) doesn't need to do any open-source projects ))
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
M.H
M.HOP6mo ago
I'm not a big fan of Go, but you're wrong here. You can use the version that you need. They pull it from GitHub, but you're able to use tags, commits, etc. And of course, there is a frozen mechanism for this. By the way, the problem was not with that. OpenTelemetry has a lot of different projects that you usually need to use together, and I couldn't combine them because of different versions and compile errors due to differing function signatures. Quite frustrating, really.
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX6mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Want results from more Discord servers?
Add your server