Skip to content

Commit 32b41c8

Browse files
committed
hasSamplingOverride
1 parent f1d672e commit 32b41c8

File tree

1 file changed

+6
-2
lines changed
  • agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/exporter

1 file changed

+6
-2
lines changed

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/exporter/AgentLogExporter.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,18 @@ private void internalExport(LogRecordData log) {
122122

123123
AiSamplerForOverride sampler = samplingOverrides.getOverride(log.getAttributes());
124124

125-
if (sampler == null && spanContext.isValid() && !spanContext.getTraceFlags().isSampled()) {
125+
boolean hasSamplingOverride = sampler != null;
126+
127+
if (!hasSamplingOverride
128+
&& spanContext.isValid()
129+
&& !spanContext.getTraceFlags().isSampled()) {
126130
// if there is no sampling override, and the log is part of an unsampled trace,
127131
// then don't capture it
128132
return;
129133
}
130134

131135
Double sampleRate = null;
132-
if (sampler != null) {
136+
if (hasSamplingOverride) {
133137
SamplingResult samplingResult = sampler.shouldSampleLog(spanContext, parentSpanSampleRate);
134138
if (samplingResult.getDecision() != SamplingDecision.RECORD_AND_SAMPLE) {
135139
return;

0 commit comments

Comments
 (0)