Skip to content

[FEATURE REQ] Custom Resource Attributes are not exported #46020

@TimothyMothra

Description

@TimothyMothra

I'm opening this issue to track and consolidate all other reported instances of this problem.
Currently, the Azure Monitor Exporter does not export any custom attribute added to the Resource Attributes.
This affects all 3 signals; Traces, Metrics, and Logs.

This is a highly requested feature and this is on our backlog.

Affected Libraries

  • Azure.Monitor.OpenTelemetry.Exporter
  • Azure.Monitor.OpenTelemetry.AspNetCore

How to Reproduce

var testResourceAttributes = new Dictionary<string, object>()
{
    // THESE ATTRIBUTES DESCRIBE YOUR SERVICE AND WILL BE EXPORTED
    { "service.instance.id", "testInstance" },
    { "service.name", "testName" },
    { "service.namespace", "testNamespace" },
    { "service.version", "testVersion" },

     // CUSTOM ATTRIBUTES ARE NOT EXPORTED TODAY
    { "customAttribute", "customValue" },
};

var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .ConfigureResource(x => x.AddAttributes(testResourceAttributes))
    .AddAzureMonitorTraceExporter()
    .Build();

 var meterProvider = Sdk.CreateMeterProviderBuilder()
     .ConfigureResource(x => x.AddAttributes(testResourceAttributes))
     .AddAzureMonitorMetricExporter()
     .Build();

var loggerFactory = LoggerFactory.Create(builder =>
{
    builder
        .AddOpenTelemetry(options =>
        {
            options.SetResourceBuilder(ResourceBuilder.CreateDefault().AddAttributes(testResourceAttributes));
            options.AddAzureMonitorLogExporter();
        });
});

Workaround

A custom processor can be used to add additional properties to Traces and Logs.

Reported Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Monitor - DistroMonitor OpenTelemetry DistroMonitor - ExporterMonitor OpenTelemetry Exportercustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions