diff --git a/appinsights/telemetry.go b/appinsights/telemetry.go index 3498fa0..40e76da 100644 --- a/appinsights/telemetry.go +++ b/appinsights/telemetry.go @@ -51,11 +51,13 @@ type baseTelemetry struct { Tags contracts.ContextTags } +// Mixin type for telemetry that includes Measurements. type baseTelemetryMeasurements struct { // Custom measurements Measurements map[string]float64 } +// Mixin type for telemetry that omits Measurements. type baseTelemetryNoMeasurements struct { } diff --git a/appinsights/telemetry_test.go b/appinsights/telemetry_test.go index 9bb64a5..ed26bba 100644 --- a/appinsights/telemetry_test.go +++ b/appinsights/telemetry_test.go @@ -59,6 +59,11 @@ func TestTraceTelemetry(t *testing.T) { checkDataContract(t, "Message", d2.Message, "~my-2nd-message~") checkDataContract(t, "SeverityLevel", d2.SeverityLevel, Critical) + + var telemInterface Telemetry + if telemInterface = telem; telemInterface.GetMeasurements() != nil { + t.Errorf("Trace.(Telemetry).GetMeasurements should return nil") + } } func TestEventTelemetry(t *testing.T) { @@ -118,6 +123,11 @@ func TestMetricTelemetry(t *testing.T) { checkDataContract(t, "DataPoint.Value", dp2.Value, 5678.0) checkDataContract(t, "DataPoint.Kind", dp2.Kind, Measurement) checkDataContract(t, "DataPoint.Count", dp2.Count, 1) + + var telemInterface Telemetry + if telemInterface = telem; telemInterface.GetMeasurements() != nil { + t.Errorf("Metric.(Telemetry).GetMeasurements should return nil") + } } type statsTest struct {