Comments (6)
Hi @bgelens , can you share your full config? How are you setting resourceBuilder
to the AddOpenTelemetry()
?
My code sample works:
<PackageReference Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.2.0-beta.4" />
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.3.0" />
builder.Services.AddOpenTelemetry()
.ConfigureResource(x => x.AddAttributes(new List<KeyValuePair<string, object>> { new KeyValuePair<string, object>("service.version", "someValue") }))
.UseAzureMonitor(o => o.ConnectionString = connectionString);
from azure-sdk-for-net.
I'll need some time to test your sample.
Just some observations:
-
if the value of
_applicationVersion
isstring.Empty
, that value won't be sent to Application Insights. -
The telemetry you shared doesn't fully match your config.
Your config shows:
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.3.0" />
But your telemetry shows Exporter version "1.3.0-beta2"
Beta2 does support the "service.version" so this is not the root cause.
I'm calling attention to this because the config you're sharing may not match the application you're testing.
Here's my end to end example:
csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.2.0" />
</ItemGroup>
</Project>
Program.cs
namespace WebApplication10
{
using Azure.Monitor.OpenTelemetry.AspNetCore;
using OpenTelemetry.Resources;
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
var connectionString = "<YOUR CONNECTION STRING>";
builder.Services.AddOpenTelemetry()
.ConfigureResource(x => x.AddAttributes(new List<KeyValuePair<string, object>> { new("service.version", "someValue") }))
.UseAzureMonitor(x => x.ConnectionString = connectionString);
var app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.Run();
}
}
}
Application Insights
from azure-sdk-for-net.
I confirmed that the value "unknown" is being filtered. This wasn't a known limitation. I'll follow up with the service team to get more information.
from azure-sdk-for-net.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @cijothomas @rajkumar-rangaraj @reyang @TimothyMothra @vishweshbankwar.
from azure-sdk-for-net.
I've adjusted my config to match yours and the end result is the same for me (nothing to see in application insights).
See my config.
<PackageVersion Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.2.0-beta.4" />
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.3.0" />
private static void ConfigureOpenTelemetry(this IHostApplicationBuilder builder)
{
builder.Configuration["OTEL_SERVICE_NAME"] ??= Assembly.GetEntryAssembly()!.GetName().Name!;
builder.Configuration["OTEL_RESOURCE_ATTRIBUTES"] ??= $"service.instance.id={Environment.MachineName}";
builder.Logging.AddOpenTelemetry(logging =>
{
logging.IncludeFormattedMessage = true;
logging.IncludeScopes = true;
});
builder.Services.AddOpenTelemetry()
.ConfigureResource(x => x.AddAttributes([new KeyValuePair<string, object>("service.version", _applicationVersion)]))
.WithMetrics(metrics =>
{
metrics.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation();
})
.WithTracing(tracing =>
{
if (builder.Environment.IsDevelopment())
{
// We want to view all traces in development
tracing.SetSampler(new AlwaysOnSampler());
}
tracing.AddAspNetCoreInstrumentation(o =>
{
o.Filter = httpContext =>
{
// do not trace health checks when they return 200
if (httpContext.Request.Path.HasValue &&
httpContext.Request.Path.Value.StartsWith("/health", StringComparison.OrdinalIgnoreCase) &&
httpContext.Response.StatusCode == (int)HttpStatusCode.OK)
{
return false;
}
// do not trace dapr config
if (httpContext.Request.Path.HasValue &&
httpContext.Request.Path.Value.StartsWith("/dapr/config", StringComparison.OrdinalIgnoreCase))
{
return false;
}
return true;
};
o.RecordException = true;
o.EnrichWithHttpResponse = (activity, httpResponse) =>
{
var user = httpResponse.HttpContext.User;
var preferredUserName = user.Claims.FirstOrDefault(x => x.Type == "preferred_username");
if (preferredUserName is null) return;
activity.AddTag("enduser.id", preferredUserName.Value);
activity.AddTag("enduser.scope", string.Join(',', user.Claims.Select(x => x.ToString())));
};
})
.AddHttpClientInstrumentation();
});
builder.AddOpenTelemetryExporters();
// change it after we call UseAzureMonitor so it is not overwritten
builder.ConfigureHttpClientTraceInstrumentationOptions();
}
private static void AddOpenTelemetryExporters(this IHostApplicationBuilder builder)
{
if (!string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]))
{
builder.Services.AddOpenTelemetry().UseOtlpExporter();
}
if (!string.IsNullOrEmpty(builder.Configuration["ApplicationInsights:ConnectionString"]))
{
// the environment variable name required by the exporter is different from the normal configuration key
builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"] =
builder.Configuration["ApplicationInsights:ConnectionString"];
}
if (string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"])) return;
builder.Services.AddOpenTelemetry().UseAzureMonitor();
}
private static void ConfigureHttpClientTraceInstrumentationOptions(this IHostApplicationBuilder builder)
{
// ignore dapr health checks
builder.Services.Configure<HttpClientTraceInstrumentationOptions>(o => o.FilterHttpRequestMessage = request =>
request.RequestUri?.AbsolutePath.StartsWith("/v1.0/healthz", StringComparison.OrdinalIgnoreCase) is not true);
}
In the aspire dashboard I can see everything is in place (the version unknown is used when starting locally, when running on aks, the version is a semantic version string):
Looking at the same trace event in application insights, the application_version is not there:
from azure-sdk-for-net.
I fixed the exporter version to match up with expectations, was an oversight.
_applicationVersion
was not string.Empty
but had value unknown
In the above screenshot from Aspire dashboard, the actual value can be seen in the service.version
entry.
This pointer however got me tinkering and I replaced unknown
with unknownVersion
and now it actually is present in application insights 😮 So I'm guessing unknown
as a value is filtered out on application insights end maybe?
Thanks for your support!
from azure-sdk-for-net.
Related Issues (20)
- Exception Information Missing HOT 1
- [QUERY] Is there a way to specify the api version in SAS Token? HOT 1
- [FEATURE REQ]Add List and Put functions in EncryptionScopeResource HOT 1
- [QUERY] How to mock SubscriptionCollection resources. HOT 2
- [QUERY] Why is ShareAccessTier Premium missing from the .NET SDK HOT 1
- [QUERY] How to add new access policy to key vault without deleting all existing access policies? HOT 2
- [BUG]: Upgrade Azure.Identity Microsoft.Identity.Client to latest version to resolve security vulnerability HOT 2
- [QUERY] Azure.Identity 1.11.4: how to use WebView2 control? HOT 17
- [QUERY] What is happening with EventGridClient class? HOT 3
- How can we Enable/Disable APIs and Operations in Azure API Management Using .NET SDK and or in Portal HOT 1
- [BUG] Azure Service Bus Timeout instead of correct response: MessagingEntityNotFound HOT 7
- [AppConfig] Update Live Tests for Filter By Tags Feature
- [BUG] Azure.Search.Documents performs vector search successfully, but results are "null" HOT 1
- [QUERY] OpenAI Assistants V2 on Azure - Activate File search on assistant + specify file_ids in message's attachments HOT 4
- infinite lease via break? HOT 2
- [FEATURE REQ] Open Telemetry Sample Request HOT 3
- [BUG] API consistency issue, ManagedIdentityCredential() does not read default values from environment variables, like other Credentials. HOT 1
- [BUG] [OpenAI] ClientResultException 400 Bad Request calling `AzureChatClient.CompleteChatAsync` with PineconeChatDataSource HOT 2
- [FEATURE REQ] Support IsStored for any string field in Azure AI Search HOT 2
- [BUG]Failed to download PEM certificate from azure.keyvault with failure "The provided key does not match the public key for this certificate" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-sdk-for-net.