Incorrect component name in App Insights on Azure, using OpenTelemetry

Viewed 54

I'm using OpenTelemetry to trace my service running on Azure.

Azure Application Map is showing incorrect name for the components sending the trace. It is also sending incorrect Cloud RoleName which is probably why this is happening. The Cloud RoleName that App Insights is displaying is Function App name and not the Function name.

In my Azure Function (called FirewallCreate), I start a trace using following util method:

def get_otel_new_tracer(name=__name__):
    # Setup a TracerProvider(). For more details read:
    # https://docs.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=python#set-the-cloud-role-name-and-the-cloud-role-instance
    trace.set_tracer_provider(
        TracerProvider(
            resource=Resource.create(
                {
                    SERVICE_NAME: name,
                    SERVICE_NAMESPACE: name,
                    # SERVICE_INSTANCE-ID: "my-instance-id"
                }
            )
        )
    )

    # Send messages to Exporter in batches
    span_processor = BatchSpanProcessor(
    AzureMonitorTraceExporter.from_connection_string(
        os.environ["TRACE_APPINSIGHTS_CONNECTION_STRING"]
        )
    )
    trace.get_tracer_provider().add_span_processor(span_processor)

    return trace.get_tracer(name)


def firewall_create():
    tracer = get_otel_new_tracer("FirewallCreate")
    with tracer.start_new_span("span-firewall-create") as span:
        # do some stuff
        ...

The traces show another function name, in the same function app (picture attached).enter image description here

  1. What mistake I could be making?
  2. The component has 0 ms and 0 calls in it. What does it mean? How to interpret it?
1 Answers

Hey thanks for trying out OpenTelemetry with Application Insights! First of all, are you using the azure-monitor-opentelemetry-exporter, and if so, what version are you using? I've also answered your questions inline:

What mistake I could be making?

What name are you trying to set your component to? The exporter will attempt to set your cloudRoleName to <service_namespace>.<service_name> by default that you set in your Resource. If <service_namespace> is not populated, it takes the value of <service_name>.

The component has 0 ms and 0 calls in it. What does it mean? How to interpret it?

Is this the only node in your application map? We need to first find whether this node is created by the exporter or by the functions runtime itself.

Related