Azure-Samples / Azure-Samples/functions-quickstart-dotnet-azd-otel

Add sample for storage output binding

Open
#1 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Bicep
Stars
1
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Can you add a sample how to configure OpenTelemetry in order for logging from Storage Account output bindings to show up in Application Insights?

I have the following function that triggers on a Service Bus message and outputs the result in Table Storage.

```csharp
public class SampleFunction
{
private readonly ILogger _logger;

public SampleFunction(ILogger logger)
{
_logger = logger;
}

[Function(nameof(SampleFunction))]
[TableOutput("aisquickSample", Connection = "StorageAccountConnection")]
public SampleTableEntity Run(
[ServiceBusTrigger("aisquick-sample", "function-app", Connection = "ServiceBusConnection", AutoCompleteMessages = true)]
SampleMessage sampleMessage
)
{
_logger.LogInformation("Received message '{message}' with ID {id}", sampleMessage.Message, sampleMessage.Id);

return new SampleTableEntity(sampleMessage);
}
}
```

When I was still using `Microsoft.ApplicationInsights.WorkerService` and `Microsoft.Azure.Functions.Worker.ApplicationInsights`, I could see logging from the `TableClient` in Application Insights:

Image

I tried migrating to OpenTelemetry ([PR](https://github.com/ronaldbosma/azure-integration-services-quickstart/pull/52)) because of [this issue](https://github.com/Azure/azure-functions-dotnet-worker/issues/3322), but the logging from `TableClient` is missing:

Image

I've tried several things with no luck.

Some things I tried:
- Set log level in host.json to Information for `Host.General`, `Microsoft.Azure.Functions.Worker.Extensions.Tables` and `Azure.Data.Tables`.
- Use `AddSource` tracing configuration to enable telemetry for certain namespaces, like adding `.AddSource("Azure.*")` .

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.