Created
October 23, 2020 22:24
-
-
Save jeffhollan/bcdf3569732e16ab464b5e6d7a6619af to your computer and use it in GitHub Desktop.
TracingOptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is what an output binding approach would do | |
// downsides are that everything added is only resolved once the execution finishes | |
// so the timestamps and stuff may be bad | |
namespace Company.Function | |
{ | |
public class HttpTrigger | |
{ | |
[FunctionName("HttpTrigger")] | |
public static async Task<IActionResult> Run( | |
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, | |
[NewRelic("telemetryThing")] IAsyncCollector<TraceConfigProvider> _traceProvider) | |
{ | |
await _traceProvider.AddAsync("foo"); | |
return new OkObjectResult(responseMessage); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is what an output binding approach would do | |
// it now is just using your TelemetryClient directly, and user just needs | |
// to create a constructor and they'd be set. This is pulling out the service you register in your | |
// `Startup.cs` of the extension | |
namespace Company.Function | |
{ | |
private readonly TraceConfigProvider _traceProvider; | |
public class HttpTrigger(TelemetryClient provider) | |
{ | |
_traceProvider = provider.Create(); | |
} | |
public class HttpTrigger | |
{ | |
[FunctionName("HttpTrigger")] | |
public static async Task<IActionResult> Run( | |
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req) | |
{ | |
_traceProvider.trace("foo"); | |
return new OkObjectResult(responseMessage); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment