dotnet / dotnet/extensions

[API Proposal]: TagProvider but as an interface

Open
#5,439 1 comment 0 reactions 1 assignee Claimed by @dariusclay View on GitHub
api-suggestion area-telemetry
Dominant language
C#
Stars
3.2k
Forks
894
Avg merge
1d 12h
Merged PRs (30d)
23

Description

### Background and motivation

Right now, TagProvider (and LogProperties) are bound to the partial log method for the generator, but the type and the logger are not always available next to each other. Using an interface you can have deconstruction behavior inside some other lib as well.

### API Proposal
```csharp
interface ITagProvider {
void RecordTags(ITagCollector collector);
}
```
### API Usage

```csharp
[GenerateTagProvider]
partial class SomeObj;

[LoggerMessage(...)]
private static partial void SomeLog(
this ILogger logger,
[LogProperties] ITagProvider obj);
```

### Alternative Designs

Using an interceptor like https://github.com/dotnet/runtime/issues/102633 could perhaps help here, but that in and by itself won't cover the generic case without some sort of interfacing.

### Risks

_No response_

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.