Skip to content

Instantly share code, notes, and snippets.

View martinjt's full-sized avatar

MartinDotNet martinjt

View GitHub Profile
@martinjt
martinjt / ConsoleEventListener.cs
Created November 14, 2022 16:29
Debugging OpenTelemetry dotnet
public class ConsoleEventListener : EventListener
{
protected override void OnEventSourceCreated(EventSource eventSource)
{
if (eventSource.Name.StartsWith("OpenTelemetry"))
EnableEvents(eventSource, EventLevel.Error);
}
protected override void OnEventWritten(EventWrittenEventArgs eventData)
{
@martinjt
martinjt / OpenTelemetryTests.cs
Created October 30, 2022 19:48
BenchmarkDotNet Tests for OpenTelemetry/Activity
using System.Diagnostics;
using BenchmarkDotNet.Attributes;
using OpenTelemetry;
using OpenTelemetry.Trace;
public class OpenTelemetryTests
{
private readonly Dictionary<string, string> _dictionary = new();
private readonly ActivitySource _source = new("DummyTest");
public OpenTelemetryTests()
@martinjt
martinjt / ids_hash.sql
Created June 25, 2020 15:02
hash for identity server
DECLARE @HASHBYTES VARBINARY(128) = hashbytes('sha2_256', N'secret')
SELECT cast(N'' as xml).value('xs:base64Binary(sql:variable("@HASHBYTES"))', 'varchar(128)');
@martinjt
martinjt / Update-R53ForCurrentHost.psm1
Created August 3, 2017 16:04
Updates a route53 entry with the public hostname of the current EC2 instance. Usage: `Update-R53ForCurrentHost "servers.example.com" "s01"`
function Update-R53ForCurrentHost {
param($zoneName, $subdomain)
Import-Module AWSPowershell
Write-Output "Updating R53 record for $subdomain.$zoneName"
$publicHostname = Invoke-WebRequest `
-Uri http://169.254.169.254/latest/meta-data/public-hostname
Write-Output "New HostName is:$publicHostname"