Skip to content

HeartbeatPlugin ignores heartbeat intervals with a seconds component under 30 (uses TimeSpan.Seconds instead of TotalSeconds) #387

Open

Description

@ejsmith

In Exceptionless 6.2.0 (core Exceptionless package), HeartbeatPlugin validates the configured interval with interval.Value.Seconds >= 30. TimeSpan.Seconds is only the 0-59 seconds component, so most whole-minute intervals are rejected and silently replaced with the 1 minute default.

Where

What happens

Requested interval .Seconds Interval used
TimeSpan.FromSeconds(45) 45 45 seconds
TimeSpan.FromSeconds(90) 30 90 seconds
TimeSpan.FromSeconds(75) 15 1 minute
TimeSpan.FromMinutes(2) 0 1 minute
TimeSpan.FromMinutes(5) 0 1 minute

Any interval that is a whole number of minutes falls back to 1 minute, so config.UseSessions(heartbeatInterval: TimeSpan.FromMinutes(5)) sends heartbeats every minute instead of every 5 minutes.

Expected

Intervals of 30 seconds or more are honored; only intervals under 30 seconds fall back to the default.

With the 6.2.0 package, new HeartbeatPlugin(TimeSpan.FromMinutes(5)) stores an interval of 00:01:00, while new HeartbeatPlugin(TimeSpan.FromSeconds(90)) stores 00:01:30.

Steps to reproduce

  1. config.UseSessions(heartbeatInterval: TimeSpan.FromMinutes(5));
  2. Set a user identity and submit an event to start a session.
  3. Session heartbeat events are sent every minute, not every 5 minutes.

Suggested fix

Use interval.Value.TotalSeconds >= 30 (or interval.Value >= TimeSpan.FromSeconds(30)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions