@Override public void reset() { setSamplingPercentage(null); }
@Override protected void setSampleRate(Envelope envelope) { Double currentSP = getSamplingPercentage(); if (currentSP != null) { envelope.setSampleRate(currentSP); } } }
/** * Sets the StartTime. Uses the default behavior and sets the property on the 'data' start time * @param timestamp he timestamp as Date. */ @Override public void setTimestamp(Date timestamp) { if (timestamp == null) { timestamp = new Date(); } super.setTimestamp(timestamp); }
((BaseSampleSourceTelemetry)bt).setSamplingPercentage(samplingPercentage); expected.setSamplingRate(DoubleValue.of(samplingPercentage));
@VisibleForTesting static <T extends BaseTelemetry> Telemetry.Builder telemetryBuilderWithStandardFields(T telemetry) { Preconditions.checkArgument(telemetry.getContext() != null, "TelemetryContext is null for telemetry with "+telemetry.getBaseTypeName()); TelemetryContext context = telemetry.getContext(); final String iKey = context.getInstrumentationKey(); Preconditions.checkArgument(iKey != null, "The TelemetryContext.InstrumentationKey is null inside "+telemetry.getBaseTypeName()); final Builder tb = Telemetry.newBuilder(); if (telemetry.getTimestamp() != null) tb.setDateTime(LocalStringsUtils.getDateFormatter().format(telemetry.getTimestamp())); if (telemetry.getSequence() != null) tb.setSequenceNumber(telemetry.getSequence()); if (telemetry instanceof BaseSampleSourceTelemetry) { final BaseSampleSourceTelemetry bsst = (BaseSampleSourceTelemetry) telemetry; if (bsst.getSamplingPercentage() != null) tb.setSamplingRate(DoubleValue.of(bsst.getSamplingPercentage())); } tb.setInstrumentationKey(iKey); if (context.getTags() != null) tb.putAllTags(context.getTags()); tb.setVer(CURRENT_ENVELOPE_VERSION); final String envelopName; if (telemetry instanceof PerformanceCounterTelemetry) { envelopName = MetricTelemetry.ENVELOPE_NAME; } else { envelopName = telemetry.getEnvelopName(); } tb.setDataTypeName(generateDataTypeName(iKey, envelopName)); return tb; }